tag/ParseName: add StringView overloads
This commit is contained in:
parent
548aa00111
commit
589639f80f
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2003-2018 The Music Player Daemon Project
|
||||
* Copyright 2003-2019 The Music Player Daemon Project
|
||||
* http://www.musicpd.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include "ParseName.hxx"
|
||||
#include "util/ASCII.hxx"
|
||||
#include "util/StringView.hxx"
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
@ -38,6 +39,21 @@ tag_name_parse(const char *name) noexcept
|
|||
return TAG_NUM_OF_ITEM_TYPES;
|
||||
}
|
||||
|
||||
TagType
|
||||
tag_name_parse(StringView name) noexcept
|
||||
{
|
||||
assert(name != nullptr);
|
||||
|
||||
for (unsigned i = 0; i < TAG_NUM_OF_ITEM_TYPES; ++i) {
|
||||
assert(tag_item_names[i] != nullptr);
|
||||
|
||||
if (name.Equals(tag_item_names[i]))
|
||||
return (TagType)i;
|
||||
}
|
||||
|
||||
return TAG_NUM_OF_ITEM_TYPES;
|
||||
}
|
||||
|
||||
TagType
|
||||
tag_name_parse_i(const char *name) noexcept
|
||||
{
|
||||
|
@ -52,3 +68,18 @@ tag_name_parse_i(const char *name) noexcept
|
|||
|
||||
return TAG_NUM_OF_ITEM_TYPES;
|
||||
}
|
||||
|
||||
TagType
|
||||
tag_name_parse_i(StringView name) noexcept
|
||||
{
|
||||
assert(name != nullptr);
|
||||
|
||||
for (unsigned i = 0; i < TAG_NUM_OF_ITEM_TYPES; ++i) {
|
||||
assert(tag_item_names[i] != nullptr);
|
||||
|
||||
if (name.EqualsIgnoreCase(tag_item_names[i]))
|
||||
return (TagType)i;
|
||||
}
|
||||
|
||||
return TAG_NUM_OF_ITEM_TYPES;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2003-2018 The Music Player Daemon Project
|
||||
* Copyright 2003-2019 The Music Player Daemon Project
|
||||
* http://www.musicpd.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
|
@ -23,6 +23,8 @@
|
|||
#include "Type.h"
|
||||
#include "util/Compiler.h"
|
||||
|
||||
struct StringView;
|
||||
|
||||
/**
|
||||
* Parse the string, and convert it into a #TagType. Returns
|
||||
* #TAG_NUM_OF_ITEM_TYPES if the string could not be recognized.
|
||||
|
@ -31,6 +33,10 @@ gcc_pure
|
|||
TagType
|
||||
tag_name_parse(const char *name) noexcept;
|
||||
|
||||
gcc_pure
|
||||
TagType
|
||||
tag_name_parse(StringView name) noexcept;
|
||||
|
||||
/**
|
||||
* Parse the string, and convert it into a #TagType. Returns
|
||||
* #TAG_NUM_OF_ITEM_TYPES if the string could not be recognized.
|
||||
|
@ -41,4 +47,8 @@ gcc_pure
|
|||
TagType
|
||||
tag_name_parse_i(const char *name) noexcept;
|
||||
|
||||
gcc_pure
|
||||
TagType
|
||||
tag_name_parse_i(StringView name) noexcept;
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue