2
* Copyright (C) 2003-2013 The Music Player Daemon Project
3
* http://www.musicpd.org
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License along
16
* with this program; if not, write to the Free Software Foundation, Inc.,
17
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20
#ifndef MPD_TAG_BUILDER_HXX
21
#define MPD_TAG_BUILDER_HXX
34
* A class that constructs #Tag objects.
38
* The duration of the song (in seconds). A value of zero
39
* means that the length is unknown. If the duration is
40
* really between zero and one second, you should round up to
46
* Does this file have an embedded playlist (e.g. embedded CUE
51
/** an array of tag items */
52
std::vector<TagItem *> items;
56
* Create an empty tag.
59
:time(-1), has_playlist(false) {}
65
TagBuilder(const TagBuilder &other) = delete;
66
TagBuilder &operator=(const TagBuilder &other) = delete;
69
* Returns true if the tag contains no items. This ignores the "time"
72
bool IsEmpty() const {
77
* Returns true if the object contains any information.
80
bool IsDefined() const {
81
return time >= 0 || has_playlist || !IsEmpty();
87
* Move this object to the given #Tag instance. This object
88
* is empty afterwards.
90
void Commit(Tag &tag);
93
* Create a new #Tag instance from data in this object. The
94
* returned object is owned by the caller. This object is
99
void SetTime(int _time) {
103
void SetHasPlaylist(bool _has_playlist) {
104
has_playlist = _has_playlist;
107
void Reserve(unsigned n) {
112
* Appends a new tag item.
114
* @param type the type of the new tag item
115
* @param value the value of the tag item (not null-terminated)
116
* @param len the length of #value
119
void AddItem(TagType type, const char *value, size_t length);
122
* Appends a new tag item.
124
* @param type the type of the new tag item
125
* @param value the value of the tag item (null-terminated)
128
void AddItem(TagType type, const char *value);
132
void AddItemInternal(TagType type, const char *value, size_t length);