diff --git a/Parser.cpp b/Parser.cpp index a20226d..89002e2 100644 --- a/Parser.cpp +++ b/Parser.cpp @@ -36,6 +36,11 @@ int Parser::integer(const TiXmlElement *element, int default_value) { return value == nullptr ? default_value : atoi(value); } +int Parser::integer_attr(const TiXmlElement *element, const char *name, int default_value) { + auto value = element->Attribute(name); + return value == nullptr ? default_value : atoi(value); +} + // Loop for parsing children and attributes. // @param method_name This name will be given to the generated method. // @param children Place where to put children and attribute parsing. @@ -130,6 +135,7 @@ int Parser::integer(const TiXmlElement *element, int default_value) { #define LANGUAGE PARSE_SINGLE_CHILD(language, language, text) #define LENGTH PARSE_SINGLE_CHILD(length, length, integer) #define MEDIUM PARSE_CHILDREN_MIXED(medium, medium, medium) +#define MEDIUM_COUNT PARSE_ATTRIBUTE(count, medium_total_count, integer) #define MEDIUM_LIST(children, attributes) INLINE(medium-list, children, attributes) #define NAME PARSE_SINGLE_CHILD(name, name, text) #define NAME_CREDIT PARSE_CHILDREN(name-credit, name_credit) @@ -185,7 +191,8 @@ ELEMENT(Release, release, LABEL_INFO ) MEDIUM_LIST( - MEDIUM + MEDIUM, + MEDIUM_COUNT ) TEXT_REPRESENTATION( LANGUAGE SCRIPT diff --git a/Parser.h b/Parser.h index e831cce..dff88f5 100644 --- a/Parser.h +++ b/Parser.h @@ -34,6 +34,6 @@ namespace foo_musicbrainz { static pfc::string8 text(const TiXmlElement *); static Date date(const TiXmlElement *); static int integer(const TiXmlElement *, int default_value = 0); + static int integer_attr(const TiXmlElement *, const char *, int default_value = 0); }; - } diff --git a/Release.h b/Release.h index 6f256f7..07a6241 100644 --- a/Release.h +++ b/Release.h @@ -16,6 +16,7 @@ namespace foo_musicbrainz { STRING_MEMBER(asin) STRING_MEMBER(language) STRING_MEMBER(script) + MEMBER(int, medium_total_count) MEMBER_BY_REFERENCE(Date, date) POINTER_MEMBER(ArtistCredit, artist_credit) POINTER_MEMBER(ReleaseGroup, release_group) @@ -50,6 +51,7 @@ namespace foo_musicbrainz { Release() : CoreEntity(), status(0), + medium_total_count(0), va(-1), artist_credit(nullptr), release_group(nullptr) {};