1 /**************************************************************************
2 copyright : (C) 2005-2007 by Lukáš Lalinský
3 email : lalinsky@gmail.com
4 **************************************************************************/
6 /***************************************************************************
7 * This library is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU Lesser General Public License version *
9 * 2.1 as published by the Free Software Foundation. *
11 * This library is distributed in the hope that it will be useful, but *
12 * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 * Lesser General Public License for more details. *
16 * You should have received a copy of the GNU Lesser General Public *
17 * License along with this library; if not, write to the Free Software *
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
21 * Alternatively, this file is available under the Mozilla Public *
22 * License Version 1.1. You may obtain a copy of the License at *
23 * http://www.mozilla.org/MPL/ *
24 ***************************************************************************/
34 using namespace TagLib;
36 class ASF::Tag::TagPrivate
44 AttributeListMap attributeListMap;
60 ASF::Tag::title() const
66 ASF::Tag::artist() const
72 ASF::Tag::album() const
74 if(d->attributeListMap.contains("WM/AlbumTitle"))
75 return d->attributeListMap["WM/AlbumTitle"][0].toString();
80 ASF::Tag::copyright() const
86 ASF::Tag::comment() const
92 ASF::Tag::rating() const
98 ASF::Tag::year() const
100 if(d->attributeListMap.contains("WM/Year"))
101 return d->attributeListMap["WM/Year"][0].toString().toInt();
106 ASF::Tag::track() const
108 if(d->attributeListMap.contains("WM/TrackNumber")) {
109 const ASF::Attribute attr = d->attributeListMap["WM/TrackNumber"][0];
110 if(attr.type() == ASF::Attribute::DWordType)
111 return attr.toUInt();
113 return attr.toString().toInt();
115 if(d->attributeListMap.contains("WM/Track"))
116 return d->attributeListMap["WM/Track"][0].toUInt();
121 ASF::Tag::genre() const
123 if(d->attributeListMap.contains("WM/Genre"))
124 return d->attributeListMap["WM/Genre"][0].toString();
129 ASF::Tag::setTitle(const String &value)
135 ASF::Tag::setArtist(const String &value)
141 ASF::Tag::setCopyright(const String &value)
143 d->copyright = value;
147 ASF::Tag::setComment(const String &value)
153 ASF::Tag::setRating(const String &value)
159 ASF::Tag::setAlbum(const String &value)
161 setAttribute("WM/AlbumTitle", value);
165 ASF::Tag::setGenre(const String &value)
167 setAttribute("WM/Genre", value);
171 ASF::Tag::setYear(uint value)
173 setAttribute("WM/Year", String::number(value));
177 ASF::Tag::setTrack(uint value)
179 setAttribute("WM/TrackNumber", String::number(value));
182 ASF::AttributeListMap&
183 ASF::Tag::attributeListMap()
185 return d->attributeListMap;
188 void ASF::Tag::removeItem(const String &key)
190 AttributeListMap::Iterator it = d->attributeListMap.find(key);
191 if(it != d->attributeListMap.end())
192 d->attributeListMap.erase(it);
195 void ASF::Tag::setAttribute(const String &name, const Attribute &attribute)
198 value.append(attribute);
199 d->attributeListMap.insert(name, value);
202 void ASF::Tag::addAttribute(const String &name, const Attribute &attribute)
204 if(d->attributeListMap.contains(name)) {
205 d->attributeListMap[name].append(attribute);
208 setAttribute(name, attribute);
212 bool ASF::Tag::isEmpty() const {
213 return TagLib::Tag::isEmpty() &&
214 copyright().isEmpty() &&
215 rating().isEmpty() &&
216 d->attributeListMap.isEmpty();