Added TagLib (with AUTORS and COPYING files)
[someplayer] / src / taglib / tagunion.h
1 /***************************************************************************
2     copyright            : (C) 2002 - 2008 by Scott Wheeler
3     email                : wheeler@kde.org
4  ***************************************************************************/
5
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.                     *
10  *                                                                         *
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.                       *
15  *                                                                         *
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  *
19  *   USA                                                                   *
20  *                                                                         *
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  ***************************************************************************/
25
26 #ifndef TAGLIB_TAGUNION_H
27 #define TAGLIB_TAGUNION_H
28
29 #include "tag.h"
30
31 #ifndef DO_NOT_DOCUMENT
32
33 namespace TagLib {
34
35   /*!
36    * \internal
37    */
38
39   class TagUnion : public Tag
40   {
41   public:
42
43     enum AccessType { Read, Write };
44
45     /*!
46      * Creates a TagLib::Tag that is the union of \a first, \a second, and
47      * \a third.  The TagUnion takes ownership of these tags and will handle
48      * their deletion.
49      */
50     TagUnion(Tag *first = 0, Tag *second = 0, Tag *third = 0);
51
52     virtual ~TagUnion();
53
54     Tag *operator[](int index) const;
55     Tag *tag(int index) const;
56
57     void set(int index, Tag *tag);
58
59     virtual String title() const;
60     virtual String artist() const;
61     virtual String album() const;
62     virtual String comment() const;
63     virtual String genre() const;
64     virtual uint year() const;
65     virtual uint track() const;
66
67     virtual void setTitle(const String &s);
68     virtual void setArtist(const String &s);
69     virtual void setAlbum(const String &s);
70     virtual void setComment(const String &s);
71     virtual void setGenre(const String &s);
72     virtual void setYear(uint i);
73     virtual void setTrack(uint i);
74     virtual bool isEmpty() const;
75
76     template <class T> T *access(int index, bool create)
77     {
78       if(!create || tag(index))
79         return static_cast<T *>(tag(index));
80
81       set(index, new T);
82       return static_cast<T *>(tag(index));
83     }
84
85   private:
86     TagUnion(const Tag &);
87     TagUnion &operator=(const Tag &);
88
89     class TagUnionPrivate;
90     TagUnionPrivate *d;
91   };
92 }
93
94 #endif
95 #endif