Tag Parser 11.0.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 TAG_PARSER_TAGFIELD_H
2#define TAG_PARSER_TAGFIELD_H
3
4#include "./tagvalue.h"
5
6namespace TagParser {
7
8template <class implementationType> class TagField;
9
16template <typename ImplementationType> class TagFieldTraits {
17};
18
30template <class ImplementationType> class TAG_PARSER_EXPORT TagField {
31 friend class TagFieldTraits<ImplementationType>;
32
33public:
36
38 TagField(const IdentifierType &id, const TagValue &value);
40
42 const IdentifierType &id() const;
43 std::string idToString() const;
44 void setId(const IdentifierType &id);
45 void clearId();
46
48 const TagValue &value() const;
49 void setValue(const TagValue &value);
50 void clearValue();
51
52 const TypeInfoType &typeInfo() const;
53 void setTypeInfo(const TypeInfoType &typeInfo);
55 bool isTypeInfoAssigned() const;
56
57 bool isDefault() const;
58 void setDefault(bool isDefault);
59
60 void clear();
61
63
64 const std::vector<ImplementationType> &nestedFields() const;
65 std::vector<ImplementationType> &nestedFields();
67
68protected:
71
72private:
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
84template <class ImplementationType>
86 : m_id(IdentifierType())
87 , m_value(TagValue())
88 , m_typeInfo(TypeInfoType())
89 , m_typeInfoAssigned(false)
90 , m_default(false)
91{
92}
93
97template <class ImplementationType>
99 : m_id(id)
100 , m_value(value)
101 , m_typeInfo(TypeInfoType())
102 , m_typeInfoAssigned(false)
103 , m_default(false)
104{
105}
106
110template <class ImplementationType> TagField<ImplementationType>::~TagField()
111{
112}
113
117template <class ImplementationType> inline typename TagField<ImplementationType>::IdentifierType &TagField<ImplementationType>::id()
118{
119 return m_id;
120}
121
125template <class ImplementationType> inline const typename TagField<ImplementationType>::IdentifierType &TagField<ImplementationType>::id() const
126{
127 return m_id;
128}
129
133template <class ImplementationType> inline std::string TagField<ImplementationType>::idToString() const
134{
135 return ImplementationType::fieldIdToString(m_id);
136}
137
141template <class ImplementationType> inline void TagField<ImplementationType>::setId(const IdentifierType &id)
142{
143 m_id = id;
144}
145
149template <class ImplementationType> inline void TagField<ImplementationType>::clearId()
150{
151 m_id = IdentifierType();
152}
153
157template <class ImplementationType> inline TagValue &TagField<ImplementationType>::value()
158{
159 return m_value;
160}
161
165template <class ImplementationType> inline const TagValue &TagField<ImplementationType>::value() const
166{
167 return m_value;
168}
169
173template <class ImplementationType> inline void TagField<ImplementationType>::setValue(const TagValue &value)
174{
175 m_value = value;
176}
177
181template <class ImplementationType> inline void TagField<ImplementationType>::clearValue()
182{
183 static_cast<ImplementationType *>(this)->internallyClearValue();
184}
185
189template <class ImplementationType> inline const typename TagField<ImplementationType>::TypeInfoType &TagField<ImplementationType>::typeInfo() const
190{
191 return m_typeInfo;
192}
193
197template <class ImplementationType> inline void TagField<ImplementationType>::setTypeInfo(const TypeInfoType &typeInfo)
198{
199 m_typeInfo = typeInfo;
200 m_typeInfoAssigned = true;
201}
202
206template <class ImplementationType> inline void TagField<ImplementationType>::removeTypeInfo()
207{
208 m_typeInfo = TypeInfoType();
209 m_typeInfoAssigned = false;
210}
211
215template <class ImplementationType> inline bool TagField<ImplementationType>::isTypeInfoAssigned() const
216{
217 return m_typeInfoAssigned;
218}
219
223template <class ImplementationType> inline bool TagField<ImplementationType>::isDefault() const
224{
225 return m_default;
226}
227
231template <class ImplementationType> inline void TagField<ImplementationType>::setDefault(bool isDefault)
232{
233 m_default = isDefault;
234}
235
239template <class ImplementationType> void TagField<ImplementationType>::clear()
240{
241 clearId();
242 clearValue();
243 static_cast<ImplementationType *>(this)->internallyClearFurtherData();
244 m_typeInfo = TypeInfoType();
245 m_typeInfoAssigned = false;
246 m_default = true;
247}
248
255template <class ImplementationType> inline bool TagField<ImplementationType>::isAdditionalTypeInfoUsed() const
256{
257 return static_cast<ImplementationType *>(this)->isAdditionalTypeInfoUsed();
258}
259
263template <class ImplementationType> const std::vector<ImplementationType> &TagField<ImplementationType>::nestedFields() const
264{
265 return m_nestedFields;
266}
267
273template <class ImplementationType> inline std::vector<ImplementationType> &TagField<ImplementationType>::nestedFields()
274{
275 return m_nestedFields;
276}
277
281template <class ImplementationType> inline bool TagField<ImplementationType>::supportsNestedFields() const
282{
283 return static_cast<ImplementationType *>(this)->supportsNestedFields();
284}
285
290template <class ImplementationType> void TagField<ImplementationType>::internallyClearValue()
291{
292 m_value.clearDataAndMetadata();
293}
294
299template <class ImplementationType> void TagField<ImplementationType>::internallyClearFurtherData()
300{
301}
302
303} // namespace TagParser
304
305#endif // TAG_PARSER_TAGFIELD_H
Defines traits for the specified ImplementationType.
The TagField class is used by FieldMapBasedTag to store the fields.
void clearId()
Clears the id of the current TagField.
TagField()
Constructs an empty TagField.
~TagField()
Destroys the TagField.
void internallyClearValue()
Clears the assigned value; called via clearValue() and clear().
bool supportsNestedFields() const
Returns whether nested fields are supported by the implementation.
std::vector< ImplementationType > & nestedFields()
Returns the nested fields.
void setTypeInfo(const TypeInfoType &typeInfo)
Sets the type info of the current TagField.
const TagValue & value() const
Returns the value of the current TagField.
typename TagFieldTraits< ImplementationType >::IdentifierType IdentifierType
const TypeInfoType & typeInfo() const
Returns the type info of the current TagField.
void clear()
Clears id, value, type info, sets default flag to false and resets further implementation specific va...
void setDefault(bool isDefault)
Sets whether the field is labeled as default.
IdentifierType & id()
Returns the id of the current TagField.
const IdentifierType & id() const
Returns the id of the current TagField.
bool isTypeInfoAssigned() const
Returns an indication whether a type info is assigned.
void internallyClearFurtherData()
Clears further data; called via clear().
const std::vector< ImplementationType > & nestedFields() const
Returns the nested fields.
void setValue(const TagValue &value)
Sets the value of the current TagField.
void removeTypeInfo()
Removes the type info from the current TagField.
void setId(const IdentifierType &id)
Sets the id of the current Tag Field.
bool isDefault() const
Returns an indication whether the field is labeled as default.
std::string idToString() const
Returns the id of the current TagField as string.
bool isAdditionalTypeInfoUsed() const
Returns an indication whether the additional type info is used.
typename TagFieldTraits< ImplementationType >::TypeInfoType TypeInfoType
TagField(const IdentifierType &id, const TagValue &value)
Constructs a new TagField with the specified id and value.
void clearValue()
Clears the value of the current TagField.
TagValue & value()
Returns the value 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