strawberry-audio-player-win.../3rdparty/taglib/mp4/mp4item.cpp

170 lines
4.3 KiB
C++
Raw Normal View History

2018-05-10 15:29:28 +02:00
/**************************************************************************
copyright : (C) 2007 by Lukáš Lalinský
email : lalinsky@gmail.com
**************************************************************************/
/***************************************************************************
* This library is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License version *
* 2.1 as published by the Free Software Foundation. *
* *
* This library is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free Software *
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
* 02110-1301 USA *
* *
* Alternatively, this file is available under the Mozilla Public *
* License Version 1.1. You may obtain a copy of the License at *
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#include <taglib.h>
#include <tdebug.h>
#include "trefcounter.h"
#include "mp4item.h"
using namespace Strawberry_TagLib::TagLib;
2018-05-10 15:29:28 +02:00
2020-06-13 19:02:42 +02:00
class MP4::Item::ItemPrivate : public RefCounter {
public:
ItemPrivate() : RefCounter(),
valid(true),
atomDataType(TypeUndefined) {}
2018-05-10 15:29:28 +02:00
bool valid;
AtomDataType atomDataType;
union {
bool m_bool;
int m_int;
IntPair m_intPair;
unsigned char m_byte;
unsigned int m_uint;
long long m_longlong;
};
StringList m_stringList;
ByteVectorList m_byteVectorList;
MP4::CoverArtList m_coverArtList;
};
2020-06-13 19:02:42 +02:00
MP4::Item::Item() : d(new ItemPrivate()) {
2018-05-10 15:29:28 +02:00
d->valid = false;
}
2020-06-13 19:02:42 +02:00
MP4::Item::Item(const Item &item) : d(item.d) {
2018-05-10 15:29:28 +02:00
d->ref();
}
MP4::Item &
2020-06-13 19:02:42 +02:00
MP4::Item::operator=(const Item &item) {
2018-05-10 15:29:28 +02:00
Item(item).swap(*this);
return *this;
}
2020-06-13 19:02:42 +02:00
void MP4::Item::swap(Item &item) {
2018-05-10 15:29:28 +02:00
using std::swap;
swap(d, item.d);
}
2020-06-13 19:02:42 +02:00
MP4::Item::~Item() {
if (d->deref())
2018-05-10 15:29:28 +02:00
delete d;
}
2020-06-13 19:02:42 +02:00
MP4::Item::Item(bool value) : d(new ItemPrivate()) {
2018-05-10 15:29:28 +02:00
d->m_bool = value;
}
2020-06-13 19:02:42 +02:00
MP4::Item::Item(int value) : d(new ItemPrivate()) {
2018-05-10 15:29:28 +02:00
d->m_int = value;
}
2020-06-13 19:02:42 +02:00
MP4::Item::Item(unsigned char value) : d(new ItemPrivate()) {
2018-05-10 15:29:28 +02:00
d->m_byte = value;
}
2020-06-13 19:02:42 +02:00
MP4::Item::Item(unsigned int value) : d(new ItemPrivate()) {
2018-05-10 15:29:28 +02:00
d->m_uint = value;
}
2020-06-13 19:02:42 +02:00
MP4::Item::Item(long long value) : d(new ItemPrivate()) {
2018-05-10 15:29:28 +02:00
d->m_longlong = value;
}
2020-06-13 19:02:42 +02:00
MP4::Item::Item(int value1, int value2) : d(new ItemPrivate()) {
2018-05-10 15:29:28 +02:00
d->m_intPair.first = value1;
d->m_intPair.second = value2;
}
2020-06-13 19:02:42 +02:00
MP4::Item::Item(const ByteVectorList &value) : d(new ItemPrivate()) {
2018-05-10 15:29:28 +02:00
d->m_byteVectorList = value;
}
2020-06-13 19:02:42 +02:00
MP4::Item::Item(const StringList &value) : d(new ItemPrivate()) {
2018-05-10 15:29:28 +02:00
d->m_stringList = value;
}
2020-06-13 19:02:42 +02:00
MP4::Item::Item(const MP4::CoverArtList &value) : d(new ItemPrivate()) {
2018-05-10 15:29:28 +02:00
d->m_coverArtList = value;
}
2020-06-13 19:02:42 +02:00
void MP4::Item::setAtomDataType(MP4::AtomDataType type) {
2018-05-10 15:29:28 +02:00
d->atomDataType = type;
}
2020-06-13 19:02:42 +02:00
MP4::AtomDataType MP4::Item::atomDataType() const {
2018-05-10 15:29:28 +02:00
return d->atomDataType;
}
2020-06-13 19:02:42 +02:00
bool MP4::Item::toBool() const {
2018-05-10 15:29:28 +02:00
return d->m_bool;
}
2020-06-13 19:02:42 +02:00
int MP4::Item::toInt() const {
2018-05-10 15:29:28 +02:00
return d->m_int;
}
unsigned char
2020-06-13 19:02:42 +02:00
MP4::Item::toByte() const {
2018-05-10 15:29:28 +02:00
return d->m_byte;
}
unsigned int
2020-06-13 19:02:42 +02:00
MP4::Item::toUInt() const {
2018-05-10 15:29:28 +02:00
return d->m_uint;
}
long long
2020-06-13 19:02:42 +02:00
MP4::Item::toLongLong() const {
2018-05-10 15:29:28 +02:00
return d->m_longlong;
}
MP4::Item::IntPair
2020-06-13 19:02:42 +02:00
MP4::Item::toIntPair() const {
2018-05-10 15:29:28 +02:00
return d->m_intPair;
}
StringList
2020-06-13 19:02:42 +02:00
MP4::Item::toStringList() const {
2018-05-10 15:29:28 +02:00
return d->m_stringList;
}
ByteVectorList
2020-06-13 19:02:42 +02:00
MP4::Item::toByteVectorList() const {
2018-05-10 15:29:28 +02:00
return d->m_byteVectorList;
}
MP4::CoverArtList
2020-06-13 19:02:42 +02:00
MP4::Item::toCoverArtList() const {
2018-05-10 15:29:28 +02:00
return d->m_coverArtList;
}
2020-06-13 19:02:42 +02:00
bool MP4::Item::isValid() const {
2018-05-10 15:29:28 +02:00
return d->valid;
}