Skip to content
This repository has been archived by the owner on Oct 4, 2020. It is now read-only.

Commit

Permalink
Added total medium count (needed when some discs are dropped during f…
Browse files Browse the repository at this point in the history
…iltration)
  • Loading branch information
Dremora committed Jun 2, 2011
1 parent 637507a commit e490641
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
9 changes: 8 additions & 1 deletion Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -185,7 +191,8 @@ ELEMENT(Release, release,
LABEL_INFO
)
MEDIUM_LIST(
MEDIUM
MEDIUM,
MEDIUM_COUNT
)
TEXT_REPRESENTATION(
LANGUAGE SCRIPT
Expand Down
2 changes: 1 addition & 1 deletion Parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

}
2 changes: 2 additions & 0 deletions Release.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -50,6 +51,7 @@ namespace foo_musicbrainz {
Release() :
CoreEntity(),
status(0),
medium_total_count(0),
va(-1),
artist_credit(nullptr),
release_group(nullptr) {};
Expand Down

0 comments on commit e490641

Please sign in to comment.