mirror of
https://github.com/taglib/taglib.git
synced 2025-11-16 22:52:57 -05:00
Replace RefCounter with std::shared_ptr if possible
This commit is contained in:
@ -60,81 +60,108 @@ public:
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ASF::Attribute::Attribute()
|
||||
: d(new AttributePrivate())
|
||||
{
|
||||
d = new AttributePrivate;
|
||||
d->type = UnicodeType;
|
||||
}
|
||||
|
||||
ASF::Attribute::Attribute(const ASF::Attribute &other)
|
||||
: d(other.d)
|
||||
{
|
||||
d->ref();
|
||||
}
|
||||
#ifndef TAGLIB_USE_CXX11
|
||||
|
||||
ASF::Attribute &ASF::Attribute::operator=(const ASF::Attribute &other)
|
||||
{
|
||||
if(d->deref())
|
||||
delete d;
|
||||
d = other.d;
|
||||
d->ref();
|
||||
return *this;
|
||||
}
|
||||
|
||||
ASF::Attribute::~Attribute()
|
||||
{
|
||||
if(d->deref())
|
||||
delete d;
|
||||
#endif
|
||||
}
|
||||
|
||||
ASF::Attribute::Attribute(const String &value)
|
||||
: d(new AttributePrivate())
|
||||
{
|
||||
d = new AttributePrivate;
|
||||
d->type = UnicodeType;
|
||||
d->stringValue = value;
|
||||
}
|
||||
|
||||
ASF::Attribute::Attribute(const ByteVector &value)
|
||||
: d(new AttributePrivate())
|
||||
{
|
||||
d = new AttributePrivate;
|
||||
d->type = BytesType;
|
||||
d->byteVectorValue = value;
|
||||
}
|
||||
|
||||
ASF::Attribute::Attribute(const ASF::Picture &value)
|
||||
: d(new AttributePrivate())
|
||||
{
|
||||
d = new AttributePrivate;
|
||||
d->type = BytesType;
|
||||
d->pictureValue = value;
|
||||
}
|
||||
|
||||
ASF::Attribute::Attribute(unsigned int value)
|
||||
: d(new AttributePrivate())
|
||||
{
|
||||
d = new AttributePrivate;
|
||||
d->type = DWordType;
|
||||
d->intValue = value;
|
||||
}
|
||||
|
||||
ASF::Attribute::Attribute(unsigned long long value)
|
||||
: d(new AttributePrivate())
|
||||
{
|
||||
d = new AttributePrivate;
|
||||
d->type = QWordType;
|
||||
d->longLongValue = value;
|
||||
}
|
||||
|
||||
ASF::Attribute::Attribute(unsigned short value)
|
||||
: d(new AttributePrivate())
|
||||
{
|
||||
d = new AttributePrivate;
|
||||
d->type = WordType;
|
||||
d->shortValue = value;
|
||||
}
|
||||
|
||||
ASF::Attribute::Attribute(bool value)
|
||||
: d(new AttributePrivate())
|
||||
{
|
||||
d = new AttributePrivate;
|
||||
d->type = BoolType;
|
||||
d->boolValue = value;
|
||||
}
|
||||
|
||||
ASF::Attribute::~Attribute()
|
||||
{
|
||||
#ifndef TAGLIB_USE_CXX11
|
||||
|
||||
if(d->deref())
|
||||
delete d;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
ASF::Attribute &ASF::Attribute::operator=(const ASF::Attribute &other)
|
||||
{
|
||||
#ifdef TAGLIB_USE_CXX11
|
||||
|
||||
d = other.d;
|
||||
|
||||
#else
|
||||
|
||||
if(d->deref())
|
||||
delete d;
|
||||
d = other.d;
|
||||
d->ref();
|
||||
|
||||
#endif
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
#ifdef TAGLIB_USE_CXX11
|
||||
|
||||
ASF::Attribute &ASF::Attribute::operator=(ASF::Attribute &&other)
|
||||
{
|
||||
d = std::move(other.d);
|
||||
return *this;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
ASF::Attribute::AttributeTypes ASF::Attribute::type() const
|
||||
{
|
||||
return d->type;
|
||||
|
||||
@ -115,6 +115,15 @@ namespace TagLib
|
||||
*/
|
||||
ASF::Attribute &operator=(const Attribute &other);
|
||||
|
||||
#ifdef TAGLIB_USE_CXX11
|
||||
|
||||
/*!
|
||||
* Moves the contents of \a other into this item.
|
||||
*/
|
||||
ASF::Attribute &operator=(Attribute &&other);
|
||||
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* Destroys the attribute.
|
||||
*/
|
||||
@ -194,7 +203,12 @@ namespace TagLib
|
||||
ByteVector render(const String &name, int kind = 0) const;
|
||||
|
||||
class AttributePrivate;
|
||||
|
||||
#ifdef TAGLIB_USE_CXX11
|
||||
std::shared_ptr<AttributePrivate> d;
|
||||
#else
|
||||
AttributePrivate *d;
|
||||
#endif
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -60,17 +60,17 @@ public:
|
||||
ASF::File::MetadataLibraryObject *metadataLibraryObject;
|
||||
};
|
||||
|
||||
static ByteVector headerGuid("\x30\x26\xB2\x75\x8E\x66\xCF\x11\xA6\xD9\x00\xAA\x00\x62\xCE\x6C", 16);
|
||||
static ByteVector filePropertiesGuid("\xA1\xDC\xAB\x8C\x47\xA9\xCF\x11\x8E\xE4\x00\xC0\x0C\x20\x53\x65", 16);
|
||||
static ByteVector streamPropertiesGuid("\x91\x07\xDC\xB7\xB7\xA9\xCF\x11\x8E\xE6\x00\xC0\x0C\x20\x53\x65", 16);
|
||||
static ByteVector contentDescriptionGuid("\x33\x26\xB2\x75\x8E\x66\xCF\x11\xA6\xD9\x00\xAA\x00\x62\xCE\x6C", 16);
|
||||
static ByteVector extendedContentDescriptionGuid("\x40\xA4\xD0\xD2\x07\xE3\xD2\x11\x97\xF0\x00\xA0\xC9\x5E\xA8\x50", 16);
|
||||
static ByteVector headerExtensionGuid("\xb5\x03\xbf_.\xa9\xcf\x11\x8e\xe3\x00\xc0\x0c Se", 16);
|
||||
static ByteVector metadataGuid("\xEA\xCB\xF8\xC5\xAF[wH\204g\xAA\214D\xFAL\xCA", 16);
|
||||
static ByteVector metadataLibraryGuid("\224\034#D\230\224\321I\241A\x1d\x13NEpT", 16);
|
||||
static ByteVector contentEncryptionGuid("\xFB\xB3\x11\x22\x23\xBD\xD2\x11\xB4\xB7\x00\xA0\xC9\x55\xFC\x6E", 16);
|
||||
static ByteVector extendedContentEncryptionGuid("\x14\xE6\x8A\x29\x22\x26 \x17\x4C\xB9\x35\xDA\xE0\x7E\xE9\x28\x9C", 16);
|
||||
static ByteVector advancedContentEncryptionGuid("\xB6\x9B\x07\x7A\xA4\xDA\x12\x4E\xA5\xCA\x91\xD3\x8D\xC1\x1A\x8D", 16);
|
||||
static const ByteVector headerGuid("\x30\x26\xB2\x75\x8E\x66\xCF\x11\xA6\xD9\x00\xAA\x00\x62\xCE\x6C", 16);
|
||||
static const ByteVector filePropertiesGuid("\xA1\xDC\xAB\x8C\x47\xA9\xCF\x11\x8E\xE4\x00\xC0\x0C\x20\x53\x65", 16);
|
||||
static const ByteVector streamPropertiesGuid("\x91\x07\xDC\xB7\xB7\xA9\xCF\x11\x8E\xE6\x00\xC0\x0C\x20\x53\x65", 16);
|
||||
static const ByteVector contentDescriptionGuid("\x33\x26\xB2\x75\x8E\x66\xCF\x11\xA6\xD9\x00\xAA\x00\x62\xCE\x6C", 16);
|
||||
static const ByteVector extendedContentDescriptionGuid("\x40\xA4\xD0\xD2\x07\xE3\xD2\x11\x97\xF0\x00\xA0\xC9\x5E\xA8\x50", 16);
|
||||
static const ByteVector headerExtensionGuid("\xb5\x03\xbf_.\xa9\xcf\x11\x8e\xe3\x00\xc0\x0c Se", 16);
|
||||
static const ByteVector metadataGuid("\xEA\xCB\xF8\xC5\xAF[wH\204g\xAA\214D\xFAL\xCA", 16);
|
||||
static const ByteVector metadataLibraryGuid("\224\034#D\230\224\321I\241A\x1d\x13NEpT", 16);
|
||||
static const ByteVector contentEncryptionGuid("\xFB\xB3\x11\x22\x23\xBD\xD2\x11\xB4\xB7\x00\xA0\xC9\x55\xFC\x6E", 16);
|
||||
static const ByteVector extendedContentEncryptionGuid("\x14\xE6\x8A\x29\x22\x26 \x17\x4C\xB9\x35\xDA\xE0\x7E\xE9\x28\x9C", 16);
|
||||
static const ByteVector advancedContentEncryptionGuid("\xB6\x9B\x07\x7A\xA4\xDA\x12\x4E\xA5\xCA\x91\xD3\x8D\xC1\x1A\x8D", 16);
|
||||
|
||||
class ASF::File::BaseObject
|
||||
{
|
||||
|
||||
@ -50,21 +50,38 @@ public:
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ASF::Picture::Picture()
|
||||
: d(new PicturePrivate())
|
||||
{
|
||||
d = new PicturePrivate();
|
||||
d->valid = true;
|
||||
}
|
||||
|
||||
ASF::Picture::Picture(const Picture& other)
|
||||
: d(other.d)
|
||||
{
|
||||
#ifndef TAGLIB_USE_CXX11
|
||||
|
||||
d->ref();
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef TAGLIB_USE_CXX11
|
||||
|
||||
ASF::Picture::Picture(Picture &&other)
|
||||
: d(std::move(other.d))
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
ASF::Picture::~Picture()
|
||||
{
|
||||
#ifndef TAGLIB_USE_CXX11
|
||||
|
||||
if(d->deref())
|
||||
delete d;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
bool ASF::Picture::isValid() const
|
||||
@ -121,15 +138,35 @@ int ASF::Picture::dataSize() const
|
||||
|
||||
ASF::Picture& ASF::Picture::operator=(const ASF::Picture& other)
|
||||
{
|
||||
#ifdef TAGLIB_USE_CXX11
|
||||
|
||||
d = other.d;
|
||||
|
||||
#else
|
||||
|
||||
if(other.d != d) {
|
||||
if(d->deref())
|
||||
delete d;
|
||||
d = other.d;
|
||||
d->ref();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
#ifdef TAGLIB_USE_CXX11
|
||||
|
||||
ASF::Picture& ASF::Picture::operator=(ASF::Picture &&other)
|
||||
{
|
||||
d = std::move(other.d);
|
||||
return *this;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
ByteVector ASF::Picture::render() const
|
||||
{
|
||||
if(!isValid())
|
||||
|
||||
@ -103,10 +103,19 @@ namespace TagLib
|
||||
Picture();
|
||||
|
||||
/*!
|
||||
* Construct an picture as a copy of \a other.
|
||||
* Constructs an picture as a copy of \a other.
|
||||
*/
|
||||
Picture(const Picture& other);
|
||||
|
||||
#ifdef TAGLIB_USE_CXX11
|
||||
|
||||
/*!
|
||||
* Constructs an picture equivalent to \a other.
|
||||
*/
|
||||
Picture(Picture &&other);
|
||||
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* Destroys the picture.
|
||||
*/
|
||||
@ -117,6 +126,15 @@ namespace TagLib
|
||||
*/
|
||||
Picture& operator=(const Picture& other);
|
||||
|
||||
#ifdef TAGLIB_USE_CXX11
|
||||
|
||||
/*!
|
||||
* Moves the contents of \a other into this picture.
|
||||
*/
|
||||
Picture& operator=(Picture &&other);
|
||||
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* Returns true if Picture stores valid picture
|
||||
*/
|
||||
@ -207,10 +225,15 @@ namespace TagLib
|
||||
static Picture fromInvalid();
|
||||
friend class Attribute;
|
||||
#endif
|
||||
private:
|
||||
class PicturePrivate;
|
||||
PicturePrivate *d;
|
||||
};
|
||||
private:
|
||||
class PicturePrivate;
|
||||
|
||||
#ifdef TAGLIB_USE_CXX11
|
||||
std::shared_ptr<PicturePrivate> d;
|
||||
#else
|
||||
PicturePrivate *d;
|
||||
#endif
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user