diff options
author | Max Kellermann <max@musicpd.org> | 2020-03-11 20:51:47 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2020-03-11 20:51:47 +0100 |
commit | 51b1dd867207fdc69d83556fa32742198847b31a (patch) | |
tree | 742d2b82a3b55f55ec0cc3955ffc8e40ad4614e0 | |
parent | 98a7d8da6cd88ddb335fbc375ef546a09ae8ea16 (diff) |
playlist/xspf: use tag_table to convert element name to TagType
-rw-r--r-- | src/playlist/plugins/XspfPlaylistPlugin.cxx | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/src/playlist/plugins/XspfPlaylistPlugin.cxx b/src/playlist/plugins/XspfPlaylistPlugin.cxx index 4a4b240bf..b084725fe 100644 --- a/src/playlist/plugins/XspfPlaylistPlugin.cxx +++ b/src/playlist/plugins/XspfPlaylistPlugin.cxx @@ -23,6 +23,7 @@ #include "song/DetachedSong.hxx" #include "input/InputStream.hxx" #include "tag/Builder.hxx" +#include "tag/Table.hxx" #include "util/StringView.hxx" #include "lib/expat/ExpatParser.hxx" #include "Log.hxx" @@ -62,6 +63,19 @@ struct XspfParser { TagBuilder tag_builder; }; +static constexpr struct tag_table xspf_tag_elements[] = { + { "title", TAG_TITLE }, + + /* TAG_COMPOSER would be more correct according to the XSPF + spec */ + { "creator", TAG_ARTIST }, + + { "annotation", TAG_COMMENT }, + { "album", TAG_ALBUM }, + { "trackNum", TAG_TRACK }, + { nullptr, TAG_NUM_OF_ITEM_TYPES } +}; + static void XMLCALL xspf_start_element(void *user_data, const XML_Char *element_name, gcc_unused const XML_Char **atts) @@ -93,18 +107,9 @@ xspf_start_element(void *user_data, const XML_Char *element_name, case XspfParser::TRACK: if (strcmp(element_name, "location") == 0) parser->state = XspfParser::LOCATION; - else if (strcmp(element_name, "title") == 0) - parser->tag_type = TAG_TITLE; - else if (strcmp(element_name, "creator") == 0) - /* TAG_COMPOSER would be more correct - according to the XSPF spec */ - parser->tag_type = TAG_ARTIST; - else if (strcmp(element_name, "annotation") == 0) - parser->tag_type = TAG_COMMENT; - else if (strcmp(element_name, "album") == 0) - parser->tag_type = TAG_ALBUM; - else if (strcmp(element_name, "trackNum") == 0) - parser->tag_type = TAG_TRACK; + else + parser->tag_type = tag_table_lookup(xspf_tag_elements, + element_name); break; |