Tag Parser  6.2.2
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 MEDIA_MATROSKATAG_H
2 #define MEDIA_MATROSKATAG_H
3 
4 #include "./matroskatagfield.h"
5 #include "./matroskatagid.h"
6 
7 #include "../fieldbasedtag.h"
8 
9 namespace Media {
10 
11 class EbmlElement;
12 class MatroskaTag;
13 
15 {
16  friend class MatroskaTag;
17 
18 public:
19  void make(std::ostream &stream) const;
20  const MatroskaTag &tag() const;
21  uint64 requiredSize() const;
22 
23 private:
25 
26  MatroskaTag &m_tag;
27  uint64 m_targetsSize;
28  uint64 m_simpleTagsSize;
29  std::vector<MatroskaTagFieldMaker> m_maker;
30  uint64 m_tagSize;
31  uint64 m_totalSize;
32 };
33 
37 inline const MatroskaTag &MatroskaTagMaker::tag() const
38 {
39  return m_tag;
40 }
41 
45 inline uint64 MatroskaTagMaker::requiredSize() const
46 {
47  return m_totalSize;
48 }
49 
50 class TAG_PARSER_EXPORT MatroskaTag : public FieldMapBasedTag<MatroskaTagField>
51 {
52 public:
53  MatroskaTag();
54 
55  static constexpr TagType tagType = TagType::MatroskaTag;
56  // FIXME: implement type() and typeName() in FieldMapBasedTag
57  TagType type() const;
58  const char *typeName() const;
59  TagTextEncoding proposedTextEncoding() const;
60  bool canEncodingBeUsed(TagTextEncoding encoding) const;
61  bool supportsTarget() const;
62  TagTargetLevel targetLevel() const;
63 
64  std::string fieldId(KnownField field) const;
65  KnownField knownField(const std::string &id) const;
66 
67  void parse(EbmlElement &tagElement);
68  MatroskaTagMaker prepareMaking();
69  void make(std::ostream &stream);
70 
71 private:
72  void parseTargets(EbmlElement &targetsElement);
73 };
74 
79 {}
80 
81 inline bool MatroskaTag::supportsTarget() const
82 {
83  return true;
84 }
85 
87 {
88  return matroskaTagTargetLevel(m_target.level());
89 }
90 
91 inline TagType MatroskaTag::type() const
92 {
93  return TagType::MatroskaTag;
94 }
95 
96 inline const char *MatroskaTag::typeName() const
97 {
98  return "Matroska tag";
99 }
100 
102 {
103  return TagTextEncoding::Utf8;
104 }
105 
107 {
108  return encoding == TagTextEncoding::Utf8;
109 }
110 
111 }
112 
113 #endif // MEDIA_MATROSKATAG_H
TagTargetLevel targetLevel() const
Returns the name of the current tag target level.
Definition: matroskatag.h:86
TAG_PARSER_EXPORT TagTargetLevel matroskaTagTargetLevel(uint64 targetLevelValue)
Returns the general TagTargetLevel for the Matroska specific targetLevelValue.
TagType type() const
Returns the type of the tag as Media::TagType.
Definition: matroskatag.h:91
bool supportsTarget() const
Returns an indication whether a target is supported by the tag.
Definition: matroskatag.h:81
MatroskaTag()
Constructs a new tag.
Definition: matroskatag.h:78
The EbmlElement class helps to parse EBML files such as Matroska files.
Definition: ebmlelement.h:50
The MatroskaTagMaker class helps writing Matroska "Tag"-elements storing tag information.
Definition: matroskatag.h:14
KnownField
Specifies the field.
Definition: tag.h:42
const MatroskaTag & tag() const
Returns the associated tag.
Definition: matroskatag.h:37
TagTextEncoding proposedTextEncoding() const
Returns the proposed text encoding.
Definition: matroskatag.h:101
TagTextEncoding
Specifies the text encoding.
Definition: tagvalue.h:21
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:106
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:45
The FieldMapBasedTag provides a generic implementation of Tag which stores the tag fields using std::...
Definition: fieldbasedtag.h:25
TagType
Specifies the tag type.
Definition: tag.h:21
Implementation of Media::Tag for the Matroska container.
Definition: matroskatag.h:50
Contains all classes and functions of the TagInfo library.
Definition: exceptions.h:9
const char * typeName() const
Returns the type name of the tag as C-style string.
Definition: matroskatag.h:96
#define TAG_PARSER_EXPORT
Marks the symbol to be exported by the tagparser library.