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.
21
#include "TagBuilder.hxx"
22
#include "TagSettings.h"
23
#include "TagPool.hxx"
24
#include "TagString.hxx"
41
tag_pool_lock.unlock();
47
TagBuilder::Commit(Tag &tag)
52
tag.has_playlist = has_playlist;
54
/* move all TagItem pointers to the new Tag object without
55
touching the TagPool reference counters; the
56
vector::clear() call is important to detach them from this
58
const unsigned n_items = items.size();
59
tag.num_items = n_items;
60
tag.items = g_new(TagItem *, n_items);
61
std::copy_n(items.begin(), n_items, tag.items);
64
/* now ensure that this object is fresh (will not delete any
65
items because we've already moved them out) */
78
TagBuilder::AddItemInternal(TagType type, const char *value, size_t length)
80
assert(value != nullptr);
83
char *p = FixTagString(value, length);
86
length = strlen(value);
90
auto i = tag_pool_get_item(type, value, length);
91
tag_pool_lock.unlock();
99
TagBuilder::AddItem(TagType type, const char *value, size_t length)
101
assert(value != nullptr);
103
if (length == 0 || ignore_tag_items[type])
106
AddItemInternal(type, value, length);
110
TagBuilder::AddItem(TagType type, const char *value)
112
assert(value != nullptr);
114
AddItem(type, value, strlen(value));