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 ***************************************************************************/
32 using namespace TagLib;
34 class ASF::Tag::TagPrivate
42 AttributeListMap attributeListMap;
58 ASF::Tag::title() const
64 ASF::Tag::artist() const
70 ASF::Tag::album() const
72 if(d->attributeListMap.contains("WM/AlbumTitle"))
73 return d->attributeListMap["WM/AlbumTitle"][0].toString();
78 ASF::Tag::copyright() const
84 ASF::Tag::comment() const
90 ASF::Tag::rating() const
96 ASF::Tag::year() const
98 if(d->attributeListMap.contains("WM/Year"))
99 return d->attributeListMap["WM/Year"][0].toString().toInt();
104 ASF::Tag::track() const
106 if(d->attributeListMap.contains("WM/TrackNumber")) {
107 const ASF::Attribute attr = d->attributeListMap["WM/TrackNumber"][0];
108 if(attr.type() == ASF::Attribute::DWordType)
109 return attr.toUInt();
111 return attr.toString().toInt();
113 if(d->attributeListMap.contains("WM/Track"))
114 return d->attributeListMap["WM/Track"][0].toUInt();
119 ASF::Tag::genre() const
121 if(d->attributeListMap.contains("WM/Genre"))
122 return d->attributeListMap["WM/Genre"][0].toString();
127 ASF::Tag::setTitle(const String &value)
133 ASF::Tag::setArtist(const String &value)
139 ASF::Tag::setCopyright(const String &value)
141 d->copyright = value;
145 ASF::Tag::setComment(const String &value)
151 ASF::Tag::setRating(const String &value)
157 ASF::Tag::setAlbum(const String &value)
159 setAttribute("WM/AlbumTitle", value);
163 ASF::Tag::setGenre(const String &value)
165 setAttribute("WM/Genre", value);
169 ASF::Tag::setYear(uint value)
171 setAttribute("WM/Year", String::number(value));
175 ASF::Tag::setTrack(uint value)
177 setAttribute("WM/TrackNumber", String::number(value));
180 ASF::AttributeListMap&
181 ASF::Tag::attributeListMap()
183 return d->attributeListMap;
186 void ASF::Tag::removeItem(const String &key)
188 AttributeListMap::Iterator it = d->attributeListMap.find(key);
189 if(it != d->attributeListMap.end())
190 d->attributeListMap.erase(it);
193 void ASF::Tag::setAttribute(const String &name, const Attribute &attribute)
196 value.append(attribute);
197 d->attributeListMap.insert(name, value);
200 void ASF::Tag::addAttribute(const String &name, const Attribute &attribute)
202 if(d->attributeListMap.contains(name)) {
203 d->attributeListMap[name].append(attribute);
206 setAttribute(name, attribute);
210 bool ASF::Tag::isEmpty() const {
211 return TagLib::Tag::isEmpty() &&
212 copyright().isEmpty() &&
213 rating().isEmpty() &&
214 d->attributeListMap.isEmpty();