Tag Parser  6.2.2
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 MEDIA_MATROSKATAGFIELD_H
2 #define MEDIA_MATROSKATAGFIELD_H
3 
4 #include "../generictagfield.h"
5 #include "../statusprovider.h"
6 
7 namespace Media {
8 
9 class EbmlElement;
10 class MatroskaTagField;
11 
15 template <>
17 {
18 public:
22  typedef std::string identifierType;
23 
27  typedef std::string typeInfoType;
28 
33 
34  static bool supportsNestedFields();
35 };
36 
41 {
42  return true;
43 }
44 
46 {
47  friend class MatroskaTagField;
48 
49 public:
50  void make(std::ostream &stream) const;
51  const MatroskaTagField &field() const;
52  uint64 requiredSize() const;
53 
54 private:
56 
57  MatroskaTagField &m_field;
58  bool m_isBinary;
59  std::string m_stringValue;
60  uint64 m_simpleTagSize;
61  uint64 m_totalSize;
62  std::vector<MatroskaTagFieldMaker> m_nestedMaker;
63 };
64 
69 {
70  return m_field;
71 }
72 
77 {
78  return m_totalSize;
79 }
80 
81 
82 
83 class TAG_PARSER_EXPORT MatroskaTagField : public TagField<MatroskaTagField>, public StatusProvider
84 {
85  friend class TagField<MatroskaTagField>;
86 
87 public:
89  MatroskaTagField(const std::string &id, const TagValue &value);
90 
91  void reparse(EbmlElement &simpleTagElement, bool parseNestedFields = true);
92  MatroskaTagFieldMaker prepareMaking();
93  void make(std::ostream &stream);
94  bool isAdditionalTypeInfoUsed() const;
95  bool supportsNestedFields() const;
96 
97  static typename std::string fieldIdFromString(const char *idString, std::size_t idStringSize = std::string::npos);
98  static std::string fieldIdToString(const std::string &id);
99 
100 protected:
101  void cleared();
102 };
103 
108 {
109  return false;
110 }
111 
116 {
117  return true;
118 }
119 
124 inline std::string MatroskaTagField::fieldIdFromString(const char *idString, std::size_t idStringSize)
125 {
126  return idStringSize != std::string::npos ? std::string(idString, idStringSize) : std::string(idString);
127 }
128 
133 inline std::string MatroskaTagField::fieldIdToString(const std::string &id)
134 {
135  return id;
136 }
137 
142 {}
143 
144 }
145 
146 #endif // MEDIA_MATROSKATAGFIELD_H
The MatroskaTagFieldMaker class helps making tag fields.
The TagValue class wraps values of different types.
Definition: tagvalue.h:63
The EbmlElement class helps to parse EBML files such as Matroska files.
Definition: ebmlelement.h:50
bool supportsNestedFields() const
Returns whether nested fields are supported.
Defines traits for the specified ImplementationType.
bool isAdditionalTypeInfoUsed() const
Returns whether the additional type info is used.
MatroskaTagField implementationType
The implementation type is EbmlElement.
const MatroskaTagField & field() const
Returns the associated field.
The TagField class is used by FieldMapBasedTag to store the fields.
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 MatroskaTagField class is used by MatroskaTag to store the fields.
uint64 requiredSize() const
Returns number of bytes which will be written when making the field.
std::string typeInfoType
The type info is stored using strings.
std::string identifierType
Fields in a Matroska tag are identified by strings.
void cleared()
Ensures the field is cleared.
Contains all classes and functions of the TagInfo library.
Definition: exceptions.h:9
The StatusProvider class acts as a base class for objects providing status information.
static std::string fieldIdToString(const std::string &id)
Returns the string representation for the specified id.
#define TAG_PARSER_EXPORT
Marks the symbol to be exported by the tagparser library.