Tag Parser  9.1.3
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
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 
9 namespace TagParser {
10 
11 class EbmlElement;
12 class MatroskaTag;
13 
15  friend class MatroskaTag;
16 
17 public:
18  void make(std::ostream &stream) const;
19  const MatroskaTag &tag() const;
20  std::uint64_t requiredSize() const;
21 
22 private:
24 
25  MatroskaTag &m_tag;
26  std::uint64_t m_targetsSize;
27  std::uint64_t m_simpleTagsSize;
28  std::vector<MatroskaTagFieldMaker> m_maker;
29  std::uint64_t m_tagSize;
30  std::uint64_t m_totalSize;
31 };
32 
36 inline const MatroskaTag &MatroskaTagMaker::tag() const
37 {
38  return m_tag;
39 }
40 
44 inline std::uint64_t MatroskaTagMaker::requiredSize() const
45 {
46  return m_totalSize;
47 }
48 
53 public:
55  using Compare = std::less<typename FieldType::IdentifierType>;
56 };
57 
58 class TAG_PARSER_EXPORT MatroskaTag : public FieldMapBasedTag<MatroskaTag> {
60 
61 public:
62  MatroskaTag();
63 
64  static constexpr TagType tagType = TagType::MatroskaTag;
65  static constexpr const char *tagName = "Matroska tag";
66  static constexpr TagTextEncoding defaultTextEncoding = TagTextEncoding::Utf8;
67  bool canEncodingBeUsed(TagTextEncoding encoding) const override;
68  bool supportsTarget() const override;
69  bool supportsMultipleValues(KnownField field) const override;
70  TagTargetLevel targetLevel() const override;
71 
72  void parse(EbmlElement &tagElement, Diagnostics &diag);
73  MatroskaTagMaker prepareMaking(Diagnostics &diag);
74  void make(std::ostream &stream, Diagnostics &diag);
75 
76 protected:
77  IdentifierType internallyGetFieldId(KnownField field) const;
78  KnownField internallyGetKnownField(const IdentifierType &id) const;
79 
80 private:
81  void parseTargets(EbmlElement &targetsElement, Diagnostics &diag);
82 };
83 
88 {
89 }
90 
91 inline bool MatroskaTag::supportsTarget() const
92 {
93  return true;
94 }
95 
102 {
103  return true;
104 }
105 
107 {
109 }
110 
122 {
123  return MatroskaTagMaker(*this, diag);
124 }
125 
133 inline void MatroskaTag::make(std::ostream &stream, Diagnostics &diag)
134 {
135  prepareMaking(diag).make(stream);
136 }
137 
139 {
140  return encoding == TagTextEncoding::Utf8;
141 }
142 
143 } // namespace TagParser
144 
145 #endif // TAG_PARSER_MATROSKATAG_H
TagParser::TagTarget::level
std::uint64_t level() const
Returns the level.
Definition: tagtarget.h:72
TagParser::TagTextEncoding::Utf8
@ Utf8
TagParser::matroskaTagTargetLevel
constexpr TAG_PARSER_EXPORT TagTargetLevel matroskaTagTargetLevel(std::uint64_t targetLevelValue)
Returns the general TagTargetLevel for the Matroska specific targetLevelValue.
Definition: matroskatagid.h:486
TagParser::TagTextEncoding
TagTextEncoding
Specifies the text encoding.
Definition: tagvalue.h:25
TagParser::Tag::m_target
TagTarget m_target
Definition: tag.h:136
TagParser::Diagnostics
The Diagnostics class is a container for DiagMessage.
Definition: diagnostics.h:156
TagParser::TagTargetLevel
TagTargetLevel
The TagTargetLevel enum specifies tag target levels.
Definition: tagtarget.h:16
TagParser::MatroskaTag::supportsTarget
bool supportsTarget() const override
Returns an indication whether a target is supported by the tag.
Definition: matroskatag.h:91
TagParser
Contains all classes and functions of the TagInfo library.
Definition: aaccodebook.h:10
TagParser::TagType::MatroskaTag
@ MatroskaTag
TagParser::MatroskaTagMaker
The MatroskaTagMaker class helps writing Matroska "Tag"-elements storing tag information.
Definition: matroskatag.h:14
TagParser::MatroskaTagMaker::requiredSize
std::uint64_t requiredSize() const
Returns the number of bytes which will be written when making the tag.
Definition: matroskatag.h:44
TagParser::FieldMapBasedTagTraits< MatroskaTag >::Compare
std::less< typename FieldType::IdentifierType > Compare
Definition: matroskatag.h:55
TagParser::EbmlElement
The EbmlElement class helps to parse EBML files such as Matroska files.
Definition: ebmlelement.h:31
TagParser::MatroskaTagField
The MatroskaTagField class is used by MatroskaTag to store the fields.
Definition: matroskatagfield.h:65
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:138
TagParser::MatroskaTag::supportsMultipleValues
bool supportsMultipleValues(KnownField field) const override
Allows multiple values for all fields.
Definition: matroskatag.h:101
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:252
TagParser::KnownField
KnownField
Specifies the field.
Definition: tag.h:42
TagParser::MatroskaTag::targetLevel
TagTargetLevel targetLevel() const override
Returns the name of the current tag target level.
Definition: matroskatag.h:106
TagParser::FieldMapBasedTag
The FieldMapBasedTag provides a generic implementation of Tag which stores the tag fields using std::...
Definition: fieldbasedtag.h:31
matroskatagfield.h
TagParser::MatroskaTag
Implementation of TagParser::Tag for the Matroska container.
Definition: matroskatag.h:58
matroskatagid.h
TAG_PARSER_EXPORT
#define TAG_PARSER_EXPORT
Marks the symbol to be exported by the tagparser library.
TagParser::MatroskaTagMaker::tag
const MatroskaTag & tag() const
Returns the associated tag.
Definition: matroskatag.h:36
TagParser::FieldMapBasedTagTraits
Defines traits for the specified ImplementationType.
Definition: fieldbasedtag.h:17
TagParser::MatroskaTag::prepareMaking
MatroskaTagMaker prepareMaking(Diagnostics &diag)
Prepares making.
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:133
TagParser::TagType
TagType
Specifies the tag type.
Definition: tag.h:20
TagParser::MatroskaTag::MatroskaTag
MatroskaTag()
Constructs a new tag.
Definition: matroskatag.h:87