mirror of
https://github.com/taglib/taglib.git
synced 2025-11-16 22:52:57 -05:00
RefCounter mimics std::shared_ptr
This commit is contained in:
@ -34,7 +34,7 @@
|
||||
|
||||
using namespace TagLib;
|
||||
|
||||
class ASF::Attribute::AttributePrivate : public RefCounter
|
||||
class ASF::Attribute::AttributePrivate
|
||||
{
|
||||
public:
|
||||
AttributePrivate()
|
||||
@ -68,11 +68,6 @@ ASF::Attribute::Attribute()
|
||||
ASF::Attribute::Attribute(const ASF::Attribute &other)
|
||||
: d(other.d)
|
||||
{
|
||||
#ifndef TAGLIB_USE_CXX11
|
||||
|
||||
d->ref();
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
ASF::Attribute::Attribute(const String &value)
|
||||
@ -126,29 +121,11 @@ ASF::Attribute::Attribute(bool 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;
|
||||
}
|
||||
|
||||
|
||||
@ -205,12 +205,7 @@ 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
|
||||
RefCountPtr<AttributePrivate> d;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -35,7 +35,7 @@
|
||||
|
||||
using namespace TagLib;
|
||||
|
||||
class ASF::Picture::PicturePrivate : public RefCounter
|
||||
class ASF::Picture::PicturePrivate
|
||||
{
|
||||
public:
|
||||
bool valid;
|
||||
@ -58,11 +58,6 @@ ASF::Picture::Picture()
|
||||
ASF::Picture::Picture(const Picture& other)
|
||||
: d(other.d)
|
||||
{
|
||||
#ifndef TAGLIB_USE_CXX11
|
||||
|
||||
d->ref();
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef TAGLIB_USE_CXX11
|
||||
@ -76,12 +71,6 @@ ASF::Picture::Picture(Picture &&other)
|
||||
|
||||
ASF::Picture::~Picture()
|
||||
{
|
||||
#ifndef TAGLIB_USE_CXX11
|
||||
|
||||
if(d->deref())
|
||||
delete d;
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
bool ASF::Picture::isValid() const
|
||||
@ -138,21 +127,7 @@ 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;
|
||||
}
|
||||
|
||||
|
||||
@ -231,12 +231,7 @@ namespace TagLib
|
||||
#endif
|
||||
private:
|
||||
class PicturePrivate;
|
||||
|
||||
#ifdef TAGLIB_USE_CXX11
|
||||
std::shared_ptr<PicturePrivate> d;
|
||||
#else
|
||||
PicturePrivate *d;
|
||||
#endif
|
||||
RefCountPtr<PicturePrivate> d;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user