Tag Parser  6.4.0
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  std::string idToString() const;
46  void setId(const identifierType &id);
47  void clearId();
48 
49  TagValue &value();
50  const TagValue &value() const;
51  void setValue(const TagValue &value);
52  void clearValue();
53 
54  const typeInfoType &typeInfo() const;
55  void setTypeInfo(const typeInfoType &typeInfo);
56  void removeTypeInfo();
57  bool isTypeInfoAssigned() const;
58 
59  bool isDefault() const;
60  void setDefault(bool isDefault);
61 
62  void clear();
63 
64  bool isAdditionalTypeInfoUsed() const;
65 
66  const std::vector<ImplementationType> &nestedFields() const;
67  std::vector<ImplementationType> &nestedFields();
68  bool supportsNestedFields() const;
69 
70 private:
71  void cleared();
72 
73 private:
74  identifierType m_id;
75  TagValue m_value;
76  typeInfoType m_typeInfo;
77  bool m_typeInfoAssigned;
78  bool m_default;
79  std::vector<ImplementationType> m_nestedFields;
80 };
81 
85 template <class ImplementationType>
87  m_id(identifierType()),
88  m_value(TagValue()),
89  m_typeInfo(typeInfoType()),
90  m_typeInfoAssigned(false),
91  m_default(false)
92 {}
93 
97 template <class ImplementationType>
99  m_id(id),
100  m_value(value),
101  m_typeInfo(typeInfoType()),
102  m_typeInfoAssigned(false),
103  m_default(false)
104 {}
105 
109 template <class ImplementationType>
111 {}
112 
116 template <class ImplementationType>
118 {
119  return m_id;
120 }
121 
122 template<class ImplementationType>
124 {
125  return ImplementationType::fieldIdToString(m_id);
126 }
127 
131 template <class ImplementationType>
133 {
134  m_id = id;
135 }
136 
140 template <class ImplementationType>
142 {
143  m_id = identifierType();
144 }
145 
149 template <class ImplementationType>
151 {
152  return m_value;
153 }
154 
158 template <class ImplementationType>
160 {
161  return m_value;
162 }
163 
167 template <class ImplementationType>
169 {
170  m_value = value;
171 }
172 
176 template <class ImplementationType>
178 {
179  m_value.clearDataAndMetadata();
180 }
181 
185 template <class ImplementationType>
187 {
188  return m_typeInfo;
189 }
190 
194 template <class ImplementationType>
196 {
197  m_typeInfo = typeInfo;
198  m_typeInfoAssigned = true;
199 }
200 
204 template <class ImplementationType>
206 {
207  m_typeInfo = typeInfoType();
208  m_typeInfoAssigned = false;
209 }
210 
214 template <class ImplementationType>
216 {
217  return m_typeInfoAssigned;
218 }
219 
223 template <class ImplementationType>
225 {
226  return m_default;
227 }
228 
232 template <class ImplementationType>
233 inline void TagField<ImplementationType>::setDefault(bool isDefault)
234 {
235  m_default = isDefault;
236 }
237 
241 template <class ImplementationType>
243 {
244  clearId();
245  clearValue();
246  m_typeInfo = typeInfoType();
247  m_typeInfoAssigned = false;
248  m_default = true;
249  static_cast<ImplementationType *>(this)->cleared();
250 }
251 
258 template <class ImplementationType>
260 {
261  return static_cast<ImplementationType *>(this)->isAdditionalTypeInfoUsed();
262 }
263 
267 template <class ImplementationType>
268 const std::vector<ImplementationType> &TagField<ImplementationType>::nestedFields() const
269 {
270  return m_nestedFields;
271 }
272 
278 template <class ImplementationType>
279 inline std::vector<ImplementationType> &TagField<ImplementationType>::nestedFields()
280 {
281  return m_nestedFields;
282 }
283 
287 template <class ImplementationType>
289 {
290  return static_cast<ImplementationType *>(this)->supportsNestedFields();
291 }
292 
296 template <class ImplementationType>
298 {}
299 
300 }
301 
302 #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.