Tag Parser
12.5.3
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
Toggle main menu visibility
Loading...
Searching...
No Matches
tag.cpp
Go to the documentation of this file.
1
#include "
./tag.h
"
2
3
using namespace
std;
4
5
namespace
TagParser
{
6
8
struct
TagPrivate
{};
9
20
24
Tag::Tag
()
25
:
m_size
(0)
26
{
27
}
28
32
Tag::~Tag
()
33
{
34
}
35
39
string
Tag::toString
()
const
40
{
41
string
res;
42
res +=
typeName
();
43
if
(
supportsTarget
()) {
44
res +=
" targeting "
;
45
res +=
targetString
();
46
}
47
return
res;
48
}
49
58
std::vector<const TagValue *>
Tag::values
(
KnownField
field)
const
59
{
60
std::vector<const TagValue *>
values
;
61
const
TagValue
&v =
value
(field);
62
if
(!v.
isEmpty
()) {
63
values
.push_back(&v);
64
}
65
return
values
;
66
}
67
76
bool
Tag::setValues
(
KnownField
field,
const
std::vector<TagValue> &
values
)
77
{
78
return
setValue
(field,
values
.size() ?
values
.front() :
TagValue
());
79
}
80
89
std::size_t
Tag::insertValues
(
const
Tag
&from,
bool
overwrite)
90
{
91
auto
count = std::size_t(0);
92
for
(
int
i =
static_cast<
int
>
(
KnownField::Invalid
) + 1, last =
static_cast<
int
>
(
KnownField::Description
); i <= last; ++i) {
93
auto
field =
static_cast<
KnownField
>
(i);
94
const
TagValue
&ownValue =
value
(field);
95
if
(overwrite || ownValue.
isEmpty
()) {
96
const
TagValue
&otherValue = from.
value
(field);
97
if
(!otherValue.
isEmpty
() &&
setValue
(field, otherValue)) {
98
++count;
99
}
100
}
101
}
102
return
count;
103
}
104
112
118
124
136
142
148
155
160
175
191
202
210
221
231
241
248
253
258
277
287
297
317
323
329
330
}
// namespace TagParser
TagParser::TagValue
The TagValue class wraps values of different types.
Definition
tagvalue.h:147
TagParser::TagValue::isEmpty
bool isEmpty() const
Returns whether no or an empty value is assigned.
Definition
tagvalue.h:490
TagParser::Tag::setValue
virtual bool setValue(KnownField field, const TagValue &value)=0
Assigns the given value to the specified field.
TagParser::Tag::m_size
std::uint64_t m_size
Definition
tag.h:217
TagParser::Tag::supportsTarget
virtual bool supportsTarget() const
Returns an indication whether a target is supported by the tag.
Definition
tag.h:252
TagParser::Tag::typeName
virtual std::string_view typeName() const
Returns the type name of the tag.
Definition
tag.h:227
TagParser::Tag::insertValues
virtual std::size_t insertValues(const Tag &from, bool overwrite)
Inserts all compatible values from another Tag.
Definition
tag.cpp:89
TagParser::Tag::toString
std::string toString() const
Returns a string representation of the tag.
Definition
tag.cpp:39
TagParser::Tag::~Tag
virtual ~Tag()
Destroys the Tag.
Definition
tag.cpp:32
TagParser::Tag::Tag
Tag()
Constructs a new Tag.
Definition
tag.cpp:24
TagParser::Tag::values
virtual std::vector< const TagValue * > values(KnownField field) const
Returns the values of the specified field.
Definition
tag.cpp:58
TagParser::Tag::setValues
virtual bool setValues(KnownField field, const std::vector< TagValue > &values)
Assigns the given values to the specified field.
Definition
tag.cpp:76
TagParser::Tag::value
virtual const TagValue & value(KnownField field) const =0
Returns the value of the specified field.
TagParser::Tag::targetString
std::string targetString() const
Returns the string representation for the assigned tag target.
Definition
tag.h:287
TagParser
Contains all classes and functions of the TagInfo library.
Definition
aaccodebook.h:10
TagParser::KnownField
KnownField
Specifies the field.
Definition
tag.h:37
TagParser::KnownField::Invalid
@ Invalid
Definition
tag.h:38
TagParser::KnownField::Description
@ Description
Definition
tag.h:64
TagParser::TagPrivate
The TagPrivate struct contains private fields of the Tag class.
Definition
tag.cpp:8
tag.h
Generated on
for Tag Parser by
1.18.0