Added TagLib (with AUTORS and COPYING files)
[someplayer] / src / taglib / mp4 / mp4item.cpp
1 /**************************************************************************
2     copyright            : (C) 2007 by Lukáš Lalinský
3     email                : lalinsky@gmail.com
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 #ifdef HAVE_CONFIG_H
27 #include <config.h>
28 #endif
29
30 #ifdef WITH_MP4
31
32 #include <taglib.h>
33 #include <tdebug.h>
34 #include "mp4item.h"
35
36 using namespace TagLib;
37
38 class MP4::Item::ItemPrivate : public RefCounter
39 {
40 public:
41   ItemPrivate() : RefCounter(), valid(true) {}
42
43   bool valid;
44   union {
45     bool m_bool;
46     int m_int;
47     IntPair m_intPair;
48   };
49   StringList m_stringList;
50   MP4::CoverArtList m_coverArtList;
51 };
52
53 MP4::Item::Item()
54 {
55   d = new ItemPrivate;
56   d->valid = false;
57 }
58
59 MP4::Item::Item(const Item &item) : d(item.d)
60 {
61   d->ref();
62 }
63
64 MP4::Item &
65 MP4::Item::operator=(const Item &item)
66 {
67   if(d->deref()) {
68     delete d;
69   }
70   d = item.d;
71   d->ref();
72   return *this;
73 }
74
75 MP4::Item::~Item()
76 {
77   if(d->deref()) {
78     delete d;
79   }
80 }
81
82 MP4::Item::Item(bool value)
83 {
84   d = new ItemPrivate;
85   d->m_bool = value;
86 }
87
88 MP4::Item::Item(int value)
89 {
90   d = new ItemPrivate;
91   d->m_int = value;
92 }
93
94 MP4::Item::Item(int value1, int value2)
95 {
96   d = new ItemPrivate;
97   d->m_intPair.first = value1;
98   d->m_intPair.second = value2;
99 }
100
101 MP4::Item::Item(const StringList &value)
102 {
103   d = new ItemPrivate;
104   d->m_stringList = value;
105 }
106
107 MP4::Item::Item(const MP4::CoverArtList &value)
108 {
109   d = new ItemPrivate;
110   d->m_coverArtList = value;
111 }
112
113 bool
114 MP4::Item::toBool() const
115 {
116   return d->m_bool;
117 }
118
119 int
120 MP4::Item::toInt() const
121 {
122   return d->m_int;
123 }
124
125 MP4::Item::IntPair
126 MP4::Item::toIntPair() const
127 {
128   return d->m_intPair;
129 }
130
131 StringList
132 MP4::Item::toStringList() const
133 {
134   return d->m_stringList;
135 }
136
137 MP4::CoverArtList
138 MP4::Item::toCoverArtList() const
139 {
140   return d->m_coverArtList;
141 }
142
143 bool
144 MP4::Item::isValid() const
145 {
146   return d->valid;
147 }
148
149 #endif