1 /***************************************************************************
2 copyright : (C) 2002 - 2008 by Scott Wheeler
3 email : wheeler@kde.org
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 ***************************************************************************/
28 using namespace TagLib;
30 #define stringUnion(method) \
31 if(tag(0) && !tag(0)->method().isEmpty()) \
32 return tag(0)->method(); \
33 if(tag(1) && !tag(1)->method().isEmpty()) \
34 return tag(1)->method(); \
35 if(tag(2) && !tag(2)->method().isEmpty()) \
36 return tag(2)->method(); \
39 #define numberUnion(method) \
40 if(tag(0) && tag(0)->method() > 0) \
41 return tag(0)->method(); \
42 if(tag(1) && tag(1)->method() > 0) \
43 return tag(1)->method(); \
44 if(tag(2) && tag(2)->method() > 0) \
45 return tag(2)->method(); \
48 #define setUnion(method, value) \
50 tag(0)->set##method(value); \
52 tag(1)->set##method(value); \
54 tag(2)->set##method(value); \
56 class TagUnion::TagUnionPrivate
59 TagUnionPrivate() : tags(3, static_cast<Tag *>(0))
71 std::vector<Tag *> tags;
74 TagUnion::TagUnion(Tag *first, Tag *second, Tag *third)
76 d = new TagUnionPrivate;
88 Tag *TagUnion::operator[](int index) const
93 Tag *TagUnion::tag(int index) const
95 return d->tags[index];
98 void TagUnion::set(int index, Tag *tag)
100 delete d->tags[index];
101 d->tags[index] = tag;
104 String TagUnion::title() const
109 String TagUnion::artist() const
114 String TagUnion::album() const
119 String TagUnion::comment() const
121 stringUnion(comment);
124 String TagUnion::genre() const
129 TagLib::uint TagUnion::year() const
134 TagLib::uint TagUnion::track() const
139 void TagUnion::setTitle(const String &s)
144 void TagUnion::setArtist(const String &s)
149 void TagUnion::setAlbum(const String &s)
154 void TagUnion::setComment(const String &s)
156 setUnion(Comment, s);
159 void TagUnion::setGenre(const String &s)
164 void TagUnion::setYear(uint i)
169 void TagUnion::setTrack(uint i)
174 bool TagUnion::isEmpty() const
176 if(d->tags[0] && !d->tags[0]->isEmpty())
178 if(d->tags[1] && !d->tags[1]->isEmpty())
180 if(d->tags[2] && !d->tags[2]->isEmpty())