Tag Parser: matroska/matroskatag.h Source File

Tag Parser 12.5.2 C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags

Loading...
Searching...
No Matches
matroskatag.h
Go to the documentation of this file.
1#ifndef TAG_PARSER_MATROSKATAG_H
2#define TAG_PARSER_MATROSKATAG_H
3
4#include "./matroskatagfield.h"
5#include "./matroskatagid.h"
6
7#include "../fieldbasedtag.h"
8
9namespace TagParser {
10
11class EbmlElement;
12class MatroskaTag;
13
17 enum class MatroskaTagFlags : std::uint64_t {
18 None = 0x0,
19 NormalizeKnownFieldIds = 0x1,
20};
21
22} // namespace TagParser
23
24 CPP_UTILITIES_MARK_FLAG_ENUM_CLASS(TagParser, TagParser::MatroskaTagFlags)
25
26namespace TagParser {
27
28 class TAG_PARSER_EXPORT MatroskaTagMaker {
29 friend class MatroskaTag;
30
31public:
32 void make(std::ostream &stream) const;
33 const MatroskaTag &tag() const;
34 std::uint64_t requiredSize() const;
35
36private:
37 MatroskaTagMaker(MatroskaTag &tag, Diagnostics &diag);
38
39 MatroskaTag &m_tag;
40 std::uint64_t m_targetsSize;
41 std::uint64_t m_simpleTagsSize;
42 std::vector<MatroskaTagFieldMaker> m_maker;
43 std::uint64_t m_tagSize;
44 std::uint64_t m_totalSize;
45};
46
50 inline const MatroskaTag &MatroskaTagMaker::tag() const
51{
52 return m_tag;
53}
54
58 inline std::uint64_t MatroskaTagMaker::requiredSize() const
59{
60 return m_totalSize;
61}
62
66 template <> class TAG_PARSER_EXPORT FieldMapBasedTagTraits<MatroskaTag> {
67public:
68 using FieldType = MatroskaTagField;
69 using Compare = std::less<typename FieldType::IdentifierType>;
70};
71
72 class TAG_PARSER_EXPORT MatroskaTag final : public FieldMapBasedTag<MatroskaTag> {
73 friend class FieldMapBasedTag<MatroskaTag>;
74
75public:
76 MatroskaTag();
77
78 static constexpr TagType tagType = TagType::MatroskaTag;
79 static constexpr std::string_view tagName = "Matroska tag";
80 static constexpr TagTextEncoding defaultTextEncoding = TagTextEncoding::Utf8;
81 bool canEncodingBeUsed(TagTextEncoding encoding) const override;
82 bool supportsTarget() const override;
83 bool supportsMultipleValues(KnownField field) const override;
84 TagTargetLevel targetLevel() const override;
85
86 void parse(EbmlElement &tagElement, Diagnostics &diag);
87 void parse2(EbmlElement &tagElement, MatroskaTagFlags flags, Diagnostics &diag);
88 MatroskaTagMaker prepareMaking(Diagnostics &diag);
89 void make(std::ostream &stream, Diagnostics &diag);
90
91protected:
92 IdentifierType internallyGetFieldId(KnownField field) const;
93 KnownField internallyGetKnownField(const IdentifierType &id) const;
94
95private:
96 void parseTargets(EbmlElement &targetsElement, Diagnostics &diag);
97};
98
102 inline MatroskaTag::MatroskaTag()
103{
104}
105
106 inline bool MatroskaTag::supportsTarget() const
107{
108 return true;
109}
110
116 inline bool MatroskaTag::supportsMultipleValues(KnownField) const
117{
118 return true;
119}
120
121 inline TagTargetLevel MatroskaTag::targetLevel() const
122{
123 return matroskaTagTargetLevel(m_target.level());
124}
125
136 inline MatroskaTagMaker MatroskaTag::prepareMaking(Diagnostics &diag)
137{
138 return MatroskaTagMaker(*this, diag);
139}
140
148 inline void MatroskaTag::make(std::ostream &stream, Diagnostics &diag)
149{
150 prepareMaking(diag).make(stream);
151}
152
153 inline bool MatroskaTag::canEncodingBeUsed(TagTextEncoding encoding) const
154{
155 return encoding == TagTextEncoding::Utf8;
156}
157
158} // namespace TagParser
159
160#endif // TAG_PARSER_MATROSKATAG_H
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::FieldMapBasedTagTraits< MatroskaTag >::Compare
std::less< typename FieldType::IdentifierType > Compare
Definition matroskatag.h:69
TagParser::FieldMapBasedTagTraits< MatroskaTag >::FieldType
MatroskaTagField FieldType
Definition matroskatag.h:68
TagParser::FieldMapBasedTagTraits
Defines traits for the specified ImplementationType.
Definition fieldbasedtag.h:17
TagParser::FieldMapBasedTag< MatroskaTag >::IdentifierType
typename FieldMapBasedTagTraits< MatroskaTag >::FieldType::IdentifierType IdentifierType
Definition fieldbasedtag.h:35
TagParser::FieldMapBasedTag< MatroskaTag >::FieldMapBasedTag
FieldMapBasedTag()
Definition fieldbasedtag.h:100
TagParser::MatroskaTagField
The MatroskaTagField class is used by MatroskaTag to store the fields.
Definition matroskatagfield.h:67
TagParser::MatroskaTagMaker
The MatroskaTagMaker class helps writing Matroska "Tag"-elements storing tag information.
Definition matroskatag.h:28
TagParser::MatroskaTagMaker::requiredSize
std::uint64_t requiredSize() const
Returns the number of bytes which will be written when making the tag.
Definition matroskatag.h:58
TagParser::MatroskaTagMaker::tag
const MatroskaTag & tag() const
Returns the associated tag.
Definition matroskatag.h:50
TagParser::MatroskaTagMaker::make
void make(std::ostream &stream) const
Saves the tag (specified when constructing the object) to the specified stream (makes a "Tag"-element...
Definition matroskatag.cpp:483
TagParser::MatroskaTagMaker::MatroskaTag
friend class MatroskaTag
Definition matroskatag.h:29
TagParser::MatroskaTag
Implementation of TagParser::Tag for the Matroska container.
Definition matroskatag.h:72
TagParser::MatroskaTag::defaultTextEncoding
static constexpr TagTextEncoding defaultTextEncoding
Definition matroskatag.h:80
TagParser::MatroskaTag::supportsTarget
bool supportsTarget() const override
Returns an indication whether a target is supported by the tag.
Definition matroskatag.h:106
TagParser::MatroskaTag::parse
void parse(EbmlElement &tagElement, Diagnostics &diag)
Parses tag information from the specified tagElement.
Definition matroskatag.cpp:317
TagParser::MatroskaTag::supportsMultipleValues
bool supportsMultipleValues(KnownField field) const override
Allows multiple values for all fields.
Definition matroskatag.h:116
TagParser::MatroskaTag::prepareMaking
MatroskaTagMaker prepareMaking(Diagnostics &diag)
Prepares making.
Definition matroskatag.h:136
TagParser::MatroskaTag::canEncodingBeUsed
bool canEncodingBeUsed(TagTextEncoding encoding) const override
Returns an indication whether the specified encoding can be used to provide string values for the tag...
Definition matroskatag.h:153
TagParser::MatroskaTag::parse2
void parse2(EbmlElement &tagElement, MatroskaTagFlags flags, Diagnostics &diag)
Parses tag information from the specified tagElement.
Definition matroskatag.cpp:329
TagParser::MatroskaTag::targetLevel
TagTargetLevel targetLevel() const override
Returns the name of the current tag target level.
Definition matroskatag.h:121
TagParser::MatroskaTag::make
void make(std::ostream &stream, Diagnostics &diag)
Writes tag information to the specified stream (makes a "Tag"-element).
Definition matroskatag.h:148
TagParser::MatroskaTag::tagType
static constexpr TagType tagType
Definition matroskatag.h:78
TagParser::MatroskaTag::internallyGetFieldId
IdentifierType internallyGetFieldId(KnownField field) const
Definition matroskatag.cpp:20
TagParser::MatroskaTag::internallyGetKnownField
KnownField internallyGetKnownField(const IdentifierType &id) const
Definition matroskatag.cpp:211
TagParser::MatroskaTag::tagName
static constexpr std::string_view tagName
Definition matroskatag.h:79
TagParser::MatroskaTag::MatroskaTag
MatroskaTag()
Constructs a new tag.
Definition matroskatag.h:102
TagParser::Tag::m_target
TagTarget m_target
Definition tag.h:219
fieldbasedtag.h
TAG_PARSER_EXPORT
#define TAG_PARSER_EXPORT
Marks the symbol to be exported by the tagparser library.
Definition global.h:14
matroskatagfield.h
matroskatagid.h
TagParser::SubFormats::None
@ None
Definition mediaformat.h:112
TagParser
Contains all classes and functions of the TagInfo library.
Definition aaccodebook.h:10
TagParser::KnownField
KnownField
Specifies the field.
Definition tag.h:37
TagParser::TagTargetLevel
TagTargetLevel
The TagTargetLevel enum specifies tag target levels.
Definition tagtarget.h:16
TagParser::TagTextEncoding
TagTextEncoding
Specifies the text encoding.
Definition tagvalue.h:29
TagParser::TagTextEncoding::Utf8
@ Utf8
Definition tagvalue.h:31
TagParser::MatroskaTagFlags
MatroskaTagFlags
The MatroskaTagFlags enum specifies flags which controls parsing and making of Matroska tags.
Definition matroskatag.h:17
TagParser::MatroskaTagFlags::NormalizeKnownFieldIds
@ NormalizeKnownFieldIds
Definition matroskatag.h:19
TagParser::matroskaTagTargetLevel
constexpr TAG_PARSER_EXPORT TagTargetLevel matroskaTagTargetLevel(std::uint64_t targetLevelValue)
Returns the general TagTargetLevel for the Matroska specific targetLevelValue.
Definition matroskatagid.h:524
TagParser::TagType
TagType
Specifies the tag type.
Definition tagtype.h:11
TagParser::TagType::MatroskaTag
@ MatroskaTag
Definition tagtype.h:16
CPP_UTILITIES_MARK_FLAG_ENUM_CLASS
CPP_UTILITIES_MARK_FLAG_ENUM_CLASS(TagParser, TagParser::TagCreationFlags)