Tag Parser
6.3.0
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
tag.cpp
Go to the documentation of this file.
1
#include "
./tag.h
"
2
3
using namespace
std
;
4
5
namespace
Media
{
6
21
Tag::Tag
() :
22
m_size(0)
23
{}
24
28
Tag::~Tag
()
29
{}
30
34
string
Tag::toString
()
const
35
{
36
string
res;
37
res +=
typeName
();
38
if
(
supportsTarget
()) {
39
res +=
" targeting "
;
40
res +=
targetString
();
41
}
42
return
res;
43
}
44
53
std::vector<const TagValue *>
Tag::values
(
KnownField
field)
const
54
{
55
std::vector<const TagValue *>
values
;
56
const
TagValue
&v =
value
(field);
57
if
(!v.
isEmpty
()) {
58
values.push_back(&v);
59
}
60
return
values
;
61
}
62
71
bool
Tag::setValues
(
KnownField
field,
const
std::vector<TagValue> &
values
)
72
{
73
return
setValue
(field, values.size() ? *values.begin() :
TagValue
());
74
}
75
127
unsigned
int
Tag::insertValues
(
const
Tag
&from,
bool
overwrite)
128
{
129
unsigned
int
count = 0;
130
for
(
int
i = static_cast<int>(
KnownField::Invalid
) + 1, last = static_cast<int>(
KnownField::Description
);
131
i <= last; ++i) {
132
KnownField
field =
static_cast<
KnownField
>
(i);
133
const
TagValue
&ownValue =
value
(field);
134
if
(overwrite || ownValue.
isEmpty
()) {
135
const
TagValue
&otherValue = from.
value
(field);
136
if
(!otherValue.
isEmpty
() &&
setValue
(field, otherValue)) {
137
++count;
138
}
139
}
140
}
141
return
count;
142
}
143
150
//bool Tag::setParent(Tag *tag)
151
//{
152
// if(m_parent != tag) {
153
// // ensure this tag is a valid parent for the specified tag
154
// if(!tag->supportsChild(this)) {
155
// return false;
156
// }
157
// // ensure the new parent is no child of this tag
158
// Tag *newParent = tag->parent();
159
// while(newParent) {
160
// if(newParent == this) {
161
// return false;
162
// }
163
// newParent = newParent->parent();
164
// }
165
// // remove this tag from the nested tags of the old parent
166
// if(m_parent) {
167
// m_parent->m_nestedTags.erase(std::remove(m_nestedTags.begin(), m_nestedTags.end(), this));
168
// }
169
// // add this tag to the nested tags of the new parent
170
// if((m_parent = tag)) {
171
// m_parent->m_nestedTags.push_back(this);
172
// }
173
// }
174
// return true;
175
//}
176
177
}
Media::Tag::targetString
std::string targetString() const
Returns the string representation for the assigned tag target.
Definition:
tag.h:295
tag.h
Media::TagValue
The TagValue class wraps values of different types.
Definition:
tagvalue.h:63
Media::Tag::setValues
virtual bool setValues(KnownField field, const std::vector< TagValue > &values)
Assigns the given values to the specified field.
Definition:
tag.cpp:71
Media::TagValue::isEmpty
bool isEmpty() const
Returns an indication whether an value is assigned.
Definition:
tagvalue.h:340
Media::KnownField::Description
Media::KnownField
KnownField
Specifies the field.
Definition:
tag.h:42
std
STL namespace.
Media::KnownField::Invalid
Media::Tag::insertValues
virtual unsigned int insertValues(const Tag &from, bool overwrite)
Inserts all compatible values from another Tag.
Definition:
tag.cpp:127
Media::Tag
The Tag class is used to store, read and write tag information.
Definition:
tag.h:98
Media::Tag::supportsTarget
virtual bool supportsTarget() const
Returns an indication whether a target is supported by the tag.
Definition:
tag.h:234
Media::Tag::typeName
virtual const char * typeName() const
Returns the type name of the tag as C-style string.
Definition:
tag.h:165
Media::MatroskaIds::Tag
Definition:
matroskaid.h:236
Media::Tag::values
virtual std::vector< const TagValue * > values(KnownField field) const
Returns the values of the specified field.
Definition:
tag.cpp:53
Media::Tag::~Tag
virtual ~Tag()
Destroys the Tag.
Definition:
tag.cpp:28
Media::Tag::setValue
virtual bool setValue(KnownField field, const TagValue &value)=0
Assigns the given value to the specified field.
Media
Contains all classes and functions of the TagInfo library.
Definition:
exceptions.h:9
Media::Tag::toString
std::string toString() const
Returns a string representation of the tag.
Definition:
tag.cpp:34
Media::Tag::value
virtual const TagValue & value(KnownField field) const =0
Returns the value of the specified field.
Generated on Wed May 31 2017 10:18:00 for Tag Parser by
1.8.13