Tag Parser  8.0.0
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
matroskatagfield.h
Go to the documentation of this file.
1 #ifndef TAG_PARSER_MATROSKATAGFIELD_H
2 #define TAG_PARSER_MATROSKATAGFIELD_H
3 
4 #include "../generictagfield.h"
5 
6 namespace TagParser {
7 
8 class EbmlElement;
9 class MatroskaTagField;
10 class Diagnostics;
11 
16 public:
17  using IdentifierType = std::string;
18  using TypeInfoType = std::string;
19  static bool supportsNestedFields();
20 };
21 
26 {
27  return true;
28 }
29 
31  friend class MatroskaTagField;
32 
33 public:
34  void make(std::ostream &stream) const;
35  const MatroskaTagField &field() const;
36  uint64 requiredSize() const;
37 
38 private:
40 
41  MatroskaTagField &m_field;
42  bool m_isBinary;
43  std::string m_stringValue;
44  uint64 m_simpleTagSize;
45  uint64 m_totalSize;
46  std::vector<MatroskaTagFieldMaker> m_nestedMaker;
47 };
48 
53 {
54  return m_field;
55 }
56 
61 {
62  return m_totalSize;
63 }
64 
65 class TAG_PARSER_EXPORT MatroskaTagField : public TagField<MatroskaTagField> {
66  friend class TagField<MatroskaTagField>;
67 
68 public:
70  MatroskaTagField(const std::string &id, const TagValue &value);
71 
72  void reparse(EbmlElement &simpleTagElement, Diagnostics &diag, bool parseNestedFields = true);
73  MatroskaTagFieldMaker prepareMaking(Diagnostics &diag);
74  void make(std::ostream &stream, Diagnostics &diag);
75  bool isAdditionalTypeInfoUsed() const;
76  bool supportsNestedFields() const;
77 
78  static typename std::string fieldIdFromString(const char *idString, std::size_t idStringSize = std::string::npos);
79  static std::string fieldIdToString(const std::string &id);
80 
81 private:
82  void reset();
83 };
84 
89 {
90  return false;
91 }
92 
97 {
98  return true;
99 }
100 
105 inline std::string MatroskaTagField::fieldIdFromString(const char *idString, std::size_t idStringSize)
106 {
107  return idStringSize != std::string::npos ? std::string(idString, idStringSize) : std::string(idString);
108 }
109 
114 inline std::string MatroskaTagField::fieldIdToString(const std::string &id)
115 {
116  return id;
117 }
118 
122 inline void MatroskaTagField::reset()
123 {
124 }
125 
126 } // namespace TagParser
127 
128 #endif // TAG_PARSER_MATROSKATAGFIELD_H
uint64 requiredSize() const
Returns number of bytes which will be written when making the field.
Defines traits for the specified ImplementationType.
The EbmlElement class helps to parse EBML files such as Matroska files.
Definition: ebmlelement.h:31
bool isAdditionalTypeInfoUsed() const
Returns whether the additional type info is used.
The MatroskaTagField class is used by MatroskaTag to store the fields.
bool supportsNestedFields() const
Returns whether nested fields are supported.
const MatroskaTagField & field() const
Returns the associated field.
static std::string fieldIdFromString(const char *idString, std::size_t idStringSize=std::string::npos)
Converts the specified ID string representation to an actual ID.
The MatroskaTagFieldMaker class helps making tag fields.
The TagField class is used by FieldMapBasedTag to store the fields.
const IdentifierType & id() const
Returns the id of the current TagField.
The TagValue class wraps values of different types.
Definition: tagvalue.h:65
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:156
static std::string fieldIdToString(const std::string &id)
Returns the string representation for the specified id.