Tag Parser  6.1.1
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  TagType type() const;
56  const char *typeName() const;
57  TagTextEncoding proposedTextEncoding() const;
58  bool canEncodingBeUsed(TagTextEncoding encoding) const;
59  bool supportsTarget() const;
60  TagTargetLevel targetLevel() const;
61 
62  std::string fieldId(KnownField field) const;
63  KnownField knownField(const std::string &id) const;
64 
65  void parse(EbmlElement &tagElement);
66  MatroskaTagMaker prepareMaking();
67  void make(std::ostream &stream);
68 
69 private:
70  void parseTargets(EbmlElement &targetsElement);
71 };
72 
77 {}
78 
79 inline bool MatroskaTag::supportsTarget() const
80 {
81  return true;
82 }
83 
85 {
86  return matroskaTagTargetLevel(m_target.level());
87 }
88 
89 inline TagType MatroskaTag::type() const
90 {
91  return TagType::MatroskaTag;
92 }
93 
94 inline const char *MatroskaTag::typeName() const
95 {
96  return "Matroska tag";
97 }
98 
100 {
101  return TagTextEncoding::Utf8;
102 }
103 
105 {
106  return encoding == TagTextEncoding::Utf8;
107 }
108 
109 }
110 
111 #endif // MEDIA_MATROSKATAG_H
TagTargetLevel targetLevel() const
Returns the name of the current tag target level.
Definition: matroskatag.h:84
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:89
bool supportsTarget() const
Returns an indication whether a target is supported by the tag.
Definition: matroskatag.h:79
MatroskaTag()
Constructs a new tag.
Definition: matroskatag.h:76
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:99
TagTextEncoding
Specifies the text encoding.
Definition: tagvalue.h:22
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:104
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:94
#define TAG_PARSER_EXPORT
Marks the symbol to be exported by the tagparser library.