Tag Parser 12.3.1
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
Loading...
Searching...
No Matches
matroskachapter.cpp
Go to the documentation of this file.
1#include "./matroskachapter.h"
2#include "./ebmlelement.h"
3#include "./matroskaid.h"
4
5#include "../diagnostics.h"
6
7#include <c++utilities/conversion/stringbuilder.h>
8
9#include <memory>
10
11using namespace std;
12using namespace CppUtilities;
13
14namespace TagParser {
15
25 : m_chapterAtomElement(chapterAtomElement)
26{
27}
28
35
43{
44 CPP_UTILITIES_UNUSED(progress)
45
46 // clear previous values and status
47 static const string context("parsing \"ChapterAtom\"-element");
48 clear();
49 // iterate through children of "ChapterAtom"-element
50 for (EbmlElement *chapterAtomChild = m_chapterAtomElement->firstChild(); chapterAtomChild; chapterAtomChild = chapterAtomChild->nextSibling()) {
51 chapterAtomChild->parse(diag);
52 switch (chapterAtomChild->id()) {
54 m_id = chapterAtomChild->readUInteger();
55 break;
57 break;
59 m_startTime = TimeSpan(static_cast<std::int64_t>(chapterAtomChild->readUInteger() / 100u));
60 break;
62 m_endTime = TimeSpan(static_cast<std::int64_t>(chapterAtomChild->readUInteger() / 100u));
63 break;
65 m_hidden = chapterAtomChild->readUInteger() == 1;
66 break;
68 m_enabled = chapterAtomChild->readUInteger() == 1;
69 break;
73 break;
75 for (EbmlElement *chapterTrackElement = chapterAtomChild->firstChild(); chapterTrackElement;
76 chapterTrackElement = chapterTrackElement->nextSibling()) {
77 chapterTrackElement->parse(diag);
78 switch (chapterTrackElement->id()) {
80 m_tracks.emplace_back(chapterTrackElement->readUInteger());
81 break;
82 default:
83 diag.emplace_back(DiagLevel::Warning,
84 "\"ChapterTrack\"-element contains unknown child element \"" % chapterAtomChild->idToString() + "\". It will be ignored.",
85 context);
86 }
87 }
88 break;
90 m_names.emplace_back();
91 for (EbmlElement *chapterDisplayElement = chapterAtomChild->firstChild(); chapterDisplayElement;
92 chapterDisplayElement = chapterDisplayElement->nextSibling()) {
93 chapterDisplayElement->parse(diag);
94 switch (chapterDisplayElement->id()) {
96 if (m_names.back().empty()) {
97 m_names.back().assign(chapterDisplayElement->readString());
98 } else {
99 diag.emplace_back(DiagLevel::Warning,
100 "\"ChapterDisplay\"-element contains multiple \"ChapString\"-elements. Surplus occurrences will be ignored.", context);
101 }
102 break;
104 m_names.back().locale().emplace_back(chapterDisplayElement->readString(), LocaleFormat::ISO_639_2_B);
105 break;
107 m_names.back().locale().emplace_back(chapterDisplayElement->readString(), LocaleFormat::BCP_47);
108 break;
110 m_names.back().locale().emplace_back(chapterDisplayElement->readString(), LocaleFormat::DomainCountry);
111 break;
112 }
113 }
114 break;
116 break;
118 m_nestedChapters.emplace_back(make_unique<MatroskaChapter>(chapterAtomChild));
119 break;
120 default:
121 diag.emplace_back(DiagLevel::Warning,
122 "\"ChapterAtom\"-element contains unknown child element \"" % chapterAtomChild->idToString() + "\". It will be ignored.", context);
123 }
124 }
125 // "eng" is default language
126 for (LocaleAwareString &name : m_names) {
127 if (name.locale().empty()) {
128 name.locale().emplace_back("eng"sv, LocaleFormat::ISO_639_2_B);
129 }
130 }
131}
132
134{
136 m_nestedChapters.clear();
137}
138
139} // namespace TagParser
The AbortableProgressFeedback class provides feedback about an ongoing operation via callbacks.
std::vector< std::uint64_t > m_tracks
CppUtilities::TimeSpan m_endTime
CppUtilities::TimeSpan m_startTime
virtual void clear()
Resets the object to its initial state.
std::vector< LocaleAwareString > m_names
The Diagnostics class is a container for DiagMessage.
The EbmlElement class helps to parse EBML files such as Matroska files.
ImplementationType * nextSibling()
Returns the next sibling of the element.
ImplementationType * firstChild()
Returns the first child of the element.
The LocaleAwareString class is a standard string with locale information (languages,...
MatroskaChapter(EbmlElement *chapterAtomElement)
Constructs a new MatroskaChapter for the specified chapterAtomElement.
void internalParse(Diagnostics &diag, AbortableProgressFeedback &progress) override
Parses the "ChapterAtom"-element which has been specified when constructing the object.
~MatroskaChapter() override
Destroys the chapter.
void clear() override
Resets the object to its initial state.
Contains all classes and functions of the TagInfo library.
Definition aaccodebook.h:10