mirror of
https://github.com/taglib/taglib.git
synced 2026-04-07 22:52:45 -04:00
Use unique_ptr for d-pointers (#1095)
* clang-tidy: make deleted members public One oversight of modernize-use-equals-delete is that the C++11 way of doing this is to make it public, which makes the warning still trigger. Signed-off-by: Rosen Penev <rosenp@gmail.com> * clang-tidy: add missing deleted functions Found with cppcoreguidelines-special-member-functions Signed-off-by: Rosen Penev <rosenp@gmail.com> * unique_ptr conversions unique_ptr is a safer and cleaner way to handle d pointers. Also added missing = default. Signed-off-by: Rosen Penev <rosenp@gmail.com> --------- Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
@ -54,6 +54,9 @@ public:
|
||||
delete properties;
|
||||
}
|
||||
|
||||
FilePrivate(const FilePrivate &) = delete;
|
||||
FilePrivate &operator=(const FilePrivate &) = delete;
|
||||
|
||||
Ogg::XiphComment *comment;
|
||||
|
||||
Properties *properties;
|
||||
@ -86,7 +89,7 @@ bool Ogg::FLAC::File::isSupported(IOStream *stream)
|
||||
Ogg::FLAC::File::File(FileName file, bool readProperties,
|
||||
Properties::ReadStyle propertiesStyle) :
|
||||
Ogg::File(file),
|
||||
d(new FilePrivate())
|
||||
d(std::make_unique<FilePrivate>())
|
||||
{
|
||||
if(isOpen())
|
||||
read(readProperties, propertiesStyle);
|
||||
@ -95,16 +98,13 @@ Ogg::FLAC::File::File(FileName file, bool readProperties,
|
||||
Ogg::FLAC::File::File(IOStream *stream, bool readProperties,
|
||||
Properties::ReadStyle propertiesStyle) :
|
||||
Ogg::File(stream),
|
||||
d(new FilePrivate())
|
||||
d(std::make_unique<FilePrivate>())
|
||||
{
|
||||
if(isOpen())
|
||||
read(readProperties, propertiesStyle);
|
||||
}
|
||||
|
||||
Ogg::FLAC::File::~File()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
Ogg::FLAC::File::~File() = default;
|
||||
|
||||
Ogg::XiphComment *Ogg::FLAC::File::tag() const
|
||||
{
|
||||
|
||||
@ -89,6 +89,9 @@ namespace TagLib {
|
||||
*/
|
||||
~File() override;
|
||||
|
||||
File(const File &) = delete;
|
||||
File &operator=(const File &) = delete;
|
||||
|
||||
/*!
|
||||
* Returns the Tag for this file. This will always be a XiphComment.
|
||||
*
|
||||
@ -152,16 +155,13 @@ namespace TagLib {
|
||||
static bool isSupported(IOStream *stream);
|
||||
|
||||
private:
|
||||
File(const File &) = delete;
|
||||
File &operator=(const File &) = delete;
|
||||
|
||||
void read(bool readProperties, Properties::ReadStyle propertiesStyle);
|
||||
void scan();
|
||||
ByteVector streamInfoData();
|
||||
ByteVector xiphCommentData();
|
||||
|
||||
class FilePrivate;
|
||||
FilePrivate *d;
|
||||
std::unique_ptr<FilePrivate> d;
|
||||
};
|
||||
} // namespace FLAC
|
||||
} // namespace Ogg
|
||||
|
||||
@ -62,6 +62,9 @@ public:
|
||||
delete lastPageHeader;
|
||||
}
|
||||
|
||||
FilePrivate(const FilePrivate &) = delete;
|
||||
FilePrivate &operator=(const FilePrivate &) = delete;
|
||||
|
||||
unsigned int streamSerialNumber;
|
||||
List<Page *> pages;
|
||||
PageHeader *firstPageHeader;
|
||||
@ -73,10 +76,7 @@ public:
|
||||
// public members
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Ogg::File::~File()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
Ogg::File::~File() = default;
|
||||
|
||||
ByteVector Ogg::File::packet(unsigned int i)
|
||||
{
|
||||
@ -175,13 +175,13 @@ bool Ogg::File::save()
|
||||
|
||||
Ogg::File::File(FileName file) :
|
||||
TagLib::File(file),
|
||||
d(new FilePrivate())
|
||||
d(std::make_unique<FilePrivate>())
|
||||
{
|
||||
}
|
||||
|
||||
Ogg::File::File(IOStream *stream) :
|
||||
TagLib::File(stream),
|
||||
d(new FilePrivate())
|
||||
d(std::make_unique<FilePrivate>())
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -52,6 +52,9 @@ namespace TagLib {
|
||||
public:
|
||||
~File() override;
|
||||
|
||||
File(const File &) = delete;
|
||||
File &operator=(const File &) = delete;
|
||||
|
||||
/*!
|
||||
* Returns the packet contents for the i-th packet (starting from zero)
|
||||
* in the Ogg bitstream.
|
||||
@ -103,9 +106,6 @@ namespace TagLib {
|
||||
File(IOStream *stream);
|
||||
|
||||
private:
|
||||
File(const File &) = delete;
|
||||
File &operator=(const File &) = delete;
|
||||
|
||||
/*!
|
||||
* Reads the pages from the beginning of the file until enough to compose
|
||||
* the requested packet.
|
||||
@ -118,7 +118,7 @@ namespace TagLib {
|
||||
void writePacket(unsigned int i, const ByteVector &packet);
|
||||
|
||||
class FilePrivate;
|
||||
FilePrivate *d;
|
||||
std::unique_ptr<FilePrivate> d;
|
||||
};
|
||||
|
||||
} // namespace Ogg
|
||||
|
||||
@ -120,14 +120,11 @@ public:
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Ogg::Page::Page(Ogg::File *file, offset_t pageOffset) :
|
||||
d(new PagePrivate(file, pageOffset))
|
||||
d(std::make_unique<PagePrivate>(file, pageOffset))
|
||||
{
|
||||
}
|
||||
|
||||
Ogg::Page::~Page()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
Ogg::Page::~Page() = default;
|
||||
|
||||
offset_t Ogg::Page::fileOffset() const
|
||||
{
|
||||
@ -342,7 +339,7 @@ Ogg::Page::Page(const ByteVectorList &packets,
|
||||
bool firstPacketContinued,
|
||||
bool lastPacketCompleted,
|
||||
bool containsLastPacket) :
|
||||
d(new PagePrivate())
|
||||
d(std::make_unique<PagePrivate>())
|
||||
{
|
||||
d->header.setFirstPageOfStream(pageNumber == 0 && !firstPacketContinued);
|
||||
d->header.setLastPageOfStream(containsLastPacket);
|
||||
|
||||
@ -59,6 +59,9 @@ namespace TagLib {
|
||||
|
||||
virtual ~Page();
|
||||
|
||||
Page(const Page &) = delete;
|
||||
Page &operator=(const Page &) = delete;
|
||||
|
||||
/*!
|
||||
* Returns the page's position within the file (in bytes).
|
||||
*/
|
||||
@ -207,11 +210,8 @@ namespace TagLib {
|
||||
bool containsLastPacket = false);
|
||||
|
||||
private:
|
||||
Page(const Page &) = delete;
|
||||
Page &operator=(const Page &) = delete;
|
||||
|
||||
class PagePrivate;
|
||||
PagePrivate *d;
|
||||
std::unique_ptr<PagePrivate> d;
|
||||
};
|
||||
} // namespace Ogg
|
||||
} // namespace TagLib
|
||||
|
||||
@ -68,16 +68,13 @@ public:
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Ogg::PageHeader::PageHeader(Ogg::File *file, offset_t pageOffset) :
|
||||
d(new PageHeaderPrivate())
|
||||
d(std::make_unique<PageHeaderPrivate>())
|
||||
{
|
||||
if(file && pageOffset >= 0)
|
||||
read(file, pageOffset);
|
||||
}
|
||||
|
||||
Ogg::PageHeader::~PageHeader()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
Ogg::PageHeader::~PageHeader() = default;
|
||||
|
||||
bool Ogg::PageHeader::isValid() const
|
||||
{
|
||||
|
||||
@ -59,6 +59,9 @@ namespace TagLib {
|
||||
*/
|
||||
virtual ~PageHeader();
|
||||
|
||||
PageHeader(const PageHeader &) = delete;
|
||||
PageHeader &operator=(const PageHeader &) = delete;
|
||||
|
||||
/*!
|
||||
* Returns true if the header parsed properly and is valid.
|
||||
*/
|
||||
@ -216,14 +219,11 @@ namespace TagLib {
|
||||
ByteVector render() const;
|
||||
|
||||
private:
|
||||
PageHeader(const PageHeader &) = delete;
|
||||
PageHeader &operator=(const PageHeader &) = delete;
|
||||
|
||||
void read(Ogg::File *file, offset_t pageOffset);
|
||||
ByteVector lacingValues() const;
|
||||
|
||||
class PageHeaderPrivate;
|
||||
PageHeaderPrivate *d;
|
||||
std::unique_ptr<PageHeaderPrivate> d;
|
||||
};
|
||||
|
||||
} // namespace Ogg
|
||||
|
||||
@ -50,6 +50,9 @@ public:
|
||||
delete properties;
|
||||
}
|
||||
|
||||
FilePrivate(const FilePrivate &) = delete;
|
||||
FilePrivate &operator=(const FilePrivate &) = delete;
|
||||
|
||||
Ogg::XiphComment *comment;
|
||||
Properties *properties;
|
||||
};
|
||||
@ -72,7 +75,7 @@ bool Ogg::Opus::File::isSupported(IOStream *stream)
|
||||
|
||||
Opus::File::File(FileName file, bool readProperties, Properties::ReadStyle) :
|
||||
Ogg::File(file),
|
||||
d(new FilePrivate())
|
||||
d(std::make_unique<FilePrivate>())
|
||||
{
|
||||
if(isOpen())
|
||||
read(readProperties);
|
||||
@ -80,16 +83,13 @@ Opus::File::File(FileName file, bool readProperties, Properties::ReadStyle) :
|
||||
|
||||
Opus::File::File(IOStream *stream, bool readProperties, Properties::ReadStyle) :
|
||||
Ogg::File(stream),
|
||||
d(new FilePrivate())
|
||||
d(std::make_unique<FilePrivate>())
|
||||
{
|
||||
if(isOpen())
|
||||
read(readProperties);
|
||||
}
|
||||
|
||||
Opus::File::~File()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
Opus::File::~File() = default;
|
||||
|
||||
Ogg::XiphComment *Opus::File::tag() const
|
||||
{
|
||||
|
||||
@ -81,6 +81,9 @@ namespace TagLib {
|
||||
*/
|
||||
~File() override;
|
||||
|
||||
File(const File &) = delete;
|
||||
File &operator=(const File &) = delete;
|
||||
|
||||
/*!
|
||||
* Returns the XiphComment for this file. XiphComment implements the tag
|
||||
* interface, so this serves as the reimplementation of
|
||||
@ -123,13 +126,10 @@ namespace TagLib {
|
||||
static bool isSupported(IOStream *stream);
|
||||
|
||||
private:
|
||||
File(const File &) = delete;
|
||||
File &operator=(const File &) = delete;
|
||||
|
||||
void read(bool readProperties);
|
||||
|
||||
class FilePrivate;
|
||||
FilePrivate *d;
|
||||
std::unique_ptr<FilePrivate> d;
|
||||
};
|
||||
} // namespace Opus
|
||||
} // namespace Ogg
|
||||
|
||||
@ -62,15 +62,12 @@ public:
|
||||
|
||||
Opus::Properties::Properties(File *file, ReadStyle style) :
|
||||
AudioProperties(style),
|
||||
d(new PropertiesPrivate())
|
||||
d(std::make_unique<PropertiesPrivate>())
|
||||
{
|
||||
read(file);
|
||||
}
|
||||
|
||||
Opus::Properties::~Properties()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
Opus::Properties::~Properties() = default;
|
||||
|
||||
int Ogg::Opus::Properties::lengthInMilliseconds() const
|
||||
{
|
||||
|
||||
@ -61,6 +61,9 @@ namespace TagLib {
|
||||
*/
|
||||
~Properties() override;
|
||||
|
||||
Properties(const Properties &) = delete;
|
||||
Properties &operator=(const Properties &) = delete;
|
||||
|
||||
/*!
|
||||
* Returns the length of the file in milliseconds.
|
||||
*
|
||||
@ -99,13 +102,10 @@ namespace TagLib {
|
||||
int opusVersion() const;
|
||||
|
||||
private:
|
||||
Properties(const Properties &) = delete;
|
||||
Properties &operator=(const Properties &) = delete;
|
||||
|
||||
void read(File *file);
|
||||
|
||||
class PropertiesPrivate;
|
||||
PropertiesPrivate *d;
|
||||
std::unique_ptr<PropertiesPrivate> d;
|
||||
};
|
||||
} // namespace Opus
|
||||
} // namespace Ogg
|
||||
|
||||
@ -50,6 +50,9 @@ public:
|
||||
delete properties;
|
||||
}
|
||||
|
||||
FilePrivate(const FilePrivate &) = delete;
|
||||
FilePrivate &operator=(const FilePrivate &) = delete;
|
||||
|
||||
Ogg::XiphComment *comment;
|
||||
Properties *properties;
|
||||
};
|
||||
@ -72,7 +75,7 @@ bool Ogg::Speex::File::isSupported(IOStream *stream)
|
||||
|
||||
Speex::File::File(FileName file, bool readProperties, Properties::ReadStyle) :
|
||||
Ogg::File(file),
|
||||
d(new FilePrivate())
|
||||
d(std::make_unique<FilePrivate>())
|
||||
{
|
||||
if(isOpen())
|
||||
read(readProperties);
|
||||
@ -80,16 +83,13 @@ Speex::File::File(FileName file, bool readProperties, Properties::ReadStyle) :
|
||||
|
||||
Speex::File::File(IOStream *stream, bool readProperties, Properties::ReadStyle) :
|
||||
Ogg::File(stream),
|
||||
d(new FilePrivate())
|
||||
d(std::make_unique<FilePrivate>())
|
||||
{
|
||||
if(isOpen())
|
||||
read(readProperties);
|
||||
}
|
||||
|
||||
Speex::File::~File()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
Speex::File::~File() = default;
|
||||
|
||||
Ogg::XiphComment *Speex::File::tag() const
|
||||
{
|
||||
|
||||
@ -81,6 +81,9 @@ namespace TagLib {
|
||||
*/
|
||||
~File() override;
|
||||
|
||||
File(const File &) = delete;
|
||||
File &operator=(const File &) = delete;
|
||||
|
||||
/*!
|
||||
* Returns the XiphComment for this file. XiphComment implements the tag
|
||||
* interface, so this serves as the reimplementation of
|
||||
@ -123,13 +126,10 @@ namespace TagLib {
|
||||
static bool isSupported(IOStream *stream);
|
||||
|
||||
private:
|
||||
File(const File &) = delete;
|
||||
File &operator=(const File &) = delete;
|
||||
|
||||
void read(bool readProperties);
|
||||
|
||||
class FilePrivate;
|
||||
FilePrivate *d;
|
||||
std::unique_ptr<FilePrivate> d;
|
||||
};
|
||||
} // namespace Speex
|
||||
} // namespace Ogg
|
||||
|
||||
@ -68,15 +68,12 @@ public:
|
||||
|
||||
Speex::Properties::Properties(File *file, ReadStyle style) :
|
||||
AudioProperties(style),
|
||||
d(new PropertiesPrivate())
|
||||
d(std::make_unique<PropertiesPrivate>())
|
||||
{
|
||||
read(file);
|
||||
}
|
||||
|
||||
Speex::Properties::~Properties()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
Speex::Properties::~Properties() = default;
|
||||
|
||||
int Speex::Properties::lengthInMilliseconds() const
|
||||
{
|
||||
|
||||
@ -61,6 +61,9 @@ namespace TagLib {
|
||||
*/
|
||||
~Properties() override;
|
||||
|
||||
Properties(const Properties &) = delete;
|
||||
Properties &operator=(const Properties &) = delete;
|
||||
|
||||
/*!
|
||||
* Returns the length of the file in milliseconds.
|
||||
*
|
||||
@ -94,13 +97,10 @@ namespace TagLib {
|
||||
int speexVersion() const;
|
||||
|
||||
private:
|
||||
Properties(const Properties &) = delete;
|
||||
Properties &operator=(const Properties &) = delete;
|
||||
|
||||
void read(File *file);
|
||||
|
||||
class PropertiesPrivate;
|
||||
PropertiesPrivate *d;
|
||||
std::unique_ptr<PropertiesPrivate> d;
|
||||
};
|
||||
} // namespace Speex
|
||||
} // namespace Ogg
|
||||
|
||||
@ -47,6 +47,9 @@ public:
|
||||
delete properties;
|
||||
}
|
||||
|
||||
FilePrivate(const FilePrivate &) = delete;
|
||||
FilePrivate &operator=(const FilePrivate &) = delete;
|
||||
|
||||
Ogg::XiphComment *comment;
|
||||
Properties *properties;
|
||||
};
|
||||
@ -77,7 +80,7 @@ bool Vorbis::File::isSupported(IOStream *stream)
|
||||
|
||||
Vorbis::File::File(FileName file, bool readProperties, Properties::ReadStyle) :
|
||||
Ogg::File(file),
|
||||
d(new FilePrivate())
|
||||
d(std::make_unique<FilePrivate>())
|
||||
{
|
||||
if(isOpen())
|
||||
read(readProperties);
|
||||
@ -85,16 +88,13 @@ Vorbis::File::File(FileName file, bool readProperties, Properties::ReadStyle) :
|
||||
|
||||
Vorbis::File::File(IOStream *stream, bool readProperties, Properties::ReadStyle) :
|
||||
Ogg::File(stream),
|
||||
d(new FilePrivate())
|
||||
d(std::make_unique<FilePrivate>())
|
||||
{
|
||||
if(isOpen())
|
||||
read(readProperties);
|
||||
}
|
||||
|
||||
Vorbis::File::~File()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
Vorbis::File::~File() = default;
|
||||
|
||||
Ogg::XiphComment *Vorbis::File::tag() const
|
||||
{
|
||||
|
||||
@ -90,6 +90,9 @@ namespace TagLib {
|
||||
*/
|
||||
~File() override;
|
||||
|
||||
File(const File &) = delete;
|
||||
File &operator=(const File &) = delete;
|
||||
|
||||
/*!
|
||||
* Returns the XiphComment for this file. XiphComment implements the tag
|
||||
* interface, so this serves as the reimplementation of
|
||||
@ -132,13 +135,10 @@ namespace TagLib {
|
||||
static bool isSupported(IOStream *stream);
|
||||
|
||||
private:
|
||||
File(const File &) = delete;
|
||||
File &operator=(const File &) = delete;
|
||||
|
||||
void read(bool readProperties);
|
||||
|
||||
class FilePrivate;
|
||||
FilePrivate *d;
|
||||
std::unique_ptr<FilePrivate> d;
|
||||
};
|
||||
} // namespace Vorbis
|
||||
|
||||
|
||||
@ -71,15 +71,12 @@ namespace TagLib {
|
||||
|
||||
Vorbis::Properties::Properties(File *file, ReadStyle style) :
|
||||
AudioProperties(style),
|
||||
d(new PropertiesPrivate())
|
||||
d(std::make_unique<PropertiesPrivate>())
|
||||
{
|
||||
read(file);
|
||||
}
|
||||
|
||||
Vorbis::Properties::~Properties()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
Vorbis::Properties::~Properties() = default;
|
||||
|
||||
int Vorbis::Properties::lengthInMilliseconds() const
|
||||
{
|
||||
|
||||
@ -69,6 +69,9 @@ namespace TagLib {
|
||||
*/
|
||||
~Properties() override;
|
||||
|
||||
Properties(const Properties &) = delete;
|
||||
Properties &operator=(const Properties &) = delete;
|
||||
|
||||
/*!
|
||||
* Returns the length of the file in milliseconds.
|
||||
*
|
||||
@ -115,13 +118,10 @@ namespace TagLib {
|
||||
int bitrateMinimum() const;
|
||||
|
||||
private:
|
||||
Properties(const Properties &) = delete;
|
||||
Properties &operator=(const Properties &) = delete;
|
||||
|
||||
void read(File *file);
|
||||
|
||||
class PropertiesPrivate;
|
||||
PropertiesPrivate *d;
|
||||
std::unique_ptr<PropertiesPrivate> d;
|
||||
};
|
||||
} // namespace Vorbis
|
||||
|
||||
|
||||
@ -62,20 +62,17 @@ public:
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Ogg::XiphComment::XiphComment() :
|
||||
d(new XiphCommentPrivate())
|
||||
d(std::make_unique<XiphCommentPrivate>())
|
||||
{
|
||||
}
|
||||
|
||||
Ogg::XiphComment::XiphComment(const ByteVector &data) :
|
||||
d(new XiphCommentPrivate())
|
||||
d(std::make_unique<XiphCommentPrivate>())
|
||||
{
|
||||
parse(data);
|
||||
}
|
||||
|
||||
Ogg::XiphComment::~XiphComment()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
Ogg::XiphComment::~XiphComment() = default;
|
||||
|
||||
String Ogg::XiphComment::title() const
|
||||
{
|
||||
|
||||
@ -85,6 +85,9 @@ namespace TagLib {
|
||||
*/
|
||||
~XiphComment() override;
|
||||
|
||||
XiphComment(const XiphComment &) = delete;
|
||||
XiphComment &operator=(const XiphComment &) = delete;
|
||||
|
||||
String title() const override;
|
||||
String artist() const override;
|
||||
String album() const override;
|
||||
@ -254,11 +257,8 @@ namespace TagLib {
|
||||
void parse(const ByteVector &data);
|
||||
|
||||
private:
|
||||
XiphComment(const XiphComment &) = delete;
|
||||
XiphComment &operator=(const XiphComment &) = delete;
|
||||
|
||||
class XiphCommentPrivate;
|
||||
XiphCommentPrivate *d;
|
||||
std::unique_ptr<XiphCommentPrivate> d;
|
||||
};
|
||||
} // namespace Ogg
|
||||
} // namespace TagLib
|
||||
|
||||
Reference in New Issue
Block a user