Tag Parser
12.5.3
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
Toggle main menu visibility
Loading...
Searching...
No Matches
matroska
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
11
using namespace
std;
12
using namespace
CppUtilities
;
13
14
namespace
TagParser
{
15
20
24
MatroskaChapter::MatroskaChapter
(
EbmlElement
*chapterAtomElement)
25
: m_chapterAtomElement(chapterAtomElement)
26
{
27
}
28
32
MatroskaChapter::~MatroskaChapter
()
33
{
34
}
35
42
void
MatroskaChapter::internalParse
(
Diagnostics
&diag,
AbortableProgressFeedback
&progress)
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()) {
53
case
MatroskaIds::ChapterUID
:
54
m_id
= chapterAtomChild->readUInteger();
55
break
;
56
case
MatroskaIds::ChapterStringUID
:
57
break
;
58
case
MatroskaIds::ChapterTimeStart
:
59
m_startTime
=
TimeSpan
(
static_cast<
std::int64_t
>
(chapterAtomChild->readUInteger() / 100u));
60
break
;
61
case
MatroskaIds::ChapterTimeEnd
:
62
m_endTime
=
TimeSpan
(
static_cast<
std::int64_t
>
(chapterAtomChild->readUInteger() / 100u));
63
break
;
64
case
MatroskaIds::ChapterFlagHidden
:
65
m_hidden
= chapterAtomChild->readUInteger() == 1;
66
break
;
67
case
MatroskaIds::ChapterFlagEnabled
:
68
m_enabled
= chapterAtomChild->readUInteger() == 1;
69
break
;
70
case
MatroskaIds::ChapterSegmentUID
:
71
case
MatroskaIds::ChapterSegmentEditionUID
:
72
case
MatroskaIds::ChapterPhysicalEquiv
:
73
break
;
74
case
MatroskaIds::ChapterTrack
:
75
for
(
EbmlElement
*chapterTrackElement = chapterAtomChild->
firstChild
(); chapterTrackElement;
76
chapterTrackElement = chapterTrackElement->
nextSibling
()) {
77
chapterTrackElement->parse(diag);
78
switch
(chapterTrackElement->id()) {
79
case
MatroskaIds::ChapterTrack
:
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
;
89
case
MatroskaIds::ChapterDisplay
:
90
m_names
.emplace_back();
91
for
(
EbmlElement
*chapterDisplayElement = chapterAtomChild->
firstChild
(); chapterDisplayElement;
92
chapterDisplayElement = chapterDisplayElement->
nextSibling
()) {
93
chapterDisplayElement->parse(diag);
94
switch
(chapterDisplayElement->id()) {
95
case
MatroskaIds::ChapString
:
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
;
103
case
MatroskaIds::ChapLanguage
:
104
m_names
.back().locale().emplace_back(chapterDisplayElement->readString(),
LocaleFormat::ISO_639_2_B
);
105
break
;
106
case
MatroskaIds::ChapLanguageIETF
:
107
m_names
.back().locale().emplace_back(chapterDisplayElement->readString(),
LocaleFormat::BCP_47
);
108
break
;
109
case
MatroskaIds::ChapCountry
:
110
m_names
.back().locale().emplace_back(chapterDisplayElement->readString(),
LocaleFormat::DomainCountry
);
111
break
;
112
}
113
}
114
break
;
115
case
MatroskaIds::ChapProcess
:
116
break
;
117
case
MatroskaIds::ChapterAtom
:
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
133
void
MatroskaChapter::clear
()
134
{
135
AbstractChapter::clear
();
136
m_nestedChapters.clear();
137
}
138
139
}
// namespace TagParser
TagParser::AbortableProgressFeedback
The AbortableProgressFeedback class provides feedback about an ongoing operation via callbacks.
Definition
progressfeedback.h:186
TagParser::AbstractChapter::m_enabled
bool m_enabled
Definition
abstractchapter.h:48
TagParser::AbstractChapter::m_id
std::uint64_t m_id
Definition
abstractchapter.h:41
TagParser::AbstractChapter::m_tracks
std::vector< std::uint64_t > m_tracks
Definition
abstractchapter.h:45
TagParser::AbstractChapter::m_endTime
CppUtilities::TimeSpan m_endTime
Definition
abstractchapter.h:44
TagParser::AbstractChapter::m_hidden
bool m_hidden
Definition
abstractchapter.h:47
TagParser::AbstractChapter::m_startTime
CppUtilities::TimeSpan m_startTime
Definition
abstractchapter.h:43
TagParser::AbstractChapter::clear
virtual void clear()
Resets the object to its initial state.
Definition
abstractchapter.cpp:57
TagParser::AbstractChapter::m_names
std::vector< LocaleAwareString > m_names
Definition
abstractchapter.h:42
TagParser::Diagnostics
The Diagnostics class is a container for DiagMessage.
Definition
diagnostics.h:156
TagParser::EbmlElement
The EbmlElement class helps to parse EBML files such as Matroska files.
Definition
ebmlelement.h:32
TagParser::GenericFileElement::nextSibling
ImplementationType * nextSibling()
Returns the next sibling of the element.
Definition
genericfileelement.h:439
TagParser::GenericFileElement::firstChild
ImplementationType * firstChild()
Returns the first child of the element.
Definition
genericfileelement.h:465
TagParser::LocaleAwareString
The LocaleAwareString class is a standard string with locale information (languages,...
Definition
localeawarestring.h:14
TagParser::MatroskaChapter::MatroskaChapter
MatroskaChapter(EbmlElement *chapterAtomElement)
Constructs a new MatroskaChapter for the specified chapterAtomElement.
Definition
matroskachapter.cpp:24
TagParser::MatroskaChapter::internalParse
void internalParse(Diagnostics &diag, AbortableProgressFeedback &progress) override
Parses the "ChapterAtom"-element which has been specified when constructing the object.
Definition
matroskachapter.cpp:42
TagParser::MatroskaChapter::~MatroskaChapter
~MatroskaChapter() override
Destroys the chapter.
Definition
matroskachapter.cpp:32
TagParser::MatroskaChapter::clear
void clear() override
Resets the object to its initial state.
Definition
matroskachapter.cpp:133
diagnostics.h
ebmlelement.h
matroskachapter.h
matroskaid.h
CppUtilities
Definition
abstractcontainer.h:16
TagParser::MatroskaIds::ChapterTrack
@ ChapterTrack
Definition
matroskaid.h:322
TagParser::MatroskaIds::ChapterTimeEnd
@ ChapterTimeEnd
Definition
matroskaid.h:316
TagParser::MatroskaIds::ChapterTimeStart
@ ChapterTimeStart
Definition
matroskaid.h:315
TagParser::MatroskaIds::ChapterFlagHidden
@ ChapterFlagHidden
Definition
matroskaid.h:317
TagParser::MatroskaIds::ChapterUID
@ ChapterUID
Definition
matroskaid.h:313
TagParser::MatroskaIds::ChapterFlagEnabled
@ ChapterFlagEnabled
Definition
matroskaid.h:318
TagParser::MatroskaIds::ChapterPhysicalEquiv
@ ChapterPhysicalEquiv
Definition
matroskaid.h:321
TagParser::MatroskaIds::ChapterSegmentEditionUID
@ ChapterSegmentEditionUID
Definition
matroskaid.h:320
TagParser::MatroskaIds::ChapterStringUID
@ ChapterStringUID
Definition
matroskaid.h:314
TagParser::MatroskaIds::ChapterDisplay
@ ChapterDisplay
Definition
matroskaid.h:323
TagParser::MatroskaIds::ChapterSegmentUID
@ ChapterSegmentUID
Definition
matroskaid.h:319
TagParser::MatroskaIds::ChapProcess
@ ChapProcess
Definition
matroskaid.h:324
TagParser::MatroskaIds::ChapterAtom
@ ChapterAtom
Definition
matroskaid.h:306
TagParser::MatroskaIds::ChapCountry
@ ChapCountry
Definition
matroskaid.h:335
TagParser::MatroskaIds::ChapLanguageIETF
@ ChapLanguageIETF
Definition
matroskaid.h:335
TagParser::MatroskaIds::ChapLanguage
@ ChapLanguage
Definition
matroskaid.h:335
TagParser::MatroskaIds::ChapString
@ ChapString
Definition
matroskaid.h:335
TagParser
Contains all classes and functions of the TagInfo library.
Definition
aaccodebook.h:10
TagParser::LocaleFormat::BCP_47
@ BCP_47
Definition
localehelper.h:20
TagParser::LocaleFormat::ISO_639_2_B
@ ISO_639_2_B
Definition
localehelper.h:19
TagParser::LocaleFormat::DomainCountry
@ DomainCountry
Definition
localehelper.h:16
TagParser::DiagLevel::Warning
@ Warning
Definition
diagnostics.h:20
TagParser::TagDataType::TimeSpan
@ TimeSpan
Definition
tagvalue.h:124
Generated on
for Tag Parser by
1.18.0