Tag Parser: generictagfield.h Source File

Tag Parser 12.5.3 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
16 template <typename ImplementationType> class TagFieldTraits {};
17
29 template <class ImplementationType> class TAG_PARSER_EXPORT TagField {
30 friend class TagFieldTraits<ImplementationType>;
31
32public:
33 using IdentifierType = typename TagFieldTraits<ImplementationType>::IdentifierType;
34 using TypeInfoType = typename TagFieldTraits<ImplementationType>::TypeInfoType;
35
36 TagField();
37 TagField(const IdentifierType &id, const TagValue &value);
38 ~TagField();
39
40 IdentifierType &id();
41 const IdentifierType &id() const;
42 std::string idToString() const;
43 void setId(const IdentifierType &id);
44 void clearId();
45
46 TagValue &value();
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);
53 void removeTypeInfo();
54 bool isTypeInfoAssigned() const;
55
56 bool isDefault() const;
57 void setDefault(bool isDefault);
58
59 void clear();
60
61 bool isAdditionalTypeInfoUsed() const;
62
63 const std::vector<ImplementationType> &nestedFields() const;
64 std::vector<ImplementationType> &nestedFields();
65 bool supportsNestedFields() const;
66
67protected:
68 void internallyClearValue();
69 void internallyClearFurtherData();
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>
84TagField<ImplementationType>::TagField()
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>
97 TagField<ImplementationType>::TagField(const IdentifierType &id, const TagValue &value)
98 : m_id(id)
99 , m_value(value)
100 , m_typeInfo(TypeInfoType())
101 , m_typeInfoAssigned(false)
102 , m_default(false)
103{
104}
105
109 template <class ImplementationType> TagField<ImplementationType>::~TagField()
110{
111}
112
116 template <class ImplementationType> inline typename TagField<ImplementationType>::IdentifierType &TagField<ImplementationType>::id()
117{
118 return m_id;
119}
120
124 template <class ImplementationType> inline const typename TagField<ImplementationType>::IdentifierType &TagField<ImplementationType>::id() const
125{
126 return m_id;
127}
128
132 template <class ImplementationType> inline std::string TagField<ImplementationType>::idToString() const
133{
134 return ImplementationType::fieldIdToString(m_id);
135}
136
140 template <class ImplementationType> inline void TagField<ImplementationType>::setId(const IdentifierType &id)
141{
142 m_id = id;
143}
144
148 template <class ImplementationType> inline void TagField<ImplementationType>::clearId()
149{
150 m_id = IdentifierType();
151}
152
156 template <class ImplementationType> inline TagValue &TagField<ImplementationType>::value()
157{
158 return m_value;
159}
160
164 template <class ImplementationType> inline const TagValue &TagField<ImplementationType>::value() const
165{
166 return m_value;
167}
168
172 template <class ImplementationType> inline void TagField<ImplementationType>::setValue(const TagValue &value)
173{
174 m_value = value;
175}
176
180 template <class ImplementationType> inline void TagField<ImplementationType>::clearValue()
181{
182 static_cast<ImplementationType *>(this)->internallyClearValue();
183}
184
188 template <class ImplementationType> inline const typename TagField<ImplementationType>::TypeInfoType &TagField<ImplementationType>::typeInfo() const
189{
190 return m_typeInfo;
191}
192
196 template <class ImplementationType> inline void TagField<ImplementationType>::setTypeInfo(const TypeInfoType &typeInfo)
197{
198 m_typeInfo = typeInfo;
199 m_typeInfoAssigned = true;
200}
201
205 template <class ImplementationType> inline void TagField<ImplementationType>::removeTypeInfo()
206{
207 m_typeInfo = TypeInfoType();
208 m_typeInfoAssigned = false;
209}
210
214 template <class ImplementationType> inline bool TagField<ImplementationType>::isTypeInfoAssigned() const
215{
216 return m_typeInfoAssigned;
217}
218
222 template <class ImplementationType> inline bool TagField<ImplementationType>::isDefault() const
223{
224 return m_default;
225}
226
230 template <class ImplementationType> inline void TagField<ImplementationType>::setDefault(bool isDefault)
231{
232 m_default = isDefault;
233}
234
238 template <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
254 template <class ImplementationType> inline bool TagField<ImplementationType>::isAdditionalTypeInfoUsed() const
255{
256 return static_cast<ImplementationType *>(this)->isAdditionalTypeInfoUsed();
257}
258
262 template <class ImplementationType> const std::vector<ImplementationType> &TagField<ImplementationType>::nestedFields() const
263{
264 return m_nestedFields;
265}
266
272 template <class ImplementationType> inline std::vector<ImplementationType> &TagField<ImplementationType>::nestedFields()
273{
274 return m_nestedFields;
275}
276
280 template <class ImplementationType> inline bool TagField<ImplementationType>::supportsNestedFields() const
281{
282 return static_cast<ImplementationType *>(this)->supportsNestedFields();
283}
284
289 template <class ImplementationType> void TagField<ImplementationType>::internallyClearValue()
290{
291 m_value.clearDataAndMetadata();
292}
293
298 template <class ImplementationType> void TagField<ImplementationType>::internallyClearFurtherData()
299{
300}
301
302} // namespace TagParser
303
304#endif // TAG_PARSER_TAGFIELD_H
TagParser::TagFieldTraits
Defines traits for the specified ImplementationType.
Definition generictagfield.h:16
TagParser::TagField
The TagField class is used by FieldMapBasedTag to store the fields.
Definition generictagfield.h:29
TagParser::TagField::clearId
void clearId()
Clears the id of the current TagField.
Definition generictagfield.h:148
TagParser::TagField::TagField
TagField()
Constructs an empty TagField.
Definition generictagfield.h:84
TagParser::TagField::~TagField
~TagField()
Destroys the TagField.
Definition generictagfield.h:109
TagParser::TagField::internallyClearValue
void internallyClearValue()
Clears the assigned value; called via clearValue() and clear().
Definition generictagfield.h:289
TagParser::TagField::supportsNestedFields
bool supportsNestedFields() const
Returns whether nested fields are supported by the implementation.
Definition generictagfield.h:280
TagParser::TagField::setTypeInfo
void setTypeInfo(const TypeInfoType &typeInfo)
Sets the type info of the current TagField.
Definition generictagfield.h:196
TagParser::TagField::IdentifierType
typename TagFieldTraits< ImplementationType >::IdentifierType IdentifierType
Definition generictagfield.h:33
TagParser::TagField::typeInfo
const TypeInfoType & typeInfo() const
Returns the type info of the current TagField.
Definition generictagfield.h:188
TagParser::TagField::clear
void clear()
Clears id, value, type info, sets default flag to false and resets further implementation specific va...
Definition generictagfield.h:238
TagParser::TagField::setDefault
void setDefault(bool isDefault)
Sets whether the field is labeled as default.
Definition generictagfield.h:230
TagParser::TagField::id
IdentifierType & id()
Returns the id of the current TagField.
Definition generictagfield.h:116
TagParser::TagField::isTypeInfoAssigned
bool isTypeInfoAssigned() const
Returns an indication whether a type info is assigned.
Definition generictagfield.h:214
TagParser::TagField::internallyClearFurtherData
void internallyClearFurtherData()
Clears further data; called via clear().
Definition generictagfield.h:298
TagParser::TagField::nestedFields
const std::vector< ImplementationType > & nestedFields() const
Returns the nested fields.
Definition generictagfield.h:262
TagParser::TagField::setValue
void setValue(const TagValue &value)
Sets the value of the current TagField.
Definition generictagfield.h:172
TagParser::TagField::removeTypeInfo
void removeTypeInfo()
Removes the type info from the current TagField.
Definition generictagfield.h:205
TagParser::TagField::setId
void setId(const IdentifierType &id)
Sets the id of the current Tag Field.
Definition generictagfield.h:140
TagParser::TagField::isDefault
bool isDefault() const
Returns an indication whether the field is labeled as default.
Definition generictagfield.h:222
TagParser::TagField::idToString
std::string idToString() const
Returns the id of the current TagField as string.
Definition generictagfield.h:132
TagParser::TagField::isAdditionalTypeInfoUsed
bool isAdditionalTypeInfoUsed() const
Returns an indication whether the additional type info is used.
Definition generictagfield.h:254
TagParser::TagField::TypeInfoType
typename TagFieldTraits< ImplementationType >::TypeInfoType TypeInfoType
Definition generictagfield.h:34
TagParser::TagField::clearValue
void clearValue()
Clears the value of the current TagField.
Definition generictagfield.h:180
TagParser::TagField< Id3v2Frame >::value
TagValue & value()
Definition generictagfield.h:156
TagParser::TagValue
The TagValue class wraps values of different types.
Definition tagvalue.h:147
TAG_PARSER_EXPORT
#define TAG_PARSER_EXPORT
Marks the symbol to be exported by the tagparser library.
Definition global.h:14
TagParser
Contains all classes and functions of the TagInfo library.
Definition aaccodebook.h:10
tagvalue.h