diff options
author | Max Kellermann <max@musicpd.org> | 2020-03-12 20:40:18 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2020-03-12 20:40:18 +0100 |
commit | c71242d74362671af2da4bbfb3d92f69ee86f97d (patch) | |
tree | ec26d443028532d87d300633fa13978759728035 | |
parent | c45f1138560b526649bf6e6433fa7d9ba8a6564b (diff) |
playlist/asx: use tag_table to convert element name to TagType
-rw-r--r-- | src/playlist/plugins/AsxPlaylistPlugin.cxx | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/playlist/plugins/AsxPlaylistPlugin.cxx b/src/playlist/plugins/AsxPlaylistPlugin.cxx index 58c004b08..b4a198815 100644 --- a/src/playlist/plugins/AsxPlaylistPlugin.cxx +++ b/src/playlist/plugins/AsxPlaylistPlugin.cxx @@ -21,6 +21,7 @@ #include "../PlaylistPlugin.hxx" #include "../MemorySongEnumerator.hxx" #include "tag/Builder.hxx" +#include "tag/Table.hxx" #include "util/ASCII.hxx" #include "util/StringView.hxx" #include "lib/expat/ExpatParser.hxx" @@ -62,6 +63,14 @@ struct AsxParser { }; +static constexpr struct tag_table asx_tag_elements[] = { + /* is that correct? or should it be COMPOSER or PERFORMER? */ + { "author", TAG_ARTIST }, + + { "title", TAG_TITLE }, + { nullptr, TAG_NUM_OF_ITEM_TYPES } +}; + static void XMLCALL asx_start_element(void *user_data, const XML_Char *element_name, const XML_Char **atts) @@ -84,12 +93,9 @@ asx_start_element(void *user_data, const XML_Char *element_name, ExpatParser::GetAttributeCase(atts, "href"); if (href != nullptr) parser->location = href; - } else if (StringEqualsCaseASCII(element_name, "author")) - /* is that correct? or should it be COMPOSER - or PERFORMER? */ - parser->tag_type = TAG_ARTIST; - else if (StringEqualsCaseASCII(element_name, "title")) - parser->tag_type = TAG_TITLE; + } else + parser->tag_type = tag_table_lookup_i(asx_tag_elements, + element_name); break; } |