mirror of
https://github.com/taglib/taglib.git
synced 2025-05-27 21:20:26 -04:00
Convert private raw pointers to unique_ptr (#1127)
Simplifies the code quite a bit.
This commit is contained in:
parent
967aaf7af2
commit
e275abb8a3
@ -52,28 +52,18 @@ namespace
|
||||
class APE::File::FilePrivate
|
||||
{
|
||||
public:
|
||||
FilePrivate() = default;
|
||||
~FilePrivate()
|
||||
{
|
||||
delete ID3v2Header;
|
||||
delete properties;
|
||||
}
|
||||
|
||||
FilePrivate(const FilePrivate &) = delete;
|
||||
FilePrivate &operator=(const FilePrivate &) = delete;
|
||||
|
||||
offset_t APELocation { -1 };
|
||||
long APESize { 0 };
|
||||
|
||||
offset_t ID3v1Location { -1 };
|
||||
|
||||
ID3v2::Header *ID3v2Header { nullptr };
|
||||
std::unique_ptr<ID3v2::Header> ID3v2Header;
|
||||
offset_t ID3v2Location { -1 };
|
||||
long ID3v2Size { 0 };
|
||||
|
||||
TagUnion tag;
|
||||
|
||||
Properties *properties { nullptr };
|
||||
std::unique_ptr<Properties> properties;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -135,7 +125,7 @@ PropertyMap APE::File::setProperties(const PropertyMap &properties)
|
||||
|
||||
APE::Properties *APE::File::audioProperties() const
|
||||
{
|
||||
return d->properties;
|
||||
return d->properties.get();
|
||||
}
|
||||
|
||||
bool APE::File::save()
|
||||
@ -254,7 +244,7 @@ void APE::File::read(bool readProperties)
|
||||
|
||||
if(d->ID3v2Location >= 0) {
|
||||
seek(d->ID3v2Location);
|
||||
d->ID3v2Header = new ID3v2::Header(readBlock(ID3v2::Header::size()));
|
||||
d->ID3v2Header = std::make_unique<ID3v2::Header>(readBlock(ID3v2::Header::size()));
|
||||
d->ID3v2Size = d->ID3v2Header->completeTagSize();
|
||||
}
|
||||
|
||||
@ -299,6 +289,6 @@ void APE::File::read(bool readProperties)
|
||||
seek(0);
|
||||
}
|
||||
|
||||
d->properties = new Properties(this, streamLength);
|
||||
d->properties = std::make_unique<Properties>(this, streamLength);
|
||||
}
|
||||
}
|
||||
|
@ -56,19 +56,15 @@ public:
|
||||
objects.setAutoDelete(true);
|
||||
}
|
||||
|
||||
~FilePrivate()
|
||||
{
|
||||
delete tag;
|
||||
delete properties;
|
||||
}
|
||||
~FilePrivate() = default;
|
||||
|
||||
FilePrivate(const FilePrivate &) = delete;
|
||||
FilePrivate &operator=(const FilePrivate &) = delete;
|
||||
|
||||
unsigned long long headerSize { 0 };
|
||||
|
||||
ASF::Tag *tag { nullptr };
|
||||
ASF::Properties *properties { nullptr };
|
||||
std::unique_ptr<ASF::Tag> tag;
|
||||
std::unique_ptr<ASF::Properties> properties;
|
||||
|
||||
List<BaseObject *> objects;
|
||||
|
||||
@ -503,7 +499,7 @@ ASF::File::~File() = default;
|
||||
|
||||
ASF::Tag *ASF::File::tag() const
|
||||
{
|
||||
return d->tag;
|
||||
return d->tag.get();
|
||||
}
|
||||
|
||||
PropertyMap ASF::File::properties() const
|
||||
@ -523,7 +519,7 @@ PropertyMap ASF::File::setProperties(const PropertyMap &properties)
|
||||
|
||||
ASF::Properties *ASF::File::audioProperties() const
|
||||
{
|
||||
return d->properties;
|
||||
return d->properties.get();
|
||||
}
|
||||
|
||||
bool ASF::File::save()
|
||||
@ -617,8 +613,8 @@ void ASF::File::read()
|
||||
return;
|
||||
}
|
||||
|
||||
d->tag = new ASF::Tag();
|
||||
d->properties = new ASF::Properties();
|
||||
d->tag = std::make_unique<ASF::Tag>();
|
||||
d->properties = std::make_unique<ASF::Properties>();
|
||||
|
||||
bool ok;
|
||||
d->headerSize = readQWORD(this, &ok);
|
||||
|
@ -59,14 +59,6 @@ public:
|
||||
blocks.setAutoDelete(true);
|
||||
}
|
||||
|
||||
~FilePrivate()
|
||||
{
|
||||
delete properties;
|
||||
}
|
||||
|
||||
FilePrivate(const FilePrivate &) = delete;
|
||||
FilePrivate &operator=(const FilePrivate &) = delete;
|
||||
|
||||
const ID3v2::FrameFactory *ID3v2FrameFactory;
|
||||
offset_t ID3v2Location { -1 };
|
||||
long ID3v2OriginalSize { 0 };
|
||||
@ -75,7 +67,7 @@ public:
|
||||
|
||||
TagUnion tag;
|
||||
|
||||
Properties *properties { nullptr };
|
||||
std::unique_ptr<Properties> properties;
|
||||
ByteVector xiphCommentData;
|
||||
List<FLAC::MetadataBlock *> blocks;
|
||||
|
||||
@ -150,7 +142,7 @@ PropertyMap FLAC::File::setProperties(const PropertyMap &properties)
|
||||
|
||||
FLAC::Properties *FLAC::File::audioProperties() const
|
||||
{
|
||||
return d->properties;
|
||||
return d->properties.get();
|
||||
}
|
||||
|
||||
bool FLAC::File::save()
|
||||
@ -431,7 +423,7 @@ void FLAC::File::read(bool readProperties)
|
||||
else
|
||||
streamLength = length() - d->streamStart;
|
||||
|
||||
d->properties = new Properties(infoData, streamLength);
|
||||
d->properties = std::make_unique<Properties>(infoData, streamLength);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,20 +43,9 @@ namespace
|
||||
class MP4::File::FilePrivate
|
||||
{
|
||||
public:
|
||||
FilePrivate() = default;
|
||||
~FilePrivate()
|
||||
{
|
||||
delete atoms;
|
||||
delete tag;
|
||||
delete properties;
|
||||
}
|
||||
|
||||
FilePrivate(const FilePrivate &) = delete;
|
||||
FilePrivate &operator=(const FilePrivate &) = delete;
|
||||
|
||||
MP4::Tag *tag { nullptr };
|
||||
MP4::Atoms *atoms { nullptr };
|
||||
MP4::Properties *properties { nullptr };
|
||||
std::unique_ptr<MP4::Tag> tag;
|
||||
std::unique_ptr<MP4::Atoms> atoms;
|
||||
std::unique_ptr<MP4::Properties> properties;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -93,10 +82,9 @@ MP4::File::File(IOStream *stream, bool readProperties, AudioProperties::ReadStyl
|
||||
|
||||
MP4::File::~File() = default;
|
||||
|
||||
MP4::Tag *
|
||||
MP4::File::tag() const
|
||||
MP4::Tag *MP4::File::tag() const
|
||||
{
|
||||
return d->tag;
|
||||
return d->tag.get();
|
||||
}
|
||||
|
||||
PropertyMap MP4::File::properties() const
|
||||
@ -114,10 +102,9 @@ PropertyMap MP4::File::setProperties(const PropertyMap &properties)
|
||||
return d->tag->setProperties(properties);
|
||||
}
|
||||
|
||||
MP4::Properties *
|
||||
MP4::File::audioProperties() const
|
||||
MP4::Properties *MP4::File::audioProperties() const
|
||||
{
|
||||
return d->properties;
|
||||
return d->properties.get();
|
||||
}
|
||||
|
||||
void
|
||||
@ -126,7 +113,7 @@ MP4::File::read(bool readProperties)
|
||||
if(!isValid())
|
||||
return;
|
||||
|
||||
d->atoms = new Atoms(this);
|
||||
d->atoms = std::make_unique<Atoms>(this);
|
||||
if(!checkValid(d->atoms->atoms)) {
|
||||
setValid(false);
|
||||
return;
|
||||
@ -138,9 +125,9 @@ MP4::File::read(bool readProperties)
|
||||
return;
|
||||
}
|
||||
|
||||
d->tag = new Tag(this, d->atoms);
|
||||
d->tag = std::make_unique<Tag>(this, d->atoms.get());
|
||||
if(readProperties) {
|
||||
d->properties = new Properties(this, d->atoms);
|
||||
d->properties = std::make_unique<Properties>(this, d->atoms.get());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,28 +44,18 @@ namespace
|
||||
class MPC::File::FilePrivate
|
||||
{
|
||||
public:
|
||||
FilePrivate() = default;
|
||||
~FilePrivate()
|
||||
{
|
||||
delete ID3v2Header;
|
||||
delete properties;
|
||||
}
|
||||
|
||||
FilePrivate(const FilePrivate &) = delete;
|
||||
FilePrivate &operator=(const FilePrivate &) = delete;
|
||||
|
||||
offset_t APELocation { -1 };
|
||||
long APESize { 0 };
|
||||
|
||||
offset_t ID3v1Location { -1 };
|
||||
|
||||
ID3v2::Header *ID3v2Header { nullptr };
|
||||
std::unique_ptr<ID3v2::Header> ID3v2Header;
|
||||
offset_t ID3v2Location { -1 };
|
||||
long ID3v2Size { 0 };
|
||||
|
||||
TagUnion tag;
|
||||
|
||||
Properties *properties { nullptr };
|
||||
std::unique_ptr<Properties> properties;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -128,7 +118,7 @@ PropertyMap MPC::File::setProperties(const PropertyMap &properties)
|
||||
|
||||
MPC::Properties *MPC::File::audioProperties() const
|
||||
{
|
||||
return d->properties;
|
||||
return d->properties.get();
|
||||
}
|
||||
|
||||
bool MPC::File::save()
|
||||
@ -240,7 +230,6 @@ void MPC::File::strip(int tags)
|
||||
APETag(true);
|
||||
|
||||
if(tags & ID3v2) {
|
||||
delete d->ID3v2Header;
|
||||
d->ID3v2Header = nullptr;
|
||||
}
|
||||
}
|
||||
@ -267,7 +256,7 @@ void MPC::File::read(bool readProperties)
|
||||
|
||||
if(d->ID3v2Location >= 0) {
|
||||
seek(d->ID3v2Location);
|
||||
d->ID3v2Header = new ID3v2::Header(readBlock(ID3v2::Header::size()));
|
||||
d->ID3v2Header = std::make_unique<ID3v2::Header>(readBlock(ID3v2::Header::size()));
|
||||
d->ID3v2Size = d->ID3v2Header->completeTagSize();
|
||||
}
|
||||
|
||||
@ -312,6 +301,6 @@ void MPC::File::read(bool readProperties)
|
||||
seek(0);
|
||||
}
|
||||
|
||||
d->properties = new Properties(this, streamLength);
|
||||
d->properties = std::make_unique<Properties>(this, streamLength);
|
||||
}
|
||||
}
|
||||
|
@ -73,23 +73,14 @@ public:
|
||||
frameList.setAutoDelete(true);
|
||||
}
|
||||
|
||||
~TagPrivate()
|
||||
{
|
||||
delete extendedHeader;
|
||||
delete footer;
|
||||
}
|
||||
|
||||
TagPrivate(const TagPrivate &) = delete;
|
||||
TagPrivate &operator=(const TagPrivate &) = delete;
|
||||
|
||||
const FrameFactory *factory { nullptr };
|
||||
|
||||
File *file { nullptr };
|
||||
offset_t tagOffset { 0 };
|
||||
|
||||
Header header;
|
||||
ExtendedHeader *extendedHeader { nullptr };
|
||||
Footer *footer { nullptr };
|
||||
std::unique_ptr<ExtendedHeader> extendedHeader;
|
||||
std::unique_ptr<Footer> footer;
|
||||
|
||||
FrameListMap frameListMap;
|
||||
FrameList frameList;
|
||||
@ -327,7 +318,7 @@ Header *ID3v2::Tag::header() const
|
||||
|
||||
ExtendedHeader *ID3v2::Tag::extendedHeader() const
|
||||
{
|
||||
return d->extendedHeader;
|
||||
return d->extendedHeader.get();
|
||||
}
|
||||
|
||||
const FrameListMap &ID3v2::Tag::frameListMap() const
|
||||
@ -755,7 +746,7 @@ void ID3v2::Tag::parse(const ByteVector &origData)
|
||||
|
||||
if(d->header.extendedHeader()) {
|
||||
if(!d->extendedHeader)
|
||||
d->extendedHeader = new ExtendedHeader();
|
||||
d->extendedHeader = std::make_unique<ExtendedHeader>();
|
||||
d->extendedHeader->setData(data);
|
||||
if(d->extendedHeader->size() <= data.size()) {
|
||||
frameDataPosition += d->extendedHeader->size();
|
||||
|
@ -51,14 +51,6 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
~FilePrivate()
|
||||
{
|
||||
delete properties;
|
||||
}
|
||||
|
||||
FilePrivate(const FilePrivate &) = delete;
|
||||
FilePrivate &operator=(const FilePrivate &) = delete;
|
||||
|
||||
const ID3v2::FrameFactory *ID3v2FrameFactory;
|
||||
|
||||
offset_t ID3v2Location { -1 };
|
||||
@ -71,7 +63,7 @@ public:
|
||||
|
||||
TagUnion tag;
|
||||
|
||||
Properties *properties { nullptr };
|
||||
std::unique_ptr<Properties> properties;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -185,7 +177,7 @@ PropertyMap MPEG::File::setProperties(const PropertyMap &properties)
|
||||
|
||||
MPEG::Properties *MPEG::File::audioProperties() const
|
||||
{
|
||||
return d->properties;
|
||||
return d->properties.get();
|
||||
}
|
||||
|
||||
bool MPEG::File::save()
|
||||
@ -487,7 +479,7 @@ void MPEG::File::read(bool readProperties)
|
||||
}
|
||||
|
||||
if(readProperties)
|
||||
d->properties = new Properties(this);
|
||||
d->properties = std::make_unique<Properties>(this);
|
||||
|
||||
// Make sure that we have our default tag types available.
|
||||
|
||||
|
@ -36,16 +36,7 @@ using namespace TagLib;
|
||||
class MPEG::Properties::PropertiesPrivate
|
||||
{
|
||||
public:
|
||||
PropertiesPrivate() = default;
|
||||
~PropertiesPrivate()
|
||||
{
|
||||
delete xingHeader;
|
||||
}
|
||||
|
||||
PropertiesPrivate(const PropertiesPrivate &) = delete;
|
||||
PropertiesPrivate &operator=(const PropertiesPrivate &) = delete;
|
||||
|
||||
XingHeader *xingHeader { nullptr };
|
||||
std::unique_ptr<XingHeader> xingHeader;
|
||||
int length { 0 };
|
||||
int bitrate { 0 };
|
||||
int sampleRate { 0 };
|
||||
@ -93,7 +84,7 @@ int MPEG::Properties::channels() const
|
||||
|
||||
const MPEG::XingHeader *MPEG::Properties::xingHeader() const
|
||||
{
|
||||
return d->xingHeader;
|
||||
return d->xingHeader.get();
|
||||
}
|
||||
|
||||
MPEG::Header::Version MPEG::Properties::version() const
|
||||
@ -146,9 +137,8 @@ void MPEG::Properties::read(File *file)
|
||||
// VBR stream.
|
||||
|
||||
file->seek(firstFrameOffset);
|
||||
d->xingHeader = new XingHeader(file->readBlock(firstHeader.frameLength()));
|
||||
d->xingHeader = std::make_unique<XingHeader>(file->readBlock(firstHeader.frameLength()));
|
||||
if(!d->xingHeader->isValid()) {
|
||||
delete d->xingHeader;
|
||||
d->xingHeader = nullptr;
|
||||
}
|
||||
|
||||
|
@ -35,19 +35,9 @@ using TagLib::FLAC::Properties;
|
||||
class Ogg::FLAC::File::FilePrivate
|
||||
{
|
||||
public:
|
||||
FilePrivate() = default;
|
||||
~FilePrivate()
|
||||
{
|
||||
delete comment;
|
||||
delete properties;
|
||||
}
|
||||
std::unique_ptr<Ogg::XiphComment> comment;
|
||||
|
||||
FilePrivate(const FilePrivate &) = delete;
|
||||
FilePrivate &operator=(const FilePrivate &) = delete;
|
||||
|
||||
Ogg::XiphComment *comment { nullptr };
|
||||
|
||||
Properties *properties { nullptr };
|
||||
std::unique_ptr<Properties> properties;
|
||||
ByteVector streamInfoData;
|
||||
ByteVector xiphCommentData;
|
||||
offset_t streamStart { 0 };
|
||||
@ -96,7 +86,7 @@ Ogg::FLAC::File::~File() = default;
|
||||
|
||||
Ogg::XiphComment *Ogg::FLAC::File::tag() const
|
||||
{
|
||||
return d->comment;
|
||||
return d->comment.get();
|
||||
}
|
||||
|
||||
PropertyMap Ogg::FLAC::File::properties() const
|
||||
@ -111,10 +101,9 @@ PropertyMap Ogg::FLAC::File::setProperties(const PropertyMap &properties)
|
||||
|
||||
Properties *Ogg::FLAC::File::audioProperties() const
|
||||
{
|
||||
return d->properties;
|
||||
return d->properties.get();
|
||||
}
|
||||
|
||||
|
||||
bool Ogg::FLAC::File::save()
|
||||
{
|
||||
d->xiphCommentData = d->comment->render(false);
|
||||
@ -174,13 +163,12 @@ void Ogg::FLAC::File::read(bool readProperties, Properties::ReadStyle properties
|
||||
|
||||
|
||||
if(d->hasXiphComment)
|
||||
d->comment = new Ogg::XiphComment(xiphCommentData());
|
||||
d->comment = std::make_unique<Ogg::XiphComment>(xiphCommentData());
|
||||
else
|
||||
d->comment = new Ogg::XiphComment();
|
||||
|
||||
d->comment = std::make_unique<Ogg::XiphComment>();
|
||||
|
||||
if(readProperties)
|
||||
d->properties = new Properties(streamInfoData(), streamLength(), propertiesStyle);
|
||||
d->properties = std::make_unique<Properties>(streamInfoData(), streamLength(), propertiesStyle);
|
||||
}
|
||||
|
||||
ByteVector Ogg::FLAC::File::streamInfoData()
|
||||
|
@ -53,19 +53,10 @@ public:
|
||||
pages.setAutoDelete(true);
|
||||
}
|
||||
|
||||
~FilePrivate()
|
||||
{
|
||||
delete firstPageHeader;
|
||||
delete lastPageHeader;
|
||||
}
|
||||
|
||||
FilePrivate(const FilePrivate &) = delete;
|
||||
FilePrivate &operator=(const FilePrivate &) = delete;
|
||||
|
||||
unsigned int streamSerialNumber;
|
||||
List<Page *> pages;
|
||||
PageHeader *firstPageHeader { nullptr };
|
||||
PageHeader *lastPageHeader { nullptr };
|
||||
std::unique_ptr<PageHeader> firstPageHeader;
|
||||
std::unique_ptr<PageHeader> lastPageHeader;
|
||||
Map<unsigned int, ByteVector> dirtyPackets;
|
||||
};
|
||||
|
||||
@ -131,10 +122,10 @@ const Ogg::PageHeader *Ogg::File::firstPageHeader()
|
||||
if(firstPageHeaderOffset < 0)
|
||||
return nullptr;
|
||||
|
||||
d->firstPageHeader = new PageHeader(this, firstPageHeaderOffset);
|
||||
d->firstPageHeader = std::make_unique<PageHeader>(this, firstPageHeaderOffset);
|
||||
}
|
||||
|
||||
return d->firstPageHeader->isValid() ? d->firstPageHeader : nullptr;
|
||||
return d->firstPageHeader->isValid() ? d->firstPageHeader.get() : nullptr;
|
||||
}
|
||||
|
||||
const Ogg::PageHeader *Ogg::File::lastPageHeader()
|
||||
@ -144,10 +135,10 @@ const Ogg::PageHeader *Ogg::File::lastPageHeader()
|
||||
if(lastPageHeaderOffset < 0)
|
||||
return nullptr;
|
||||
|
||||
d->lastPageHeader = new PageHeader(this, lastPageHeaderOffset);
|
||||
d->lastPageHeader = std::make_unique<PageHeader>(this, lastPageHeaderOffset);
|
||||
}
|
||||
|
||||
return d->lastPageHeader->isValid() ? d->lastPageHeader : nullptr;
|
||||
return d->lastPageHeader->isValid() ? d->lastPageHeader.get() : nullptr;
|
||||
}
|
||||
|
||||
bool Ogg::File::save()
|
||||
|
@ -39,18 +39,8 @@ using namespace TagLib::Ogg;
|
||||
class Opus::File::FilePrivate
|
||||
{
|
||||
public:
|
||||
FilePrivate() = default;
|
||||
~FilePrivate()
|
||||
{
|
||||
delete comment;
|
||||
delete properties;
|
||||
}
|
||||
|
||||
FilePrivate(const FilePrivate &) = delete;
|
||||
FilePrivate &operator=(const FilePrivate &) = delete;
|
||||
|
||||
Ogg::XiphComment *comment { nullptr };
|
||||
Properties *properties { nullptr };
|
||||
std::unique_ptr<Ogg::XiphComment> comment;
|
||||
std::unique_ptr<Properties> properties;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -89,7 +79,7 @@ Opus::File::~File() = default;
|
||||
|
||||
Ogg::XiphComment *Opus::File::tag() const
|
||||
{
|
||||
return d->comment;
|
||||
return d->comment.get();
|
||||
}
|
||||
|
||||
PropertyMap Opus::File::properties() const
|
||||
@ -104,13 +94,13 @@ PropertyMap Opus::File::setProperties(const PropertyMap &properties)
|
||||
|
||||
Opus::Properties *Opus::File::audioProperties() const
|
||||
{
|
||||
return d->properties;
|
||||
return d->properties.get();
|
||||
}
|
||||
|
||||
bool Opus::File::save()
|
||||
{
|
||||
if(!d->comment)
|
||||
d->comment = new Ogg::XiphComment();
|
||||
d->comment = std::make_unique<Ogg::XiphComment>();
|
||||
|
||||
setPacket(1, ByteVector("OpusTags", 8) + d->comment->render(false));
|
||||
|
||||
@ -139,8 +129,8 @@ void Opus::File::read(bool readProperties)
|
||||
return;
|
||||
}
|
||||
|
||||
d->comment = new Ogg::XiphComment(commentHeaderData.mid(8));
|
||||
d->comment = std::make_unique<Ogg::XiphComment>(commentHeaderData.mid(8));
|
||||
|
||||
if(readProperties)
|
||||
d->properties = new Properties(this);
|
||||
d->properties = std::make_unique<Properties>(this);
|
||||
}
|
||||
|
@ -39,18 +39,8 @@ using namespace TagLib::Ogg;
|
||||
class Speex::File::FilePrivate
|
||||
{
|
||||
public:
|
||||
FilePrivate() = default;
|
||||
~FilePrivate()
|
||||
{
|
||||
delete comment;
|
||||
delete properties;
|
||||
}
|
||||
|
||||
FilePrivate(const FilePrivate &) = delete;
|
||||
FilePrivate &operator=(const FilePrivate &) = delete;
|
||||
|
||||
Ogg::XiphComment *comment { nullptr };
|
||||
Properties *properties { nullptr };
|
||||
std::unique_ptr<Ogg::XiphComment> comment;
|
||||
std::unique_ptr<Properties> properties;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -89,7 +79,7 @@ Speex::File::~File() = default;
|
||||
|
||||
Ogg::XiphComment *Speex::File::tag() const
|
||||
{
|
||||
return d->comment;
|
||||
return d->comment.get();
|
||||
}
|
||||
|
||||
PropertyMap Speex::File::properties() const
|
||||
@ -104,13 +94,13 @@ PropertyMap Speex::File::setProperties(const PropertyMap &properties)
|
||||
|
||||
Speex::Properties *Speex::File::audioProperties() const
|
||||
{
|
||||
return d->properties;
|
||||
return d->properties.get();
|
||||
}
|
||||
|
||||
bool Speex::File::save()
|
||||
{
|
||||
if(!d->comment)
|
||||
d->comment = new Ogg::XiphComment();
|
||||
d->comment = std::make_unique<Ogg::XiphComment>();
|
||||
|
||||
setPacket(1, d->comment->render());
|
||||
|
||||
@ -133,8 +123,8 @@ void Speex::File::read(bool readProperties)
|
||||
|
||||
ByteVector commentHeaderData = packet(1);
|
||||
|
||||
d->comment = new Ogg::XiphComment(commentHeaderData);
|
||||
d->comment = std::make_unique<Ogg::XiphComment>(commentHeaderData);
|
||||
|
||||
if(readProperties)
|
||||
d->properties = new Properties(this);
|
||||
d->properties = std::make_unique<Properties>(this);
|
||||
}
|
||||
|
@ -34,18 +34,8 @@ using namespace TagLib;
|
||||
class Vorbis::File::FilePrivate
|
||||
{
|
||||
public:
|
||||
FilePrivate() = default;
|
||||
~FilePrivate()
|
||||
{
|
||||
delete comment;
|
||||
delete properties;
|
||||
}
|
||||
|
||||
FilePrivate(const FilePrivate &) = delete;
|
||||
FilePrivate &operator=(const FilePrivate &) = delete;
|
||||
|
||||
Ogg::XiphComment *comment { nullptr };
|
||||
Properties *properties { nullptr };
|
||||
std::unique_ptr<Ogg::XiphComment> comment;
|
||||
std::unique_ptr<Properties> properties;
|
||||
};
|
||||
|
||||
namespace TagLib {
|
||||
@ -92,7 +82,7 @@ Vorbis::File::~File() = default;
|
||||
|
||||
Ogg::XiphComment *Vorbis::File::tag() const
|
||||
{
|
||||
return d->comment;
|
||||
return d->comment.get();
|
||||
}
|
||||
|
||||
PropertyMap Vorbis::File::properties() const
|
||||
@ -107,7 +97,7 @@ PropertyMap Vorbis::File::setProperties(const PropertyMap &properties)
|
||||
|
||||
Vorbis::Properties *Vorbis::File::audioProperties() const
|
||||
{
|
||||
return d->properties;
|
||||
return d->properties.get();
|
||||
}
|
||||
|
||||
bool Vorbis::File::save()
|
||||
@ -115,7 +105,7 @@ bool Vorbis::File::save()
|
||||
ByteVector v(vorbisCommentHeaderID);
|
||||
|
||||
if(!d->comment)
|
||||
d->comment = new Ogg::XiphComment();
|
||||
d->comment = std::make_unique<Ogg::XiphComment>();
|
||||
v.append(d->comment->render());
|
||||
|
||||
setPacket(1, v);
|
||||
@ -137,8 +127,8 @@ void Vorbis::File::read(bool readProperties)
|
||||
return;
|
||||
}
|
||||
|
||||
d->comment = new Ogg::XiphComment(commentHeaderData.mid(7));
|
||||
d->comment = std::make_unique<Ogg::XiphComment>(commentHeaderData.mid(7));
|
||||
|
||||
if(readProperties)
|
||||
d->properties = new Properties(this);
|
||||
d->properties = std::make_unique<Properties>(this);
|
||||
}
|
||||
|
@ -34,18 +34,8 @@ using namespace TagLib;
|
||||
class RIFF::AIFF::File::FilePrivate
|
||||
{
|
||||
public:
|
||||
FilePrivate() = default;
|
||||
~FilePrivate()
|
||||
{
|
||||
delete properties;
|
||||
delete tag;
|
||||
}
|
||||
|
||||
FilePrivate(const FilePrivate &) = delete;
|
||||
FilePrivate &operator=(const FilePrivate &) = delete;
|
||||
|
||||
Properties *properties { nullptr };
|
||||
ID3v2::Tag *tag { nullptr };
|
||||
std::unique_ptr<Properties> properties;
|
||||
std::unique_ptr<ID3v2::Tag> tag;
|
||||
|
||||
bool hasID3v2 { false };
|
||||
};
|
||||
@ -86,7 +76,7 @@ RIFF::AIFF::File::~File() = default;
|
||||
|
||||
ID3v2::Tag *RIFF::AIFF::File::tag() const
|
||||
{
|
||||
return d->tag;
|
||||
return d->tag.get();
|
||||
}
|
||||
|
||||
PropertyMap RIFF::AIFF::File::properties() const
|
||||
@ -106,7 +96,7 @@ PropertyMap RIFF::AIFF::File::setProperties(const PropertyMap &properties)
|
||||
|
||||
RIFF::AIFF::Properties *RIFF::AIFF::File::audioProperties() const
|
||||
{
|
||||
return d->properties;
|
||||
return d->properties.get();
|
||||
}
|
||||
|
||||
bool RIFF::AIFF::File::save()
|
||||
@ -155,7 +145,7 @@ void RIFF::AIFF::File::read(bool readProperties)
|
||||
const ByteVector name = chunkName(i);
|
||||
if(name == "ID3 " || name == "id3 ") {
|
||||
if(!d->tag) {
|
||||
d->tag = new ID3v2::Tag(this, chunkOffset(i));
|
||||
d->tag = std::make_unique<ID3v2::Tag>(this, chunkOffset(i));
|
||||
d->hasID3v2 = true;
|
||||
}
|
||||
else {
|
||||
@ -165,8 +155,8 @@ void RIFF::AIFF::File::read(bool readProperties)
|
||||
}
|
||||
|
||||
if(!d->tag)
|
||||
d->tag = new ID3v2::Tag();
|
||||
d->tag = std::make_unique<ID3v2::Tag>();
|
||||
|
||||
if(readProperties)
|
||||
d->properties = new Properties(this, Properties::Average);
|
||||
d->properties = std::make_unique<Properties>(this, Properties::Average);
|
||||
}
|
||||
|
@ -41,16 +41,7 @@ namespace
|
||||
class RIFF::WAV::File::FilePrivate
|
||||
{
|
||||
public:
|
||||
FilePrivate() = default;
|
||||
~FilePrivate()
|
||||
{
|
||||
delete properties;
|
||||
}
|
||||
|
||||
FilePrivate(const FilePrivate &) = delete;
|
||||
FilePrivate &operator=(const FilePrivate &) = delete;
|
||||
|
||||
Properties *properties { nullptr };
|
||||
std::unique_ptr<Properties> properties;
|
||||
TagUnion tag;
|
||||
|
||||
bool hasID3v2 { false };
|
||||
@ -135,7 +126,7 @@ PropertyMap RIFF::WAV::File::setProperties(const PropertyMap &properties)
|
||||
|
||||
RIFF::WAV::Properties *RIFF::WAV::File::audioProperties() const
|
||||
{
|
||||
return d->properties;
|
||||
return d->properties.get();
|
||||
}
|
||||
|
||||
bool RIFF::WAV::File::save()
|
||||
@ -227,7 +218,7 @@ void RIFF::WAV::File::read(bool readProperties)
|
||||
d->tag.set(InfoIndex, new RIFF::Info::Tag());
|
||||
|
||||
if(readProperties)
|
||||
d->properties = new Properties(this, Properties::Average);
|
||||
d->properties = std::make_unique<Properties>(this, Properties::Average);
|
||||
}
|
||||
|
||||
void RIFF::WAV::File::removeTagChunks(TagTypes tags)
|
||||
|
@ -51,14 +51,6 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
~FilePrivate()
|
||||
{
|
||||
delete properties;
|
||||
}
|
||||
|
||||
FilePrivate(const FilePrivate &) = delete;
|
||||
FilePrivate &operator=(const FilePrivate &) = delete;
|
||||
|
||||
const ID3v2::FrameFactory *ID3v2FrameFactory;
|
||||
offset_t ID3v2Location { -1 };
|
||||
long ID3v2OriginalSize { 0 };
|
||||
@ -67,7 +59,7 @@ public:
|
||||
|
||||
TagUnion tag;
|
||||
|
||||
Properties *properties { nullptr };
|
||||
std::unique_ptr<Properties> properties;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -147,7 +139,7 @@ PropertyMap TrueAudio::File::setProperties(const PropertyMap &properties)
|
||||
|
||||
TrueAudio::Properties *TrueAudio::File::audioProperties() const
|
||||
{
|
||||
return d->properties;
|
||||
return d->properties.get();
|
||||
}
|
||||
|
||||
bool TrueAudio::File::save()
|
||||
@ -294,6 +286,6 @@ void TrueAudio::File::read(bool readProperties)
|
||||
seek(0);
|
||||
}
|
||||
|
||||
d->properties = new Properties(readBlock(TrueAudio::HeaderSize), streamLength);
|
||||
d->properties = std::make_unique<Properties>(readBlock(TrueAudio::HeaderSize), streamLength);
|
||||
}
|
||||
}
|
||||
|
@ -47,15 +47,6 @@ namespace
|
||||
class WavPack::File::FilePrivate
|
||||
{
|
||||
public:
|
||||
FilePrivate() = default;
|
||||
~FilePrivate()
|
||||
{
|
||||
delete properties;
|
||||
}
|
||||
|
||||
FilePrivate(const FilePrivate &) = delete;
|
||||
FilePrivate &operator=(const FilePrivate &) = delete;
|
||||
|
||||
offset_t APELocation { -1 };
|
||||
long APESize { 0 };
|
||||
|
||||
@ -63,7 +54,7 @@ public:
|
||||
|
||||
TagUnion tag;
|
||||
|
||||
Properties *properties { nullptr };
|
||||
std::unique_ptr<Properties> properties;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -125,7 +116,7 @@ PropertyMap WavPack::File::setProperties(const PropertyMap &properties)
|
||||
|
||||
WavPack::Properties *WavPack::File::audioProperties() const
|
||||
{
|
||||
return d->properties;
|
||||
return d->properties.get();
|
||||
}
|
||||
|
||||
bool WavPack::File::save()
|
||||
@ -271,6 +262,6 @@ void WavPack::File::read(bool readProperties)
|
||||
else
|
||||
streamLength = length();
|
||||
|
||||
d->properties = new Properties(this, streamLength);
|
||||
d->properties = std::make_unique<Properties>(this, streamLength);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user