Tag Parser  9.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  bool m_isBinary;
43  std::string m_stringValue;
44  std::uint64_t m_simpleTagSize;
45  std::uint64_t m_totalSize;
46  std::vector<MatroskaTagFieldMaker> m_nestedMaker;
47 };
48 
53 {
54  return m_field;
55 }
56 
60 inline std::uint64_t MatroskaTagFieldMaker::requiredSize() const
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
TagParser::TagFieldTraits
Defines traits for the specified ImplementationType.
Definition: generictagfield.h:16
TagParser::MatroskaTagField::fieldIdToString
static std::string fieldIdToString(const std::string &id)
Returns the string representation for the specified id.
Definition: matroskatagfield.h:114
TagParser::TagFieldTraits< MatroskaTagField >::IdentifierType
std::string IdentifierType
Definition: matroskatagfield.h:17
TagParser::MatroskaTagField::isAdditionalTypeInfoUsed
bool isAdditionalTypeInfoUsed() const
Returns whether the additional type info is used.
Definition: matroskatagfield.h:88
TagParser::MatroskaTagFieldMaker
The MatroskaTagFieldMaker class helps making tag fields. It allows to calculate the required size.
Definition: matroskatagfield.h:30
TagParser::Diagnostics
The Diagnostics class is a container for DiagMessage.
Definition: diagnostics.h:156
TagParser
Contains all classes and functions of the TagInfo library.
Definition: aaccodebook.h:10
TagParser::TagField< MatroskaTagField >::id
const IdentifierType & id() const
Returns the id of the current TagField.
Definition: generictagfield.h:115
TagParser::TagField
The TagField class is used by FieldMapBasedTag to store the fields.
Definition: generictagfield.h:8
TagParser::MatroskaTagFieldMaker::requiredSize
std::uint64_t requiredSize() const
Returns number of bytes which will be written when making the field.
Definition: matroskatagfield.h:60
TagParser::MatroskaTagField::supportsNestedFields
bool supportsNestedFields() const
Returns whether nested fields are supported.
Definition: matroskatagfield.h:96
TagParser::EbmlElement
The EbmlElement class helps to parse EBML files such as Matroska files.
Definition: ebmlelement.h:31
TagParser::MatroskaTagField
The MatroskaTagField class is used by MatroskaTag to store the fields.
Definition: matroskatagfield.h:65
TagParser::TagFieldTraits< MatroskaTagField >::TypeInfoType
std::string TypeInfoType
Definition: matroskatagfield.h:18
TagParser::MatroskaTagFieldMaker::field
const MatroskaTagField & field() const
Returns the associated field.
Definition: matroskatagfield.h:52
TagParser::MatroskaTagField::fieldIdFromString
static std::string fieldIdFromString(const char *idString, std::size_t idStringSize=std::string::npos)
Converts the specified ID string representation to an actual ID.
Definition: matroskatagfield.h:105
TagParser::TagValue
The TagValue class wraps values of different types. It is meant to be assigned to a tag field.
Definition: tagvalue.h:75
TAG_PARSER_EXPORT
#define TAG_PARSER_EXPORT
Marks the symbol to be exported by the tagparser library.