Tag Parser  10.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  std::uint64_t requiredSize() const;
37 
38 private:
40 
41  MatroskaTagField &m_field;
42  std::string m_stringValue;
43  const std::string &m_language;
44  const std::string &m_languageIETF;
45  std::uint64_t m_simpleTagSize;
46  std::uint64_t m_totalSize;
47  std::vector<MatroskaTagFieldMaker> m_nestedMaker;
48  bool m_isBinary;
49 };
50 
55 {
56  return m_field;
57 }
58 
62 inline std::uint64_t MatroskaTagFieldMaker::requiredSize() const
63 {
64  return m_totalSize;
65 }
66 
67 class TAG_PARSER_EXPORT MatroskaTagField : public TagField<MatroskaTagField> {
68  friend class TagField<MatroskaTagField>;
69 
70 public:
72  MatroskaTagField(const std::string &id, const TagValue &value);
73 
74  void reparse(EbmlElement &simpleTagElement, Diagnostics &diag, bool parseNestedFields = true);
75  MatroskaTagFieldMaker prepareMaking(Diagnostics &diag);
76  void make(std::ostream &stream, Diagnostics &diag);
77  bool isAdditionalTypeInfoUsed() const;
78  bool supportsNestedFields() const;
79 
80  static typename std::string fieldIdFromString(std::string_view idString);
81  static std::string fieldIdToString(const std::string &id);
82 };
83 
88 {
89  return false;
90 }
91 
96 {
97  return true;
98 }
99 
104 inline std::string MatroskaTagField::fieldIdFromString(std::string_view idString)
105 {
106  return std::string(idString);
107 }
108 
113 inline std::string MatroskaTagField::fieldIdToString(const std::string &id)
114 {
115  return id;
116 }
117 
118 } // namespace TagParser
119 
120 #endif // TAG_PARSER_MATROSKATAGFIELD_H
The Diagnostics class is a container for DiagMessage.
Definition: diagnostics.h:156
The EbmlElement class helps to parse EBML files such as Matroska files.
Definition: ebmlelement.h:32
The MatroskaTagFieldMaker class helps making tag fields.
const MatroskaTagField & field() const
Returns the associated field.
std::uint64_t requiredSize() const
Returns number of bytes which will be written when making the field.
The MatroskaTagField class is used by MatroskaTag to store the fields.
static std::string fieldIdToString(const std::string &id)
Returns the string representation for the specified id.
static std::string fieldIdFromString(std::string_view idString)
Converts the specified ID string representation to an actual ID.
bool supportsNestedFields() const
Returns whether nested fields are supported.
bool isAdditionalTypeInfoUsed() const
Returns whether the additional type info is used.
Defines traits for the specified ImplementationType.
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:95
#define TAG_PARSER_EXPORT
Marks the symbol to be exported by the tagparser library.
Contains all classes and functions of the TagInfo library.
Definition: aaccodebook.h:10