mpd/src/tag/ParseName.cxx

52 lines
1.0 KiB
C++
Raw Normal View History

// SPDX-License-Identifier: GPL-2.0-or-later
// Copyright The Music Player Daemon Project
#include "ParseName.hxx"
#include "util/ASCII.hxx"
2022-06-30 10:51:33 +02:00
#include "util/StringCompare.hxx"
#include <cassert>
#include <string.h>
TagType
2022-06-30 10:51:33 +02:00
tag_name_parse(std::string_view name) noexcept
{
for (unsigned i = 0; i < TAG_NUM_OF_ITEM_TYPES; ++i) {
assert(tag_item_names[i] != nullptr);
2022-06-30 10:51:33 +02:00
if (name == tag_item_names[i])
return (TagType)i;
}
return TAG_NUM_OF_ITEM_TYPES;
}
TagType
tag_name_parse_i(const char *name) noexcept
{
assert(name != nullptr);
for (unsigned i = 0; i < TAG_NUM_OF_ITEM_TYPES; ++i) {
assert(tag_item_names[i] != nullptr);
if (StringEqualsCaseASCII(name, tag_item_names[i]))
return (TagType)i;
}
return TAG_NUM_OF_ITEM_TYPES;
}
TagType
2022-06-30 10:51:33 +02:00
tag_name_parse_i(std::string_view name) noexcept
{
for (unsigned i = 0; i < TAG_NUM_OF_ITEM_TYPES; ++i) {
assert(tag_item_names[i] != nullptr);
2022-06-30 10:51:33 +02:00
if (StringIsEqualIgnoreCase(name, tag_item_names[i]))
return (TagType)i;
}
return TAG_NUM_OF_ITEM_TYPES;
}