Tag Parser 12.3.1
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
Loading...
Searching...
No Matches
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
29template <class ImplementationType> class TAG_PARSER_EXPORT TagField {
30 friend class TagFieldTraits<ImplementationType>;
31
32public:
35
37 TagField(const IdentifierType &id, const TagValue &value);
39
41 const IdentifierType &id() const;
42 std::string idToString() const;
43 void setId(const IdentifierType &id);
44 void clearId();
45
47 const TagValue &value() const;
48 void setValue(const TagValue &value);
49 void clearValue();
50
51 const TypeInfoType &typeInfo() const;
52 void setTypeInfo(const TypeInfoType &typeInfo);
54 bool isTypeInfoAssigned() const;
55
56 bool isDefault() const;
57 void setDefault(bool isDefault);
58
59 void clear();
60
62
63 const std::vector<ImplementationType> &nestedFields() const;
64 std::vector<ImplementationType> &nestedFields();
66
67protected:
70
71private:
72 IdentifierType m_id;
73 TagValue m_value;
74 TypeInfoType m_typeInfo;
75 bool m_typeInfoAssigned;
76 bool m_default;
77 std::vector<ImplementationType> m_nestedFields;
78};
79
83template <class ImplementationType>
85 : m_id(IdentifierType())
86 , m_value(TagValue())
87 , m_typeInfo(TypeInfoType())
88 , m_typeInfoAssigned(false)
89 , m_default(false)
90{
91}
92
96template <class ImplementationType>
98 : m_id(id)
99 , m_value(value)
100 , m_typeInfo(TypeInfoType())
101 , m_typeInfoAssigned(false)
102 , m_default(false)
103{
104}
105
109template <class ImplementationType> TagField<ImplementationType>::~TagField()
110{
111}
112
116template <class ImplementationType> inline typename TagField<ImplementationType>::IdentifierType &TagField<ImplementationType>::id()
117{
118 return m_id;
119}
120
124template <class ImplementationType> inline const typename TagField<ImplementationType>::IdentifierType &TagField<ImplementationType>::id() const
125{
126 return m_id;
127}
128
132template <class ImplementationType> inline std::string TagField<ImplementationType>::idToString() const
133{
134 return ImplementationType::fieldIdToString(m_id);
135}
136
140template <class ImplementationType> inline void TagField<ImplementationType>::setId(const IdentifierType &id)
141{
142 m_id = id;
143}
144
148template <class ImplementationType> inline void TagField<ImplementationType>::clearId()
149{
150 m_id = IdentifierType();
151}
152
156template <class ImplementationType> inline TagValue &TagField<ImplementationType>::value()
157{
158 return m_value;
159}
160
164template <class ImplementationType> inline const TagValue &TagField<ImplementationType>::value() const
165{
166 return m_value;
167}
168
172template <class ImplementationType> inline void TagField<ImplementationType>::setValue(const TagValue &value)
173{
174 m_value = value;
175}
176
180template <class ImplementationType> inline void TagField<ImplementationType>::clearValue()
181{
182 static_cast<ImplementationType *>(this)->internallyClearValue();
183}
184
188template <class ImplementationType> inline const typename TagField<ImplementationType>::TypeInfoType &TagField<ImplementationType>::typeInfo() const
189{
190 return m_typeInfo;
191}
192
196template <class ImplementationType> inline void TagField<ImplementationType>::setTypeInfo(const TypeInfoType &typeInfo)
197{
198 m_typeInfo = typeInfo;
199 m_typeInfoAssigned = true;
200}
201
205template <class ImplementationType> inline void TagField<ImplementationType>::removeTypeInfo()
206{
207 m_typeInfo = TypeInfoType();
208 m_typeInfoAssigned = false;
209}
210
214template <class ImplementationType> inline bool TagField<ImplementationType>::isTypeInfoAssigned() const
215{
216 return m_typeInfoAssigned;
217}
218
222template <class ImplementationType> inline bool TagField<ImplementationType>::isDefault() const
223{
224 return m_default;
225}
226
230template <class ImplementationType> inline void TagField<ImplementationType>::setDefault(bool isDefault)
231{
232 m_default = isDefault;
233}
234
238template <class ImplementationType> void TagField<ImplementationType>::clear()
239{
240 clearId();
241 clearValue();
242 static_cast<ImplementationType *>(this)->internallyClearFurtherData();
243 m_typeInfo = TypeInfoType();
244 m_typeInfoAssigned = false;
245 m_default = true;
246}
247
254template <class ImplementationType> inline bool TagField<ImplementationType>::isAdditionalTypeInfoUsed() const
255{
256 return static_cast<ImplementationType *>(this)->isAdditionalTypeInfoUsed();
257}
258
262template <class ImplementationType> const std::vector<ImplementationType> &TagField<ImplementationType>::nestedFields() const
263{
264 return m_nestedFields;
265}
266
272template <class ImplementationType> inline std::vector<ImplementationType> &TagField<ImplementationType>::nestedFields()
273{
274 return m_nestedFields;
275}
276
280template <class ImplementationType> inline bool TagField<ImplementationType>::supportsNestedFields() const
281{
282 return static_cast<ImplementationType *>(this)->supportsNestedFields();
283}
284
289template <class ImplementationType> void TagField<ImplementationType>::internallyClearValue()
290{
291 m_value.clearDataAndMetadata();
292}
293
298template <class ImplementationType> void TagField<ImplementationType>::internallyClearFurtherData()
299{
300}
301
302} // namespace TagParser
303
304#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.
#define TAG_PARSER_EXPORT
Marks the symbol to be exported by the tagparser library.
Definition global.h:14
Contains all classes and functions of the TagInfo library.
Definition aaccodebook.h:10