tagunion.h
Go to the documentation of this file.
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., 51 Franklin Street, Fifth Floor, Boston, MA *
19  * 02110-1301 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 
39  class TagUnion : public Tag
40  {
41  public:
42 
43  enum AccessType { Read, Write };
44 
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
virtual uint track() const
Tag * operator[](int index) const
virtual void setYear(uint i)
virtual void setTitle(const String &s)
virtual String artist() const
virtual bool isEmpty() const
void set(int index, Tag *tag)
T * access(int index, bool create)
Definition: tagunion.h:76
virtual void setAlbum(const String &s)
virtual String genre() const
gProfD create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0755)
function d(s)
virtual String comment() const
virtual ~TagUnion()
virtual void setTrack(uint i)
virtual void setComment(const String &s)
virtual void setGenre(const String &s)
virtual void setArtist(const String &s)
Tag * tag(int index) const
TagUnion(Tag *first=0, Tag *second=0, Tag *third=0)
virtual String album() const
virtual String title() const
merge second
_getSelectedPageStyle s i
return first
virtual uint year() const