Tag Parser  6.3.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 <c++utilities/conversion/stringbuilder.h>
6 #include <c++utilities/conversion/stringconversion.h>
7 
8 #include <string>
9 #include <memory>
10 
11 using namespace std;
12 using namespace ConversionUtilities;
13 
14 namespace Media {
15 
24 MatroskaEditionEntry::MatroskaEditionEntry(EbmlElement *editionEntryElement) :
25  m_editionEntryElement(editionEntryElement),
26  m_id(0),
27  m_hidden(false),
28  m_default(false),
29  m_ordered(false)
30 {}
31 
36 {}
37 
42 {
43  return "ID: " + numberToString(id());
44 }
45 
54 {
55  // clear previous values and status
56  static const string context("parsing \"EditionEntry\"-element");
58  clear();
59  // iterate through children of "EditionEntry"-element
60  EbmlElement *entryChild = m_editionEntryElement->firstChild();
61  while(entryChild) {
62  entryChild->parse();
63  switch(entryChild->id()) {
65  m_id = entryChild->readUInteger();
66  break;
68  m_hidden = entryChild->readUInteger() == 1;
69  break;
71  m_default = entryChild->readUInteger() == 1;
72  break;
74  m_ordered = entryChild->readUInteger() == 1;
75  break;
77  m_chapters.emplace_back(make_unique<MatroskaChapter>(entryChild));
78  break;
79  default:
80  addNotification(NotificationType::Warning, "\"EditionEntry\"-element contains unknown child element \"" % entryChild->idToString() + "\" which will be ingored.", context);
81  }
82  entryChild = entryChild->nextSibling();
83  }
84 }
85 
93 {
94  parse();
95  for(auto &chapter : chapters()) {
96  chapter->parseNested();
97  }
98 }
99 
104 {
105  m_id = 0;
106  m_hidden = m_default = m_ordered = false;
107  m_chapters.clear();
108 }
109 
110 } // namespace Media
111 
void invalidateStatus()
Invalidates the current status.
implementationType * nextSibling()
Returns the next sibling of the element.
uint64 readUInteger()
Reads the content of the element as unsigned integer.
The EbmlElement class helps to parse EBML files such as Matroska files.
Definition: ebmlelement.h:50
void parse()
Parses the header information of the element which is read from the related stream at the start offse...
STL namespace.
void addNotification(const Notification &notification)
This protected method is meant to be called by the derived class to add a notification.
void clear()
Resets the object to its initial state.
void parseNested()
Parses the "EditionEntry"-element specified when constructing the object.
void parse()
Parses the "EditionEntry"-element specified when constructing the object.
std::string idToString() const
Converts the specified EBML ID to a printable string.
Definition: ebmlelement.h:91
implementationType * firstChild()
Returns the first child of the element.
const identifierType & id() const
Returns the element ID.
~MatroskaEditionEntry()
Destroys the MatroskaEditionEntry.
std::string label() const
Returns a label for the entry.
const std::vector< std::unique_ptr< MatroskaChapter > > & chapters() const
Returns the chapters the edition contains.
Contains all classes and functions of the TagInfo library.
Definition: exceptions.h:9