TagLib API Documentation
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
33namespace TagLib {
34
39 class TagUnion : public Tag
40 {
41 public:
42
43 enum AccessType { Read, Write };
44
50 TagUnion(Tag *first = nullptr, Tag *second = nullptr, Tag *third = nullptr);
51
52 ~TagUnion() override;
53
54 TagUnion(const TagUnion &) = delete;
55 TagUnion &operator=(const TagUnion &) = delete;
56
57 Tag *operator[](int index) const;
58 Tag *tag(int index) const;
59
60 void set(int index, Tag *tag);
61
62 PropertyMap properties() const override;
63 void removeUnsupportedProperties(const StringList &unsupported) override;
64
65 StringList complexPropertyKeys() const override;
66 List<VariantMap> complexProperties(const String &key) const override;
67 bool setComplexProperties(const String &key, const List<VariantMap> &value) override;
68
69 String title() const override;
70 String artist() const override;
71 String album() const override;
72 String comment() const override;
73 String genre() const override;
74 unsigned int year() const override;
75 unsigned int track() const override;
76
77 void setTitle(const String &s) override;
78 void setArtist(const String &s) override;
79 void setAlbum(const String &s) override;
80 void setComment(const String &s) override;
81 void setGenre(const String &s) override;
82 void setYear(unsigned int i) override;
83 void setTrack(unsigned int i) override;
84 bool isEmpty() const override;
85
86 template <class T> T *access(int index, bool create)
87 {
88 if(!create || tag(index))
89 return static_cast<T *>(tag(index));
90
91 set(index, new T);
92 return static_cast<T *>(tag(index));
93 }
94
95 template <class T, class F> T *access(int index, bool create, const F *factory)
96 {
97 if(!create || tag(index))
98 return static_cast<T *>(tag(index));
99
100 set(index, new T(nullptr, 0, factory));
101 return static_cast<T *>(tag(index));
102 }
103
104 private:
105 TagUnion(const Tag &);
106 TagUnion &operator=(const Tag &);
107
108 class TagUnionPrivate;
109 std::unique_ptr<TagUnionPrivate> d;
110 };
111} // namespace TagLib
112
113#endif
114#endif
String TAGLIB_EXPORT genre(int index)
A namespace for all TagLib related classes and functions.
Definition: apefile.h:41