Tag Parser  6.1.1
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/misc/memory.h>
6 
7 #include <string>
8 
9 using namespace std;
10 
11 namespace Media {
12 
21 MatroskaEditionEntry::MatroskaEditionEntry(EbmlElement *editionEntryElement) :
22  m_editionEntryElement(editionEntryElement),
23  m_id(0),
24  m_hidden(false),
25  m_default(false),
26  m_ordered(false)
27 {}
28 
33 {}
34 
39 {
40  stringstream ss;
41  ss << "ID: " << id();
42  return ss.str();
43 }
44 
53 {
54  // clear previous values and status
55  static const string context("parsing \"EditionEntry\"-element");
57  clear();
58  // iterate through children of "EditionEntry"-element
59  EbmlElement *entryChild = m_editionEntryElement->firstChild();
60  while(entryChild) {
61  entryChild->parse();
62  switch(entryChild->id()) {
64  m_id = entryChild->readUInteger();
65  break;
67  m_hidden = entryChild->readUInteger() == 1;
68  break;
70  m_default = entryChild->readUInteger() == 1;
71  break;
73  m_ordered = entryChild->readUInteger() == 1;
74  break;
76  m_chapters.emplace_back(make_unique<MatroskaChapter>(entryChild));
77  break;
78  default:
79  addNotification(NotificationType::Warning, "\"EditionEntry\"-element contains unknown child element \"" + entryChild->idToString() + "\" which will be ingored.", context);
80  }
81  entryChild = entryChild->nextSibling();
82  }
83 }
84 
92 {
93  parse();
94  for(auto &chapter : chapters()) {
95  chapter->parseNested();
96  }
97 }
98 
103 {
104  m_id = 0;
105  m_hidden = m_default = m_ordered = false;
106  m_chapters.clear();
107 }
108 
109 } // namespace Media
110 
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.
uint64 id() const
Returns the edition ID.
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:90
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