Tag Parser  6.1.1
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
generictagfield.h
Go to the documentation of this file.
1 #ifndef TAGFIELD_H
2 #define TAGFIELD_H
3 
4 #include "./tagvalue.h"
5 
6 namespace Media {
7 
8 template <class implementationType>
9 class TagField;
10 
17 template<typename ImplementationType>
19 {};
20 
31 template <class ImplementationType>
32 class TAG_PARSER_EXPORT TagField
33 {
34 public:
35  friend class TagFieldTraits<ImplementationType>;
39 
40  TagField();
41  TagField(const identifierType &id, const TagValue &value);
42  ~TagField();
43 
44  const identifierType &id() const;
45  void setId(const identifierType &id);
46  void clearId();
47 
48  TagValue &value();
49  const TagValue &value() const;
50  void setValue(const TagValue &value);
51  void clearValue();
52 
53  const typeInfoType &typeInfo() const;
54  void setTypeInfo(const typeInfoType &typeInfo);
55  void removeTypeInfo();
56  bool isTypeInfoAssigned() const;
57 
58  bool isDefault() const;
59  void setDefault(bool isDefault);
60 
61  void clear();
62 
63  bool isAdditionalTypeInfoUsed() const;
64 
65  const std::vector<ImplementationType> &nestedFields() const;
66  std::vector<ImplementationType> &nestedFields();
67  bool supportsNestedFields() const;
68 
69 private:
70  void cleared();
71 
72 private:
73  identifierType m_id;
74  TagValue m_value;
75  typeInfoType m_typeInfo;
76  bool m_typeInfoAssigned;
77  bool m_default;
78  std::vector<ImplementationType> m_nestedFields;
79 };
80 
84 template <class ImplementationType>
86  m_id(identifierType()),
87  m_value(TagValue()),
88  m_typeInfo(typeInfoType()),
89  m_typeInfoAssigned(false),
90  m_default(false)
91 {}
92 
96 template <class ImplementationType>
98  m_id(id),
99  m_value(value),
100  m_typeInfo(typeInfoType()),
101  m_typeInfoAssigned(false),
102  m_default(false)
103 {}
104 
108 template <class ImplementationType>
110 {}
111 
115 template <class ImplementationType>
117 {
118  return m_id;
119 }
120 
124 template <class ImplementationType>
126 {
127  m_id = id;
128 }
129 
133 template <class ImplementationType>
135 {
136  m_id = identifierType();
137 }
138 
142 template <class ImplementationType>
144 {
145  return m_value;
146 }
147 
151 template <class ImplementationType>
153 {
154  return m_value;
155 }
156 
160 template <class ImplementationType>
162 {
163  m_value = value;
164 }
165 
169 template <class ImplementationType>
171 {
172  m_value.clearDataAndMetadata();
173 }
174 
178 template <class ImplementationType>
180 {
181  return m_typeInfo;
182 }
183 
187 template <class ImplementationType>
189 {
190  m_typeInfo = typeInfo;
191  m_typeInfoAssigned = true;
192 }
193 
197 template <class ImplementationType>
199 {
200  m_typeInfo = typeInfoType();
201  m_typeInfoAssigned = false;
202 }
203 
207 template <class ImplementationType>
209 {
210  return m_typeInfoAssigned;
211 }
212 
216 template <class ImplementationType>
218 {
219  return m_default;
220 }
221 
225 template <class ImplementationType>
226 inline void TagField<ImplementationType>::setDefault(bool isDefault)
227 {
228  m_default = isDefault;
229 }
230 
234 template <class ImplementationType>
236 {
237  clearId();
238  clearValue();
239  m_typeInfo = typeInfoType();
240  m_typeInfoAssigned = false;
241  m_default = true;
242  static_cast<ImplementationType *>(this)->cleared();
243 }
244 
251 template <class ImplementationType>
253 {
254  return static_cast<ImplementationType *>(this)->isAdditionalTypeInfoUsed();
255 }
256 
260 template <class ImplementationType>
261 const std::vector<ImplementationType> &TagField<ImplementationType>::nestedFields() const
262 {
263  return m_nestedFields;
264 }
265 
271 template <class ImplementationType>
272 inline std::vector<ImplementationType> &TagField<ImplementationType>::nestedFields()
273 {
274  return m_nestedFields;
275 }
276 
280 template <class ImplementationType>
282 {
283  return static_cast<ImplementationType *>(this)->supportsNestedFields();
284 }
285 
289 template <class ImplementationType>
291 {}
292 
293 }
294 
295 #endif // TAGFIELD_H
The TagValue class wraps values of different types.
Definition: tagvalue.h:64
TagFieldTraits< ImplementationType >::identifierType identifierType
Defines traits for the specified ImplementationType.
TagField()
Constructs an empty TagField.
TagFieldTraits< ImplementationType >::typeInfoType typeInfoType
The TagField class is used by FieldMapBasedTag to store the fields.
TagFieldTraits< ImplementationType >::implementationType implementationType
Contains all classes and functions of the TagInfo library.
Definition: exceptions.h:9
#define TAG_PARSER_EXPORT
Marks the symbol to be exported by the tagparser library.