Tag Parser  8.0.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 ConversionUtilities;
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
const std::vector< std::unique_ptr< MatroskaChapter > > & chapters() const
Returns the chapters the edition contains.
ImplementationType * nextSibling()
Returns the next sibling of the element.
ImplementationType * firstChild()
Returns the first child of the element.
STL namespace.
void parse(Diagnostics &diag)
Parses the "EditionEntry"-element specified when constructing the object.
The EbmlElement class helps to parse EBML files such as Matroska files.
Definition: ebmlelement.h:31
std::string idToString() const
Converts the specified EBML ID to a printable string.
Definition: ebmlelement.h:71
void parse(Diagnostics &diag)
Parses the header information of the element which is read from the related stream at the start offse...
~MatroskaEditionEntry()
Destroys the MatroskaEditionEntry.
uint64 readUInteger()
Reads the content of the element as unsigned integer.
void parseNested(Diagnostics &diag)
Parses the "EditionEntry"-element specified when constructing the object.
std::string label() const
Returns a label for the entry.
void clear()
Resets the object to its initial state.
const IdentifierType & id() const
Returns the element ID.
Contains all classes and functions of the TagInfo library.
Definition: aaccodebook.h:9
The Diagnostics class is a container for DiagMessage.
Definition: diagnostics.h:156