mirror of
https://github.com/taglib/taglib.git
synced 2026-08-14 06:17:00 -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 <[email protected]> * clang-tidy: add missing deleted functions Found with cppcoreguidelines-special-member-functions Signed-off-by: Rosen Penev <[email protected]> * unique_ptr conversions unique_ptr is a safer and cleaner way to handle d pointers. Also added missing = default. Signed-off-by: Rosen Penev <[email protected]> --------- Signed-off-by: Rosen Penev <[email protected]>
This commit is contained in:
@@ -62,6 +62,9 @@ public:
|
||||
delete properties;
|
||||
}
|
||||
|
||||
FilePrivate(const FilePrivate &) = delete;
|
||||
FilePrivate &operator=(const FilePrivate &) = delete;
|
||||
|
||||
offset_t APELocation;
|
||||
long APESize;
|
||||
|
||||
@@ -95,7 +98,7 @@ bool MPC::File::isSupported(IOStream *stream)
|
||||
|
||||
MPC::File::File(FileName file, bool readProperties, Properties::ReadStyle) :
|
||||
TagLib::File(file),
|
||||
d(new FilePrivate())
|
||||
d(std::make_unique<FilePrivate>())
|
||||
{
|
||||
if(isOpen())
|
||||
read(readProperties);
|
||||
@@ -103,16 +106,13 @@ MPC::File::File(FileName file, bool readProperties, Properties::ReadStyle) :
|
||||
|
||||
MPC::File::File(IOStream *stream, bool readProperties, Properties::ReadStyle) :
|
||||
TagLib::File(stream),
|
||||
d(new FilePrivate())
|
||||
d(std::make_unique<FilePrivate>())
|
||||
{
|
||||
if(isOpen())
|
||||
read(readProperties);
|
||||
}
|
||||
|
||||
MPC::File::~File()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
MPC::File::~File() = default;
|
||||
|
||||
TagLib::Tag *MPC::File::tag() const
|
||||
{
|
||||
|
||||
@@ -109,6 +109,9 @@ namespace TagLib {
|
||||
*/
|
||||
~File() override;
|
||||
|
||||
File(const File &) = delete;
|
||||
File &operator=(const File &) = delete;
|
||||
|
||||
/*!
|
||||
* Returns the Tag for this file. This will be an APE tag, an ID3v1 tag
|
||||
* or a combination of the two.
|
||||
@@ -218,13 +221,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 MPC
|
||||
} // namespace TagLib
|
||||
|
||||
@@ -70,7 +70,7 @@ public:
|
||||
|
||||
MPC::Properties::Properties(File *file, offset_t streamLength, ReadStyle style) :
|
||||
AudioProperties(style),
|
||||
d(new PropertiesPrivate())
|
||||
d(std::make_unique<PropertiesPrivate>())
|
||||
{
|
||||
ByteVector magic = file->readBlock(4);
|
||||
if(magic == "MPCK") {
|
||||
@@ -83,10 +83,7 @@ MPC::Properties::Properties(File *file, offset_t streamLength, ReadStyle style)
|
||||
}
|
||||
}
|
||||
|
||||
MPC::Properties::~Properties()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
MPC::Properties::~Properties() = default;
|
||||
|
||||
int MPC::Properties::lengthInMilliseconds() const
|
||||
{
|
||||
|
||||
@@ -59,6 +59,9 @@ namespace TagLib {
|
||||
*/
|
||||
~Properties() override;
|
||||
|
||||
Properties(const Properties &) = delete;
|
||||
Properties &operator=(const Properties &) = delete;
|
||||
|
||||
/*!
|
||||
* Returns the length of the file in milliseconds.
|
||||
*
|
||||
@@ -116,14 +119,11 @@ namespace TagLib {
|
||||
int albumPeak() const;
|
||||
|
||||
private:
|
||||
Properties(const Properties &) = delete;
|
||||
Properties &operator=(const Properties &) = delete;
|
||||
|
||||
void readSV7(const ByteVector &data, offset_t streamLength);
|
||||
void readSV8(File *file, offset_t streamLength);
|
||||
|
||||
class PropertiesPrivate;
|
||||
PropertiesPrivate *d;
|
||||
std::unique_ptr<PropertiesPrivate> d;
|
||||
};
|
||||
} // namespace MPC
|
||||
} // namespace TagLib
|
||||
|
||||
Reference in New Issue
Block a user