lib/dbus/UDisks2: use std::string_view instead of StringView

This commit is contained in:
Max Kellermann 2022-07-04 14:47:22 +02:00
parent 4964eda167
commit 1c30b3d5a1

View File

@ -23,7 +23,6 @@
#include "ObjectManager.hxx" #include "ObjectManager.hxx"
#include "util/SpanCast.hxx" #include "util/SpanCast.hxx"
#include "util/StringAPI.hxx" #include "util/StringAPI.hxx"
#include "util/StringView.hxx"
#include "util/Compiler.h" #include "util/Compiler.h"
#include <functional> #include <functional>
@ -44,11 +43,11 @@ CheckString(I &&i) noexcept
template<typename I> template<typename I>
gcc_pure gcc_pure
static StringView static std::string_view
CheckRecursedByteArrayToString(I &&i) noexcept CheckRecursedByteArrayToString(I &&i) noexcept
{ {
if (i.GetArgType() != DBUS_TYPE_BYTE) if (i.GetArgType() != DBUS_TYPE_BYTE)
return nullptr; return {};
auto value = i.template GetFixedArray<char>(); auto value = i.template GetFixedArray<char>();
return ToStringView(value); return ToStringView(value);
@ -56,22 +55,22 @@ CheckRecursedByteArrayToString(I &&i) noexcept
template<typename I> template<typename I>
gcc_pure gcc_pure
static StringView static std::string_view
CheckByteArrayToString(I &&i) noexcept CheckByteArrayToString(I &&i) noexcept
{ {
if (i.GetArgType() != DBUS_TYPE_ARRAY) if (i.GetArgType() != DBUS_TYPE_ARRAY)
return nullptr; return {};
return CheckRecursedByteArrayToString(i.Recurse()); return CheckRecursedByteArrayToString(i.Recurse());
} }
template<typename I> template<typename I>
gcc_pure gcc_pure
static StringView static std::string_view
CheckByteArrayArrayFrontToString(I &&i) noexcept CheckByteArrayArrayFrontToString(I &&i) noexcept
{ {
if (i.GetArgType() != DBUS_TYPE_ARRAY) if (i.GetArgType() != DBUS_TYPE_ARRAY)
return nullptr; return {};
return CheckByteArrayToString(i.Recurse()); return CheckByteArrayToString(i.Recurse());
} }
@ -110,8 +109,8 @@ ParseFileesystemDictEntry(Object &o, const char *name,
/* get the first string in the array */ /* get the first string in the array */
auto value = CheckByteArrayArrayFrontToString(value_i); auto value = CheckByteArrayArrayFrontToString(value_i);
if (value != nullptr) if (value.data() != nullptr)
o.mount_point = {value.data, value.size}; o.mount_point = value;
// TODO: check whether the string is a valid filesystem path // TODO: check whether the string is a valid filesystem path
} }