Tag Parser 12.3.1
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
5#include "./matroskatagid.h"
6
7#include "../fieldbasedtag.h"
8
9namespace TagParser {
10
11class EbmlElement;
12class MatroskaTag;
13
17enum class MatroskaTagFlags : std::uint64_t {
18 None = 0x0,
20};
21
22} // namespace TagParser
23
25
26namespace TagParser {
27
28class 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:
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
51{
52 return m_tag;
53}
54
58inline std::uint64_t MatroskaTagMaker::requiredSize() const
59{
60 return m_totalSize;
61}
62
67public:
69 using Compare = std::less<typename FieldType::IdentifierType>;
70};
71
72class TAG_PARSER_EXPORT MatroskaTag final : public FieldMapBasedTag<MatroskaTag> {
73 friend class FieldMapBasedTag<MatroskaTag>;
74
75public:
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
103{
104}
105
107{
108 return true;
109}
110
117{
118 return true;
119}
120
125
137{
138 return MatroskaTagMaker(*this, diag);
139}
140
148inline void MatroskaTag::make(std::ostream &stream, Diagnostics &diag)
149{
150 prepareMaking(diag).make(stream);
151}
152
154{
155 return encoding == TagTextEncoding::Utf8;
156}
157
158} // namespace TagParser
159
160#endif // TAG_PARSER_MATROSKATAG_H
The Diagnostics class is a container for DiagMessage.
The EbmlElement class helps to parse EBML files such as Matroska files.
std::less< typename FieldType::IdentifierType > Compare
Definition matroskatag.h:69
Defines traits for the specified ImplementationType.
The FieldMapBasedTag provides a generic implementation of Tag which stores the tag fields using std::...
The MatroskaTagField class is used by MatroskaTag to store the fields.
The MatroskaTagMaker class helps writing Matroska "Tag"-elements storing tag information.
std::uint64_t requiredSize() const
Returns the number of bytes which will be written when making the tag.
Definition matroskatag.h:58
const MatroskaTag & tag() const
Returns the associated tag.
Definition matroskatag.h:50
void make(std::ostream &stream) const
Saves the tag (specified when constructing the object) to the specified stream (makes a "Tag"-element...
Implementation of TagParser::Tag for the Matroska container.
bool supportsTarget() const override
Returns an indication whether a target is supported by the tag.
bool supportsMultipleValues(KnownField field) const override
Allows multiple values for all fields.
MatroskaTagMaker prepareMaking(Diagnostics &diag)
Prepares making.
bool canEncodingBeUsed(TagTextEncoding encoding) const override
Returns an indication whether the specified encoding can be used to provide string values for the tag...
TagTargetLevel targetLevel() const override
Returns the name of the current tag target level.
void make(std::ostream &stream, Diagnostics &diag)
Writes tag information to the specified stream (makes a "Tag"-element).
MatroskaTag()
Constructs a new tag.
std::uint64_t level() const
Returns the level.
Definition tagtarget.h:73
TagTarget m_target
Definition tag.h:208
#define TAG_PARSER_EXPORT
Marks the symbol to be exported by the tagparser library.
Definition global.h:14
Contains all classes and functions of the TagInfo library.
Definition aaccodebook.h:10
KnownField
Specifies the field.
Definition tag.h:29
TagTargetLevel
The TagTargetLevel enum specifies tag target levels.
Definition tagtarget.h:16
TagTextEncoding
Specifies the text encoding.
Definition tagvalue.h:29
MatroskaTagFlags
The MatroskaTagFlags enum specifies flags which controls parsing and making of Matroska tags.
Definition matroskatag.h:17
constexpr TAG_PARSER_EXPORT TagTargetLevel matroskaTagTargetLevel(std::uint64_t targetLevelValue)
Returns the general TagTargetLevel for the Matroska specific targetLevelValue.
TagType
Specifies the tag type.
Definition tagtype.h:11
CPP_UTILITIES_MARK_FLAG_ENUM_CLASS(TagParser, TagParser::TagCreationFlags)