Tag Parser  7.1.0
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  uint64 requiredSize() const;
21 
22 private:
24 
25  MatroskaTag &m_tag;
26  uint64 m_targetsSize;
27  uint64 m_simpleTagsSize;
28  std::vector<MatroskaTagFieldMaker> m_maker;
29  uint64 m_tagSize;
30  uint64 m_totalSize;
31 };
32 
36 inline const MatroskaTag &MatroskaTagMaker::tag() const
37 {
38  return m_tag;
39 }
40 
44 inline uint64 MatroskaTagMaker::requiredSize() const
45 {
46  return m_totalSize;
47 }
48 
53 public:
55  typedef std::less<typename FieldType::IdentifierType> Compare;
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;
68  bool supportsTarget() const;
69  TagTargetLevel targetLevel() const;
70 
71  void parse(EbmlElement &tagElement, Diagnostics &diag);
72  MatroskaTagMaker prepareMaking(Diagnostics &diag);
73  void make(std::ostream &stream, Diagnostics &diag);
74 
75 protected:
76  IdentifierType internallyGetFieldId(KnownField field) const;
77  KnownField internallyGetKnownField(const IdentifierType &id) const;
78 
79 private:
80  void parseTargets(EbmlElement &targetsElement, Diagnostics &diag);
81 };
82 
87 {
88 }
89 
90 inline bool MatroskaTag::supportsTarget() const
91 {
92  return true;
93 }
94 
96 {
98 }
99 
101 {
102  return encoding == TagTextEncoding::Utf8;
103 }
104 
105 } // namespace TagParser
106 
107 #endif // TAG_PARSER_MATROSKATAG_H
The FieldMapBasedTag provides a generic implementation of Tag which stores the tag fields using std::...
Definition: fieldbasedtag.h:31
bool canEncodingBeUsed(TagTextEncoding encoding) const
Returns an indication whether the specified encoding can be used to provide string values for the tag...
Definition: matroskatag.h:100
TagTargetLevel
The TagTargetLevel enum specifies tag target levels.
Definition: tagtarget.h:17
uint64 requiredSize() const
Returns the number of bytes which will be written when making the tag.
Definition: matroskatag.h:44
uint64 level() const
Returns the level.
Definition: tagtarget.h:72
The MatroskaTagMaker class helps writing Matroska "Tag"-elements storing tag information.
Definition: matroskatag.h:14
KnownField
Specifies the field.
Definition: tag.h:40
The EbmlElement class helps to parse EBML files such as Matroska files.
Definition: ebmlelement.h:31
The MatroskaTagField class is used by MatroskaTag to store the fields.
Defines traits for the specified ImplementationType.
Definition: fieldbasedtag.h:17
bool supportsTarget() const
Returns an indication whether a target is supported by the tag.
Definition: matroskatag.h:90
TAG_PARSER_EXPORT TagTargetLevel matroskaTagTargetLevel(uint64 targetLevelValue)
Returns the general TagTargetLevel for the Matroska specific targetLevelValue.
Implementation of TagParser::Tag for the Matroska container.
Definition: matroskatag.h:58
std::less< typename FieldType::IdentifierType > Compare
Definition: matroskatag.h:55
MatroskaTag()
Constructs a new tag.
Definition: matroskatag.h:86
TagTargetLevel targetLevel() const
Returns the name of the current tag target level.
Definition: matroskatag.h:95
TagTarget m_target
Definition: tag.h:132
const MatroskaTag & tag() const
Returns the associated tag.
Definition: matroskatag.h:36
TagType
Specifies the tag type.
Definition: tag.h:20
TagTextEncoding
Specifies the text encoding.
Definition: tagvalue.h:23
Contains all classes and functions of the TagInfo library.
Definition: aaccodebook.h:9
#define TAG_PARSER_EXPORT
Marks the symbol to be exported by the tagparser library.
The Diagnostics class is a container for DiagMessage.
Definition: diagnostics.h:154