Tag Parser  9.2.0
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
matroskaeditionentry.cpp
Go to the documentation of this file.
2 #include "./ebmlelement.h"
3 #include "./matroskaid.h"
4 
5 #include "../diagnostics.h"
6 
7 #include <c++utilities/conversion/stringbuilder.h>
8 #include <c++utilities/conversion/stringconversion.h>
9 
10 #include <memory>
11 #include <string>
12 
13 using namespace std;
14 using namespace CppUtilities;
15 
16 namespace TagParser {
17 
26 MatroskaEditionEntry::MatroskaEditionEntry(EbmlElement *editionEntryElement)
27  : m_editionEntryElement(editionEntryElement)
28  , m_id(0)
29  , m_hidden(false)
30  , m_default(false)
31  , m_ordered(false)
32 {
33 }
34 
39 {
40 }
41 
46 {
47  return argsToString("ID: ", id());
48 }
49 
58 {
59  // clear previous values and status
60  static const string context("parsing \"EditionEntry\"-element");
61  clear();
62  // iterate through children of "EditionEntry"-element
63  EbmlElement *entryChild = m_editionEntryElement->firstChild();
64  while (entryChild) {
65  entryChild->parse(diag);
66  switch (entryChild->id()) {
68  m_id = entryChild->readUInteger();
69  break;
71  m_hidden = entryChild->readUInteger() == 1;
72  break;
74  m_default = entryChild->readUInteger() == 1;
75  break;
77  m_ordered = entryChild->readUInteger() == 1;
78  break;
80  m_chapters.emplace_back(make_unique<MatroskaChapter>(entryChild));
81  break;
82  default:
83  diag.emplace_back(DiagLevel::Warning,
84  "\"EditionEntry\"-element contains unknown child element \"" % entryChild->idToString() + "\" which will be ingored.", context);
85  }
86  entryChild = entryChild->nextSibling();
87  }
88 }
89 
97 {
98  parse(diag);
99  for (auto &chapter : chapters()) {
100  chapter->parseNested(diag);
101  }
102 }
103 
108 {
109  m_id = 0;
110  m_hidden = m_default = m_ordered = false;
111  m_chapters.clear();
112 }
113 
114 } // namespace TagParser
TagParser::MatroskaEditionEntry::~MatroskaEditionEntry
~MatroskaEditionEntry()
Destroys the MatroskaEditionEntry.
Definition: matroskaeditionentry.cpp:38
TagParser::MatroskaEditionEntry::label
std::string label() const
Returns a label for the entry.
Definition: matroskaeditionentry.cpp:45
TagParser::EbmlElement::readUInteger
std::uint64_t readUInteger()
Reads the content of the element as unsigned integer.
Definition: ebmlelement.cpp:238
TagParser::DiagLevel::Warning
@ Warning
TagParser::Diagnostics
The Diagnostics class is a container for DiagMessage.
Definition: diagnostics.h:156
TagParser
Contains all classes and functions of the TagInfo library.
Definition: aaccodebook.h:10
TagParser::GenericFileElement::nextSibling
ImplementationType * nextSibling()
Returns the next sibling of the element.
Definition: genericfileelement.h:434
TagParser::GenericFileElement::id
const IdentifierType & id() const
Returns the element ID.
Definition: genericfileelement.h:278
TagParser::GenericFileElement::parse
void parse(Diagnostics &diag)
Parses the header information of the element which is read from the related stream at the start offse...
Definition: genericfileelement.h:771
TagParser::MatroskaIds::EditionFlagDefault
@ EditionFlagDefault
Definition: matroskaid.h:296
TagParser::MatroskaIds::EditionUID
@ EditionUID
Definition: matroskaid.h:294
TagParser::GenericFileElement::firstChild
ImplementationType * firstChild()
Returns the first child of the element.
Definition: genericfileelement.h:460
matroskaid.h
TagParser::EbmlElement
The EbmlElement class helps to parse EBML files such as Matroska files.
Definition: ebmlelement.h:31
TagParser::MatroskaEditionEntry::chapters
const std::vector< std::unique_ptr< MatroskaChapter > > & chapters() const
Returns the chapters the edition contains.
Definition: matroskaeditionentry.h:79
TagParser::MatroskaEditionEntry::parseNested
void parseNested(Diagnostics &diag)
Parses the "EditionEntry"-element specified when constructing the object.
Definition: matroskaeditionentry.cpp:96
CppUtilities
Definition: abstractcontainer.h:15
TagParser::EbmlElement::idToString
std::string idToString() const
Converts the specified EBML ID to a printable string.
Definition: ebmlelement.h:71
TagParser::MatroskaIds::EditionFlagOrdered
@ EditionFlagOrdered
Definition: matroskaid.h:297
matroskaeditionentry.h
TagParser::MatroskaIds::EditionFlagHidden
@ EditionFlagHidden
Definition: matroskaid.h:295
ebmlelement.h
TagParser::MatroskaEditionEntry::clear
void clear()
Resets the object to its initial state.
Definition: matroskaeditionentry.cpp:107
TagParser::MatroskaEditionEntry::parse
void parse(Diagnostics &diag)
Parses the "EditionEntry"-element specified when constructing the object.
Definition: matroskaeditionentry.cpp:57
TagParser::MatroskaIds::ChapterAtom
@ ChapterAtom
Definition: matroskaid.h:298