diff options
author | Max Kellermann <max@duempel.org> | 2013-07-30 20:11:57 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-07-30 20:19:53 +0200 |
commit | 06f898cc1240a29b293de0e97ad95a4fdc971254 (patch) | |
tree | 001a6d3db039cdc03323f3bfddc13b94bde31ce4 /src/cue | |
parent | 6a9ab8bc0e2f5d34803513bb2d94d041a607a58c (diff) | |
download | mpd-06f898cc1240a29b293de0e97ad95a4fdc971254.tar.gz mpd-06f898cc1240a29b293de0e97ad95a4fdc971254.tar.xz mpd-06f898cc1240a29b293de0e97ad95a4fdc971254.zip |
tag: convert to C++
Diffstat (limited to 'src/cue')
-rw-r--r-- | src/cue/CueParser.cxx | 31 | ||||
-rw-r--r-- | src/cue/CueParser.hxx | 5 |
2 files changed, 19 insertions, 17 deletions
diff --git a/src/cue/CueParser.cxx b/src/cue/CueParser.cxx index ae1445abc..e2ae6f2dd 100644 --- a/src/cue/CueParser.cxx +++ b/src/cue/CueParser.cxx @@ -21,15 +21,16 @@ #include "CueParser.hxx" #include "util/StringUtil.hxx" #include "Song.hxx" -#include "tag.h" +#include "Tag.hxx" #include <glib.h> #include <assert.h> +#include <string.h> #include <stdlib.h> CueParser::CueParser() - :state(HEADER), tag(tag_new()), + :state(HEADER), tag(new Tag()), filename(nullptr), current(nullptr), previous(nullptr), @@ -38,7 +39,7 @@ CueParser::CueParser() CueParser::~CueParser() { - tag_free(tag); + delete tag; g_free(filename); if (current != nullptr) @@ -109,16 +110,16 @@ cue_next_value(char **pp) } static void -cue_add_tag(struct tag *tag, enum tag_type type, char *p) +cue_add_tag(Tag &tag, enum tag_type type, char *p) { const char *value = cue_next_value(&p); if (value != nullptr) - tag_add_item(tag, type, value); + tag.AddItem(type, value); } static void -cue_parse_rem(char *p, struct tag *tag) +cue_parse_rem(char *p, Tag &tag) { const char *type = cue_next_token(&p); if (type == nullptr) @@ -129,7 +130,7 @@ cue_parse_rem(char *p, struct tag *tag) cue_add_tag(tag, type2, p); } -struct tag * +Tag * CueParser::GetCurrentTag() { if (state == HEADER) @@ -188,9 +189,9 @@ CueParser::Feed2(char *p) return; if (strcmp(command, "REM") == 0) { - struct tag *current_tag = GetCurrentTag(); + Tag *current_tag = GetCurrentTag(); if (current_tag != nullptr) - cue_parse_rem(p, current_tag); + cue_parse_rem(p, *current_tag); } else if (strcmp(command, "PERFORMER") == 0) { /* MPD knows a "performer" tag, but it is not a good match for this CUE tag; from the Hydrogenaudio @@ -202,14 +203,14 @@ CueParser::Feed2(char *p) ? TAG_ARTIST : TAG_ALBUM_ARTIST; - struct tag *current_tag = GetCurrentTag(); + Tag *current_tag = GetCurrentTag(); if (current_tag != nullptr) - cue_add_tag(current_tag, type, p); + cue_add_tag(*current_tag, type, p); } else if (strcmp(command, "TITLE") == 0) { if (state == HEADER) - cue_add_tag(tag, TAG_ALBUM, p); + cue_add_tag(*tag, TAG_ALBUM, p); else if (state == TRACK) - cue_add_tag(current->tag, TAG_TITLE, p); + cue_add_tag(*current->tag, TAG_TITLE, p); } else if (strcmp(command, "FILE") == 0) { Commit(); @@ -252,8 +253,8 @@ CueParser::Feed2(char *p) state = TRACK; current = Song::NewRemote(filename); assert(current->tag == nullptr); - current->tag = tag_dup(tag); - tag_add_item(current->tag, TAG_TRACK, nr); + current->tag = new Tag(*tag); + current->tag->AddItem(TAG_TRACK, nr); last_updated = false; } else if (state == IGNORE_TRACK) { return; diff --git a/src/cue/CueParser.hxx b/src/cue/CueParser.hxx index ad2a6f34c..5cb51200f 100644 --- a/src/cue/CueParser.hxx +++ b/src/cue/CueParser.hxx @@ -24,6 +24,7 @@ #include "gcc.h" struct Song; +struct Tag; class CueParser { enum { @@ -53,7 +54,7 @@ class CueParser { IGNORE_TRACK, } state; - struct tag *tag; + Tag *tag; char *filename; @@ -115,7 +116,7 @@ public: private: gcc_pure - struct tag *GetCurrentTag(); + Tag *GetCurrentTag(); /** * Commit the current song. It will be moved to "previous", |