db/upnp/Directory: use std::string_view instead of StringView
This commit is contained in:
parent
93834fe389
commit
23235e3194
|
@ -23,23 +23,24 @@
|
||||||
#include "tag/Builder.hxx"
|
#include "tag/Builder.hxx"
|
||||||
#include "tag/Table.hxx"
|
#include "tag/Table.hxx"
|
||||||
#include "util/NumberParser.hxx"
|
#include "util/NumberParser.hxx"
|
||||||
#include "util/StringView.hxx"
|
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
using std::string_view_literals::operator""sv;
|
||||||
|
|
||||||
/* this destructor exists here just so it won't get inlined */
|
/* this destructor exists here just so it won't get inlined */
|
||||||
UPnPDirContent::~UPnPDirContent() = default;
|
UPnPDirContent::~UPnPDirContent() = default;
|
||||||
|
|
||||||
[[gnu::pure]]
|
[[gnu::pure]]
|
||||||
static UPnPDirObject::ItemClass
|
static UPnPDirObject::ItemClass
|
||||||
ParseItemClass(StringView name) noexcept
|
ParseItemClass(std::string_view name) noexcept
|
||||||
{
|
{
|
||||||
if (name.Equals("object.item.audioItem.musicTrack"))
|
if (name == "object.item.audioItem.musicTrack"sv)
|
||||||
return UPnPDirObject::ItemClass::MUSIC;
|
return UPnPDirObject::ItemClass::MUSIC;
|
||||||
else if (name.Equals("object.item.playlistItem"))
|
else if (name == "object.item.playlistItem"sv)
|
||||||
return UPnPDirObject::ItemClass::PLAYLIST;
|
return UPnPDirObject::ItemClass::PLAYLIST;
|
||||||
else
|
else
|
||||||
return UPnPDirObject::ItemClass::UNKNOWN;
|
return UPnPDirObject::ItemClass::UNKNOWN;
|
||||||
|
@ -224,7 +225,7 @@ protected:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CLASS:
|
case CLASS:
|
||||||
object.item_class = ParseItemClass(StringView(s, len));
|
object.item_class = ParseItemClass(std::string_view(s, len));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
#include "input/InputStream.hxx"
|
#include "input/InputStream.hxx"
|
||||||
#include "input/Error.hxx"
|
#include "input/Error.hxx"
|
||||||
#include "util/StringCompare.hxx"
|
#include "util/StringCompare.hxx"
|
||||||
#include "util/StringView.hxx"
|
#include "util/StringSplit.hxx"
|
||||||
#include "util/UriExtract.hxx"
|
#include "util/UriExtract.hxx"
|
||||||
#include "Log.hxx"
|
#include "Log.hxx"
|
||||||
|
|
||||||
|
@ -434,14 +434,13 @@ UpdateWalk::DirectoryMakeChildChecked(Directory &parent,
|
||||||
|
|
||||||
inline Directory *
|
inline Directory *
|
||||||
UpdateWalk::DirectoryMakeUriParentChecked(Directory &root,
|
UpdateWalk::DirectoryMakeUriParentChecked(Directory &root,
|
||||||
std::string_view _uri) noexcept
|
std::string_view uri) noexcept
|
||||||
{
|
{
|
||||||
Directory *directory = &root;
|
Directory *directory = &root;
|
||||||
StringView uri(_uri);
|
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
auto [name, rest] = uri.Split('/');
|
auto [name, rest] = Split(uri, '/');
|
||||||
if (rest == nullptr)
|
if (rest.data() == nullptr)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (!name.empty()) {
|
if (!name.empty()) {
|
||||||
|
|
Loading…
Reference in New Issue