diff --git a/taglib/ape/apefile.cpp b/taglib/ape/apefile.cpp index 77389c42..78aed40a 100644 --- a/taglib/ape/apefile.cpp +++ b/taglib/ape/apefile.cpp @@ -70,6 +70,9 @@ public: delete properties; } + FilePrivate(const FilePrivate &) = delete; + FilePrivate &operator=(const FilePrivate &) = delete; + offset_t APELocation; long APESize; @@ -102,7 +105,7 @@ bool APE::File::isSupported(IOStream *stream) APE::File::File(FileName file, bool readProperties, Properties::ReadStyle) : TagLib::File(file), - d(new FilePrivate()) + d(std::make_unique()) { if(isOpen()) read(readProperties); @@ -110,16 +113,13 @@ APE::File::File(FileName file, bool readProperties, Properties::ReadStyle) : APE::File::File(IOStream *stream, bool readProperties, Properties::ReadStyle) : TagLib::File(stream), - d(new FilePrivate()) + d(std::make_unique()) { if(isOpen()) read(readProperties); } -APE::File::~File() -{ - delete d; -} +APE::File::~File() = default; TagLib::Tag *APE::File::tag() const { diff --git a/taglib/ape/apefile.h b/taglib/ape/apefile.h index 199cd509..72eedf64 100644 --- a/taglib/ape/apefile.h +++ b/taglib/ape/apefile.h @@ -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. @@ -221,13 +224,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 d; }; } // namespace APE } // namespace TagLib diff --git a/taglib/ape/apefooter.cpp b/taglib/ape/apefooter.cpp index 76834566..d9300c63 100644 --- a/taglib/ape/apefooter.cpp +++ b/taglib/ape/apefooter.cpp @@ -76,20 +76,17 @@ ByteVector APE::Footer::fileIdentifier() //////////////////////////////////////////////////////////////////////////////// APE::Footer::Footer() : - d(new FooterPrivate()) + d(std::make_unique()) { } APE::Footer::Footer(const ByteVector &data) : - d(new FooterPrivate()) + d(std::make_unique()) { parse(data); } -APE::Footer::~Footer() -{ - delete d; -} +APE::Footer::~Footer() = default; unsigned int APE::Footer::version() const { diff --git a/taglib/ape/apefooter.h b/taglib/ape/apefooter.h index 6b495e62..7db6ce85 100644 --- a/taglib/ape/apefooter.h +++ b/taglib/ape/apefooter.h @@ -61,6 +61,9 @@ namespace TagLib { */ virtual ~Footer(); + Footer(const Footer &) = delete; + Footer &operator=(const Footer &) = delete; + /*! * Returns the version number. (Note: This is the 1000 or 2000.) */ @@ -160,11 +163,8 @@ namespace TagLib { ByteVector render(bool isHeader) const; private: - Footer(const Footer &) = delete; - Footer &operator=(const Footer &) = delete; - class FooterPrivate; - FooterPrivate *d; + std::unique_ptr d; }; } // namespace APE diff --git a/taglib/ape/apeitem.cpp b/taglib/ape/apeitem.cpp index 92468be2..ae7c100f 100644 --- a/taglib/ape/apeitem.cpp +++ b/taglib/ape/apeitem.cpp @@ -50,19 +50,19 @@ public: //////////////////////////////////////////////////////////////////////////////// APE::Item::Item() : - d(new ItemPrivate()) + d(std::make_unique()) { } APE::Item::Item(const String &key, const StringList &values) : - d(new ItemPrivate()) + d(std::make_unique()) { d->key = key; d->text = values; } APE::Item::Item(const String &key, const ByteVector &value, bool binary) : - d(new ItemPrivate()) + d(std::make_unique()) { d->key = key; if(binary) { @@ -75,14 +75,11 @@ APE::Item::Item(const String &key, const ByteVector &value, bool binary) : } APE::Item::Item(const Item &item) : - d(new ItemPrivate(*item.d)) + d(std::make_unique(*item.d)) { } -APE::Item::~Item() -{ - delete d; -} +APE::Item::~Item() = default; Item &APE::Item::operator=(const Item &item) { diff --git a/taglib/ape/apeitem.h b/taglib/ape/apeitem.h index fe69aefd..a1f24192 100644 --- a/taglib/ape/apeitem.h +++ b/taglib/ape/apeitem.h @@ -205,7 +205,7 @@ namespace TagLib { private: class ItemPrivate; - ItemPrivate *d; + std::unique_ptr d; }; } // namespace APE } // namespace TagLib diff --git a/taglib/ape/apeproperties.cpp b/taglib/ape/apeproperties.cpp index ad1a8640..d836cb52 100644 --- a/taglib/ape/apeproperties.cpp +++ b/taglib/ape/apeproperties.cpp @@ -65,15 +65,12 @@ public: APE::Properties::Properties(File *file, offset_t streamLength, ReadStyle style) : AudioProperties(style), - d(new PropertiesPrivate()) + d(std::make_unique()) { read(file, streamLength); } -APE::Properties::~Properties() -{ - delete d; -} +APE::Properties::~Properties() = default; int APE::Properties::lengthInMilliseconds() const { diff --git a/taglib/ape/apeproperties.h b/taglib/ape/apeproperties.h index 831d3ac5..ec284a12 100644 --- a/taglib/ape/apeproperties.h +++ b/taglib/ape/apeproperties.h @@ -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,16 +102,13 @@ namespace TagLib { int version() const; private: - Properties(const Properties &) = delete; - Properties &operator=(const Properties &) = delete; - void read(File *file, offset_t streamLength); void analyzeCurrent(File *file); void analyzeOld(File *file); class PropertiesPrivate; - PropertiesPrivate *d; + std::unique_ptr d; }; } // namespace APE } // namespace TagLib diff --git a/taglib/ape/apetag.cpp b/taglib/ape/apetag.cpp index 352281c7..58d9a479 100644 --- a/taglib/ape/apetag.cpp +++ b/taglib/ape/apetag.cpp @@ -94,12 +94,12 @@ public: //////////////////////////////////////////////////////////////////////////////// APE::Tag::Tag() : - d(new TagPrivate()) + d(std::make_unique()) { } APE::Tag::Tag(TagLib::File *file, offset_t footerLocation) : - d(new TagPrivate()) + d(std::make_unique()) { d->file = file; d->footerLocation = footerLocation; @@ -107,10 +107,7 @@ APE::Tag::Tag(TagLib::File *file, offset_t footerLocation) : read(); } -APE::Tag::~Tag() -{ - delete d; -} +APE::Tag::~Tag() = default; ByteVector APE::Tag::fileIdentifier() { diff --git a/taglib/ape/apetag.h b/taglib/ape/apetag.h index 486d2b52..179a1cd4 100644 --- a/taglib/ape/apetag.h +++ b/taglib/ape/apetag.h @@ -73,6 +73,9 @@ namespace TagLib { */ ~Tag() override; + Tag(const Tag &) = delete; + Tag &operator=(const Tag &) = delete; + /*! * Renders the in memory values to a ByteVector suitable for writing to * the file. @@ -196,11 +199,8 @@ namespace TagLib { void parse(const ByteVector &data); private: - Tag(const Tag &) = delete; - Tag &operator=(const Tag &) = delete; - class TagPrivate; - TagPrivate *d; + std::unique_ptr d; }; } // namespace APE } // namespace TagLib diff --git a/taglib/asf/asffile.cpp b/taglib/asf/asffile.cpp index 9184b5b4..cf114add 100644 --- a/taglib/asf/asffile.cpp +++ b/taglib/asf/asffile.cpp @@ -70,6 +70,9 @@ public: delete properties; } + FilePrivate(const FilePrivate &) = delete; + FilePrivate &operator=(const FilePrivate &) = delete; + unsigned long long headerSize; ASF::Tag *tag; @@ -490,7 +493,7 @@ bool ASF::File::isSupported(IOStream *stream) ASF::File::File(FileName file, bool, Properties::ReadStyle) : TagLib::File(file), - d(new FilePrivate()) + d(std::make_unique()) { if(isOpen()) read(); @@ -498,16 +501,13 @@ ASF::File::File(FileName file, bool, Properties::ReadStyle) : ASF::File::File(IOStream *stream, bool, Properties::ReadStyle) : TagLib::File(stream), - d(new FilePrivate()) + d(std::make_unique()) { if(isOpen()) read(); } -ASF::File::~File() -{ - delete d; -} +ASF::File::~File() = default; ASF::Tag *ASF::File::tag() const { diff --git a/taglib/asf/asffile.h b/taglib/asf/asffile.h index 16d12cd3..ee241dc2 100644 --- a/taglib/asf/asffile.h +++ b/taglib/asf/asffile.h @@ -73,6 +73,9 @@ namespace TagLib { */ ~File() override; + File(const File &) = delete; + File &operator=(const File &) = delete; + /*! * Returns a pointer to the ASF tag of the file. * @@ -126,7 +129,7 @@ namespace TagLib { void read(); class FilePrivate; - FilePrivate *d; + std::unique_ptr d; }; } // namespace ASF } // namespace TagLib diff --git a/taglib/asf/asfproperties.cpp b/taglib/asf/asfproperties.cpp index 4ad525ad..b613af80 100644 --- a/taglib/asf/asfproperties.cpp +++ b/taglib/asf/asfproperties.cpp @@ -58,14 +58,11 @@ public: ASF::Properties::Properties() : AudioProperties(AudioProperties::Average), - d(new PropertiesPrivate()) + d(std::make_unique()) { } -ASF::Properties::~Properties() -{ - delete d; -} +ASF::Properties::~Properties() = default; int ASF::Properties::lengthInMilliseconds() const { diff --git a/taglib/asf/asfproperties.h b/taglib/asf/asfproperties.h index 6efb8ad3..17467a04 100644 --- a/taglib/asf/asfproperties.h +++ b/taglib/asf/asfproperties.h @@ -78,6 +78,9 @@ namespace TagLib { */ ~Properties() override; + Properties(const Properties &) = delete; + Properties &operator=(const Properties &) = delete; + /*! * Returns the length of the file in milliseconds. * @@ -151,7 +154,7 @@ namespace TagLib { private: class PropertiesPrivate; - PropertiesPrivate *d; + std::unique_ptr d; }; } // namespace ASF } // namespace TagLib diff --git a/taglib/asf/asftag.cpp b/taglib/asf/asftag.cpp index 1a824316..4cbf1e73 100644 --- a/taglib/asf/asftag.cpp +++ b/taglib/asf/asftag.cpp @@ -42,14 +42,11 @@ public: }; ASF::Tag::Tag() : - d(new TagPrivate()) + d(std::make_unique()) { } -ASF::Tag::~Tag() -{ - delete d; -} +ASF::Tag::~Tag() = default; String ASF::Tag::title() const { diff --git a/taglib/asf/asftag.h b/taglib/asf/asftag.h index c19f6deb..c8b0e6bc 100644 --- a/taglib/asf/asftag.h +++ b/taglib/asf/asftag.h @@ -49,6 +49,9 @@ namespace TagLib { ~Tag() override; + Tag(const Tag &) = delete; + Tag &operator=(const Tag &) = delete; + /*! * Returns the track name. */ @@ -204,7 +207,7 @@ namespace TagLib { private: class TagPrivate; - TagPrivate *d; + std::unique_ptr d; }; } // namespace ASF } // namespace TagLib diff --git a/taglib/audioproperties.cpp b/taglib/audioproperties.cpp index 09e6af3e..61ef9baa 100644 --- a/taglib/audioproperties.cpp +++ b/taglib/audioproperties.cpp @@ -29,7 +29,6 @@ using namespace TagLib; class AudioProperties::AudioPropertiesPrivate { - }; //////////////////////////////////////////////////////////////////////////////// @@ -67,8 +66,6 @@ int AudioProperties::sampleRate() const // protected methods //////////////////////////////////////////////////////////////////////////////// -AudioProperties::AudioProperties(ReadStyle) : - d(nullptr) +AudioProperties::AudioProperties(ReadStyle) { - } diff --git a/taglib/audioproperties.h b/taglib/audioproperties.h index be3c4310..a2df2f46 100644 --- a/taglib/audioproperties.h +++ b/taglib/audioproperties.h @@ -28,6 +28,8 @@ #include "taglib_export.h" +#include + namespace TagLib { //! A simple, abstract interface to common audio properties @@ -64,6 +66,9 @@ namespace TagLib { */ virtual ~AudioProperties(); + AudioProperties(const AudioProperties &) = delete; + AudioProperties &operator=(const AudioProperties &) = delete; + /*! * Returns the length of the file in seconds. The length is rounded down to * the nearest whole second. @@ -118,11 +123,8 @@ namespace TagLib { AudioProperties(ReadStyle style); private: - AudioProperties(const AudioProperties &) = delete; - AudioProperties &operator=(const AudioProperties &) = delete; - class AudioPropertiesPrivate; - AudioPropertiesPrivate *d; + std::unique_ptr d; }; } // namespace TagLib diff --git a/taglib/fileref.cpp b/taglib/fileref.cpp index 75172d28..ca367887 100644 --- a/taglib/fileref.cpp +++ b/taglib/fileref.cpp @@ -57,6 +57,14 @@ using namespace TagLib; +class FileRef::FileTypeResolver::FileTypeResolverPrivate +{ +}; + +class FileRef::StreamTypeResolver::StreamTypeResolverPrivate +{ +}; + namespace { typedef List ResolverList; @@ -304,6 +312,9 @@ public: delete stream; } + FileRefPrivate(const FileRefPrivate &) = delete; + FileRefPrivate &operator=(const FileRefPrivate &) = delete; + File *file; IOStream *stream; }; @@ -509,6 +520,8 @@ void FileRef::parse(IOStream *stream, bool readAudioProperties, d->file = detectByContent(stream, readAudioProperties, audioPropertiesStyle); } +FileRef::FileTypeResolver::FileTypeResolver() = default; FileRef::FileTypeResolver::~FileTypeResolver() = default; +FileRef::StreamTypeResolver::StreamTypeResolver() = default; FileRef::StreamTypeResolver::~StreamTypeResolver() = default; diff --git a/taglib/fileref.h b/taglib/fileref.h index 6a558bdf..14dee450 100644 --- a/taglib/fileref.h +++ b/taglib/fileref.h @@ -92,11 +92,15 @@ namespace TagLib { class TAGLIB_EXPORT FileTypeResolver { public: + FileTypeResolver(); /*! * Destroys this FileTypeResolver instance. */ virtual ~FileTypeResolver() = 0; + FileTypeResolver(const FileTypeResolver &) = delete; + FileTypeResolver &operator=(const FileTypeResolver &) = delete; + /*! * This method must be overridden to provide an additional file type * resolver. If the resolver is able to determine the file type it should @@ -112,24 +116,28 @@ namespace TagLib { audioPropertiesStyle = AudioProperties::Average) const = 0; private: class FileTypeResolverPrivate; - FileTypeResolverPrivate *d; + std::unique_ptr d; }; class TAGLIB_EXPORT StreamTypeResolver : public FileTypeResolver { public: + StreamTypeResolver(); /*! * Destroys this StreamTypeResolver instance. */ ~StreamTypeResolver() override = 0; + StreamTypeResolver(const StreamTypeResolver &) = delete; + StreamTypeResolver &operator=(const StreamTypeResolver &) = delete; + virtual File *createFileFromStream(IOStream *stream, bool readAudioProperties = true, AudioProperties::ReadStyle audioPropertiesStyle = AudioProperties::Average) const = 0; private: class StreamTypeResolverPrivate; - StreamTypeResolverPrivate *d; + std::unique_ptr d; }; /*! diff --git a/taglib/flac/flacfile.cpp b/taglib/flac/flacfile.cpp index 678fcfe2..0c0d7a54 100644 --- a/taglib/flac/flacfile.cpp +++ b/taglib/flac/flacfile.cpp @@ -79,6 +79,9 @@ public: delete properties; } + FilePrivate(const FilePrivate &) = delete; + FilePrivate &operator=(const FilePrivate &) = delete; + const ID3v2::FrameFactory *ID3v2FrameFactory; offset_t ID3v2Location; long ID3v2OriginalSize; @@ -114,7 +117,7 @@ bool FLAC::File::isSupported(IOStream *stream) FLAC::File::File(FileName file, bool readProperties, Properties::ReadStyle) : TagLib::File(file), - d(new FilePrivate()) + d(std::make_unique()) { if(isOpen()) read(readProperties); @@ -123,7 +126,7 @@ FLAC::File::File(FileName file, bool readProperties, Properties::ReadStyle) : FLAC::File::File(FileName file, ID3v2::FrameFactory *frameFactory, bool readProperties, Properties::ReadStyle) : TagLib::File(file), - d(new FilePrivate(frameFactory)) + d(std::make_unique(frameFactory)) { if(isOpen()) read(readProperties); @@ -132,16 +135,13 @@ FLAC::File::File(FileName file, ID3v2::FrameFactory *frameFactory, FLAC::File::File(IOStream *stream, ID3v2::FrameFactory *frameFactory, bool readProperties, Properties::ReadStyle) : TagLib::File(stream), - d(new FilePrivate(frameFactory)) + d(std::make_unique(frameFactory)) { if(isOpen()) read(readProperties); } -FLAC::File::~File() -{ - delete d; -} +FLAC::File::~File() = default; TagLib::Tag *FLAC::File::tag() const { diff --git a/taglib/flac/flacfile.h b/taglib/flac/flacfile.h index 6c64d438..7cb568f8 100644 --- a/taglib/flac/flacfile.h +++ b/taglib/flac/flacfile.h @@ -130,6 +130,9 @@ namespace TagLib { */ ~File() override; + File(const File &) = delete; + File &operator=(const File &) = delete; + /*! * Returns the Tag for this file. This will be a union of XiphComment, * ID3v1 and ID3v2 tags. @@ -301,14 +304,11 @@ namespace TagLib { static bool isSupported(IOStream *stream); private: - File(const File &) = delete; - File &operator=(const File &) = delete; - void read(bool readProperties); void scan(); class FilePrivate; - FilePrivate *d; + std::unique_ptr d; }; } // namespace FLAC } // namespace TagLib diff --git a/taglib/flac/flacmetadatablock.cpp b/taglib/flac/flacmetadatablock.cpp index 574e2948..58a734aa 100644 --- a/taglib/flac/flacmetadatablock.cpp +++ b/taglib/flac/flacmetadatablock.cpp @@ -31,13 +31,8 @@ using namespace TagLib; class FLAC::MetadataBlock::MetadataBlockPrivate { -public: - MetadataBlockPrivate() = default; }; -FLAC::MetadataBlock::MetadataBlock() - : d(nullptr) -{ -} +FLAC::MetadataBlock::MetadataBlock() = default; FLAC::MetadataBlock::~MetadataBlock() = default; diff --git a/taglib/flac/flacmetadatablock.h b/taglib/flac/flacmetadatablock.h index f90d0339..2c68df34 100644 --- a/taglib/flac/flacmetadatablock.h +++ b/taglib/flac/flacmetadatablock.h @@ -38,6 +38,9 @@ namespace TagLib { MetadataBlock(); virtual ~MetadataBlock(); + MetadataBlock(const MetadataBlock &item) = delete; + MetadataBlock &operator=(const MetadataBlock &item) = delete; + enum BlockType { StreamInfo = 0, Padding, @@ -59,11 +62,8 @@ namespace TagLib { virtual ByteVector render() const = 0; private: - MetadataBlock(const MetadataBlock &item) = delete; - MetadataBlock &operator=(const MetadataBlock &item) = delete; - class MetadataBlockPrivate; - MetadataBlockPrivate *d; + std::unique_ptr d; }; } // namespace FLAC } // namespace TagLib diff --git a/taglib/flac/flacpicture.cpp b/taglib/flac/flacpicture.cpp index 251640b6..977bd3b6 100644 --- a/taglib/flac/flacpicture.cpp +++ b/taglib/flac/flacpicture.cpp @@ -51,20 +51,17 @@ public: }; FLAC::Picture::Picture() : - d(new PicturePrivate()) + d(std::make_unique()) { } FLAC::Picture::Picture(const ByteVector &data) : - d(new PicturePrivate()) + d(std::make_unique()) { parse(data); } -FLAC::Picture::~Picture() -{ - delete d; -} +FLAC::Picture::~Picture() = default; int FLAC::Picture::code() const { diff --git a/taglib/flac/flacpicture.h b/taglib/flac/flacpicture.h index 93468386..089adeca 100644 --- a/taglib/flac/flacpicture.h +++ b/taglib/flac/flacpicture.h @@ -90,6 +90,9 @@ namespace TagLib { Picture(const ByteVector &data); ~Picture() override; + Picture(const Picture &item) = delete; + Picture &operator=(const Picture &item) = delete; + /*! * Returns the type of the image. */ @@ -190,11 +193,8 @@ namespace TagLib { bool parse(const ByteVector &rawData); private: - Picture(const Picture &item) = delete; - Picture &operator=(const Picture &item) = delete; - class PicturePrivate; - PicturePrivate *d; + std::unique_ptr d; }; typedef List PictureList; diff --git a/taglib/flac/flacproperties.cpp b/taglib/flac/flacproperties.cpp index 37eace58..f465292a 100644 --- a/taglib/flac/flacproperties.cpp +++ b/taglib/flac/flacproperties.cpp @@ -58,15 +58,12 @@ public: FLAC::Properties::Properties(const ByteVector &data, offset_t streamLength, ReadStyle style) : AudioProperties(style), - d(new PropertiesPrivate()) + d(std::make_unique()) { read(data, streamLength); } -FLAC::Properties::~Properties() -{ - delete d; -} +FLAC::Properties::~Properties() = default; int FLAC::Properties::lengthInMilliseconds() const { diff --git a/taglib/flac/flacproperties.h b/taglib/flac/flacproperties.h index db0c5c7d..85cdefe3 100644 --- a/taglib/flac/flacproperties.h +++ b/taglib/flac/flacproperties.h @@ -55,6 +55,9 @@ namespace TagLib { */ ~Properties() override; + Properties(const Properties &) = delete; + Properties &operator=(const Properties &) = delete; + /*! * Returns the length of the file in milliseconds. * @@ -95,13 +98,10 @@ namespace TagLib { ByteVector signature() const; private: - Properties(const Properties &) = delete; - Properties &operator=(const Properties &) = delete; - void read(const ByteVector &data, offset_t streamLength); class PropertiesPrivate; - PropertiesPrivate *d; + std::unique_ptr d; }; } // namespace FLAC } // namespace TagLib diff --git a/taglib/flac/flacunknownmetadatablock.cpp b/taglib/flac/flacunknownmetadatablock.cpp index 2ec00239..eaa7a70f 100644 --- a/taglib/flac/flacunknownmetadatablock.cpp +++ b/taglib/flac/flacunknownmetadatablock.cpp @@ -40,16 +40,13 @@ public: }; FLAC::UnknownMetadataBlock::UnknownMetadataBlock(int code, const ByteVector &data) : - d(new UnknownMetadataBlockPrivate()) + d(std::make_unique()) { d->code = code; d->data = data; } -FLAC::UnknownMetadataBlock::~UnknownMetadataBlock() -{ - delete d; -} +FLAC::UnknownMetadataBlock::~UnknownMetadataBlock() = default; int FLAC::UnknownMetadataBlock::code() const { diff --git a/taglib/flac/flacunknownmetadatablock.h b/taglib/flac/flacunknownmetadatablock.h index 12c4cc1d..250a9583 100644 --- a/taglib/flac/flacunknownmetadatablock.h +++ b/taglib/flac/flacunknownmetadatablock.h @@ -39,6 +39,9 @@ namespace TagLib { UnknownMetadataBlock(int blockType, const ByteVector &data); ~UnknownMetadataBlock() override; + UnknownMetadataBlock(const UnknownMetadataBlock &item) = delete; + UnknownMetadataBlock &operator=(const UnknownMetadataBlock &item) = delete; + /*! * Returns the FLAC metadata block type. */ @@ -65,11 +68,8 @@ namespace TagLib { ByteVector render() const override; private: - UnknownMetadataBlock(const MetadataBlock &item); - UnknownMetadataBlock &operator=(const MetadataBlock &item); - class UnknownMetadataBlockPrivate; - UnknownMetadataBlockPrivate *d; + std::unique_ptr d; }; } // namespace FLAC } // namespace TagLib diff --git a/taglib/it/itfile.cpp b/taglib/it/itfile.cpp index db5f5b29..f87ea9ae 100644 --- a/taglib/it/itfile.cpp +++ b/taglib/it/itfile.cpp @@ -48,7 +48,7 @@ public: IT::File::File(FileName file, bool readProperties, AudioProperties::ReadStyle propertiesStyle) : Mod::FileBase(file), - d(new FilePrivate(propertiesStyle)) + d(std::make_unique(propertiesStyle)) { if(isOpen()) read(readProperties); @@ -57,16 +57,13 @@ IT::File::File(FileName file, bool readProperties, IT::File::File(IOStream *stream, bool readProperties, AudioProperties::ReadStyle propertiesStyle) : Mod::FileBase(stream), - d(new FilePrivate(propertiesStyle)) + d(std::make_unique(propertiesStyle)) { if(isOpen()) read(readProperties); } -IT::File::~File() -{ - delete d; -} +IT::File::~File() = default; Mod::Tag *IT::File::tag() const { diff --git a/taglib/it/itfile.h b/taglib/it/itfile.h index 87259afd..48094121 100644 --- a/taglib/it/itfile.h +++ b/taglib/it/itfile.h @@ -65,6 +65,9 @@ namespace TagLib { */ ~File() override; + File(const File &) = delete; + File &operator=(const File &) = delete; + Mod::Tag *tag() const override; /*! @@ -81,15 +84,11 @@ namespace TagLib { */ bool save() override; - private: - File(const File &) = delete; - File &operator=(const File &) = delete; - void read(bool readProperties); class FilePrivate; - FilePrivate *d; + std::unique_ptr d; }; } // namespace IT } // namespace TagLib diff --git a/taglib/it/itproperties.cpp b/taglib/it/itproperties.cpp index 23b224ac..72fa9e08 100644 --- a/taglib/it/itproperties.cpp +++ b/taglib/it/itproperties.cpp @@ -70,14 +70,11 @@ public: IT::Properties::Properties(AudioProperties::ReadStyle propertiesStyle) : AudioProperties(propertiesStyle), - d(new PropertiesPrivate()) + d(std::make_unique()) { } -IT::Properties::~Properties() -{ - delete d; -} +IT::Properties::~Properties() = default; int IT::Properties::channels() const { diff --git a/taglib/it/itproperties.h b/taglib/it/itproperties.h index 3a6e346a..05d459be 100644 --- a/taglib/it/itproperties.h +++ b/taglib/it/itproperties.h @@ -54,6 +54,9 @@ namespace TagLib { Properties(AudioProperties::ReadStyle propertiesStyle); ~Properties() override; + Properties(const Properties &) = delete; + Properties &operator=(const Properties &) = delete; + int channels() const override; unsigned short lengthInPatterns() const; @@ -89,11 +92,8 @@ namespace TagLib { void setPitchWheelDepth(unsigned char pitchWheelDepth); private: - Properties(const Properties&) = delete; - Properties &operator=(const Properties&) = delete; - class PropertiesPrivate; - PropertiesPrivate *d; + std::unique_ptr d; }; } // namespace IT } // namespace TagLib diff --git a/taglib/mod/modfile.cpp b/taglib/mod/modfile.cpp index 00d330eb..4af7952a 100644 --- a/taglib/mod/modfile.cpp +++ b/taglib/mod/modfile.cpp @@ -48,7 +48,7 @@ public: Mod::File::File(FileName file, bool readProperties, AudioProperties::ReadStyle propertiesStyle) : Mod::FileBase(file), - d(new FilePrivate(propertiesStyle)) + d(std::make_unique(propertiesStyle)) { if(isOpen()) read(readProperties); @@ -57,16 +57,13 @@ Mod::File::File(FileName file, bool readProperties, Mod::File::File(IOStream *stream, bool readProperties, AudioProperties::ReadStyle propertiesStyle) : Mod::FileBase(stream), - d(new FilePrivate(propertiesStyle)) + d(std::make_unique(propertiesStyle)) { if(isOpen()) read(readProperties); } -Mod::File::~File() -{ - delete d; -} +Mod::File::~File() = default; Mod::Tag *Mod::File::tag() const { diff --git a/taglib/mod/modfile.h b/taglib/mod/modfile.h index 12dcf53b..7ed87eb3 100644 --- a/taglib/mod/modfile.h +++ b/taglib/mod/modfile.h @@ -68,6 +68,9 @@ namespace TagLib { */ ~File() override; + File(const File &) = delete; + File &operator=(const File &) = delete; + Mod::Tag *tag() const override; /*! @@ -96,13 +99,10 @@ namespace TagLib { bool save() override; private: - File(const File &) = delete; - File &operator=(const File &) = delete; - void read(bool readProperties); class FilePrivate; - FilePrivate *d; + std::unique_ptr d; }; } // namespace Mod } // namespace TagLib diff --git a/taglib/mod/modfilebase.cpp b/taglib/mod/modfilebase.cpp index daa9eb8f..708f85fc 100644 --- a/taglib/mod/modfilebase.cpp +++ b/taglib/mod/modfilebase.cpp @@ -30,6 +30,12 @@ using namespace TagLib; using namespace Mod; +class Mod::FileBase::FileBasePrivate +{ +}; + +Mod::FileBase::~FileBase() = default; + Mod::FileBase::FileBase(FileName file) : TagLib::File(file) { } diff --git a/taglib/mod/modfilebase.h b/taglib/mod/modfilebase.h index 469e8b65..374eedc8 100644 --- a/taglib/mod/modfilebase.h +++ b/taglib/mod/modfilebase.h @@ -38,6 +38,12 @@ namespace TagLib { namespace Mod { class TAGLIB_EXPORT FileBase : public TagLib::File { + public: + ~FileBase() override; + + FileBase(const FileBase &) = delete; + FileBase& operator=(const FileBase &) = delete; + protected: FileBase(FileName file); FileBase(IOStream *stream); @@ -57,7 +63,7 @@ namespace TagLib { bool readU32B(unsigned long &number); private: class FileBasePrivate; - FileBasePrivate *d; + std::unique_ptr d; }; } // namespace Mod } // namespace TagLib diff --git a/taglib/mod/modproperties.cpp b/taglib/mod/modproperties.cpp index 05b2ddcf..8a7a57c4 100644 --- a/taglib/mod/modproperties.cpp +++ b/taglib/mod/modproperties.cpp @@ -46,14 +46,11 @@ public: Mod::Properties::Properties(AudioProperties::ReadStyle propertiesStyle) : AudioProperties(propertiesStyle), - d(new PropertiesPrivate()) + d(std::make_unique()) { } -Mod::Properties::~Properties() -{ - delete d; -} +Mod::Properties::~Properties() = default; int Mod::Properties::bitrate() const { diff --git a/taglib/mod/modproperties.h b/taglib/mod/modproperties.h index 1581a076..60c29aaa 100644 --- a/taglib/mod/modproperties.h +++ b/taglib/mod/modproperties.h @@ -37,6 +37,9 @@ namespace TagLib { Properties(AudioProperties::ReadStyle propertiesStyle); ~Properties() override; + Properties(const Properties &) = delete; + Properties &operator=(const Properties &) = delete; + int bitrate() const override; int sampleRate() const override; int channels() const override; @@ -50,11 +53,8 @@ namespace TagLib { void setLengthInPatterns(unsigned char lengthInPatterns); private: - Properties(const Properties&) = delete; - Properties &operator=(const Properties&) = delete; - class PropertiesPrivate; - PropertiesPrivate *d; + std::unique_ptr d; }; } // namespace Mod } // namespace TagLib diff --git a/taglib/mod/modtag.cpp b/taglib/mod/modtag.cpp index 11a710e1..e27b68fe 100644 --- a/taglib/mod/modtag.cpp +++ b/taglib/mod/modtag.cpp @@ -34,22 +34,17 @@ using namespace Mod; class Mod::Tag::TagPrivate { public: - TagPrivate() = default; - String title; String comment; String trackerName; }; Mod::Tag::Tag() : - d(new TagPrivate()) + d(std::make_unique()) { } -Mod::Tag::~Tag() -{ - delete d; -} +Mod::Tag::~Tag() = default; String Mod::Tag::title() const { diff --git a/taglib/mod/modtag.h b/taglib/mod/modtag.h index ad7cdbe8..b2bca87e 100644 --- a/taglib/mod/modtag.h +++ b/taglib/mod/modtag.h @@ -48,6 +48,9 @@ namespace TagLib { Tag(); ~Tag() override; + Tag(const Tag &) = delete; + Tag &operator=(const Tag &) = delete; + /*! * Returns the track name; if no track name is present in the tag * String::null will be returned. @@ -178,11 +181,8 @@ namespace TagLib { PropertyMap setProperties(const PropertyMap &) override; private: - Tag(const Tag &) = delete; - Tag &operator=(const Tag &) = delete; - class TagPrivate; - TagPrivate *d; + std::unique_ptr d; }; } // namespace Mod } // namespace TagLib diff --git a/taglib/mp4/mp4atom.cpp b/taglib/mp4/mp4atom.cpp index 923ee1cd..eadc54ef 100644 --- a/taglib/mp4/mp4atom.cpp +++ b/taglib/mp4/mp4atom.cpp @@ -191,8 +191,7 @@ MP4::Atoms::Atoms(File *file) } } -MP4::Atoms::~Atoms() -= default; +MP4::Atoms::~Atoms() = default; MP4::Atom * MP4::Atoms::find(const char *name1, const char *name2, const char *name3, const char *name4) diff --git a/taglib/mp4/mp4atom.h b/taglib/mp4/mp4atom.h index 9517ecf6..5c01764c 100644 --- a/taglib/mp4/mp4atom.h +++ b/taglib/mp4/mp4atom.h @@ -79,6 +79,8 @@ namespace TagLib { public: Atom(File *file); ~Atom(); + Atom(const Atom &) = delete; + Atom &operator=(const Atom &) = delete; Atom *find(const char *name1, const char *name2 = nullptr, const char *name3 = nullptr, const char *name4 = nullptr); bool path(AtomList &path, const char *name1, const char *name2 = nullptr, const char *name3 = nullptr); AtomList findall(const char *name, bool recursive = false); @@ -94,6 +96,8 @@ namespace TagLib { public: Atoms(File *file); ~Atoms(); + Atoms(const Atoms &) = delete; + Atoms &operator=(const Atoms &) = delete; Atom *find(const char *name1, const char *name2 = nullptr, const char *name3 = nullptr, const char *name4 = nullptr); AtomList path(const char *name1, const char *name2 = nullptr, const char *name3 = nullptr, const char *name4 = nullptr); AtomList atoms; diff --git a/taglib/mp4/mp4file.cpp b/taglib/mp4/mp4file.cpp index 04b00947..22a1b783 100644 --- a/taglib/mp4/mp4file.cpp +++ b/taglib/mp4/mp4file.cpp @@ -64,6 +64,9 @@ public: delete properties; } + FilePrivate(const FilePrivate &) = delete; + FilePrivate &operator=(const FilePrivate &) = delete; + MP4::Tag *tag; MP4::Atoms *atoms; MP4::Properties *properties; @@ -87,7 +90,7 @@ bool MP4::File::isSupported(IOStream *stream) MP4::File::File(FileName file, bool readProperties, AudioProperties::ReadStyle) : TagLib::File(file), - d(new FilePrivate()) + d(std::make_unique()) { if(isOpen()) read(readProperties); @@ -95,16 +98,13 @@ MP4::File::File(FileName file, bool readProperties, AudioProperties::ReadStyle) MP4::File::File(IOStream *stream, bool readProperties, AudioProperties::ReadStyle) : TagLib::File(stream), - d(new FilePrivate()) + d(std::make_unique()) { if(isOpen()) read(readProperties); } -MP4::File::~File() -{ - delete d; -} +MP4::File::~File() = default; MP4::Tag * MP4::File::tag() const diff --git a/taglib/mp4/mp4file.h b/taglib/mp4/mp4file.h index 6337e9bf..4af06941 100644 --- a/taglib/mp4/mp4file.h +++ b/taglib/mp4/mp4file.h @@ -85,6 +85,9 @@ namespace TagLib { */ ~File() override; + File(const File &) = delete; + File &operator=(const File &) = delete; + /*! * Returns a pointer to the MP4 tag of the file. * @@ -153,7 +156,7 @@ namespace TagLib { void read(bool readProperties); class FilePrivate; - FilePrivate *d; + std::unique_ptr d; }; } // namespace MP4 } // namespace TagLib diff --git a/taglib/mp4/mp4properties.cpp b/taglib/mp4/mp4properties.cpp index 900cbf1d..5128c018 100644 --- a/taglib/mp4/mp4properties.cpp +++ b/taglib/mp4/mp4properties.cpp @@ -79,15 +79,12 @@ public: MP4::Properties::Properties(File *file, MP4::Atoms *atoms, ReadStyle style) : AudioProperties(style), - d(new PropertiesPrivate()) + d(std::make_unique()) { read(file, atoms); } -MP4::Properties::~Properties() -{ - delete d; -} +MP4::Properties::~Properties() = default; int MP4::Properties::channels() const diff --git a/taglib/mp4/mp4properties.h b/taglib/mp4/mp4properties.h index ee744621..baafab77 100644 --- a/taglib/mp4/mp4properties.h +++ b/taglib/mp4/mp4properties.h @@ -47,6 +47,9 @@ namespace TagLib { Properties(File *file, Atoms *atoms, ReadStyle style = Average); ~Properties() override; + Properties(const Properties &) = delete; + Properties &operator=(const Properties &) = delete; + /*! * Returns the length of the file in milliseconds. * @@ -88,7 +91,7 @@ namespace TagLib { void read(File *file, Atoms *atoms); class PropertiesPrivate; - PropertiesPrivate *d; + std::unique_ptr d; }; } // namespace MP4 } // namespace TagLib diff --git a/taglib/mp4/mp4tag.cpp b/taglib/mp4/mp4tag.cpp index 3b4d919b..fdcbadd8 100644 --- a/taglib/mp4/mp4tag.cpp +++ b/taglib/mp4/mp4tag.cpp @@ -47,12 +47,12 @@ public: }; MP4::Tag::Tag() : - d(new TagPrivate()) + d(std::make_unique()) { } MP4::Tag::Tag(TagLib::File *file, MP4::Atoms *atoms) : - d(new TagPrivate()) + d(std::make_unique()) { d->file = file; d->atoms = atoms; @@ -116,10 +116,7 @@ MP4::Tag::Tag(TagLib::File *file, MP4::Atoms *atoms) : } } -MP4::Tag::~Tag() -{ - delete d; -} +MP4::Tag::~Tag() = default; MP4::AtomDataList MP4::Tag::parseData2(const MP4::Atom *atom, int expectedFlags, bool freeForm) diff --git a/taglib/mp4/mp4tag.h b/taglib/mp4/mp4tag.h index 0ba29230..77fc53cf 100644 --- a/taglib/mp4/mp4tag.h +++ b/taglib/mp4/mp4tag.h @@ -45,6 +45,8 @@ namespace TagLib { Tag(); Tag(TagLib::File *file, Atoms *atoms); ~Tag() override; + Tag(const Tag &) = delete; + Tag &operator=(const Tag &) = delete; bool save(); String title() const override; @@ -148,7 +150,7 @@ namespace TagLib { void addItem(const String &name, const Item &value); class TagPrivate; - TagPrivate *d; + std::unique_ptr d; }; } // namespace MP4 } // namespace TagLib diff --git a/taglib/mpc/mpcfile.cpp b/taglib/mpc/mpcfile.cpp index 462888e8..2f41f49c 100644 --- a/taglib/mpc/mpcfile.cpp +++ b/taglib/mpc/mpcfile.cpp @@ -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()) { 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()) { if(isOpen()) read(readProperties); } -MPC::File::~File() -{ - delete d; -} +MPC::File::~File() = default; TagLib::Tag *MPC::File::tag() const { diff --git a/taglib/mpc/mpcfile.h b/taglib/mpc/mpcfile.h index 23931e9f..59810adb 100644 --- a/taglib/mpc/mpcfile.h +++ b/taglib/mpc/mpcfile.h @@ -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 d; }; } // namespace MPC } // namespace TagLib diff --git a/taglib/mpc/mpcproperties.cpp b/taglib/mpc/mpcproperties.cpp index 5c3b45b0..a81e45e8 100644 --- a/taglib/mpc/mpcproperties.cpp +++ b/taglib/mpc/mpcproperties.cpp @@ -70,7 +70,7 @@ public: MPC::Properties::Properties(File *file, offset_t streamLength, ReadStyle style) : AudioProperties(style), - d(new PropertiesPrivate()) + d(std::make_unique()) { 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 { diff --git a/taglib/mpc/mpcproperties.h b/taglib/mpc/mpcproperties.h index ae77c8cc..b39bf4c6 100644 --- a/taglib/mpc/mpcproperties.h +++ b/taglib/mpc/mpcproperties.h @@ -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 d; }; } // namespace MPC } // namespace TagLib diff --git a/taglib/mpeg/id3v1/id3v1tag.cpp b/taglib/mpeg/id3v1/id3v1tag.cpp index b6fe5acd..e1607311 100644 --- a/taglib/mpeg/id3v1/id3v1tag.cpp +++ b/taglib/mpeg/id3v1/id3v1tag.cpp @@ -60,6 +60,10 @@ public: unsigned char genre; }; +class ID3v1::StringHandler::StringHandlerPrivate +{ +}; + //////////////////////////////////////////////////////////////////////////////// // StringHandler implementation //////////////////////////////////////////////////////////////////////////////// @@ -85,12 +89,12 @@ ByteVector ID3v1::StringHandler::render(const String &s) const //////////////////////////////////////////////////////////////////////////////// ID3v1::Tag::Tag() : - d(new TagPrivate()) + d(std::make_unique()) { } ID3v1::Tag::Tag(File *file, offset_t tagOffset) : - d(new TagPrivate()) + d(std::make_unique()) { d->file = file; d->tagOffset = tagOffset; @@ -98,10 +102,7 @@ ID3v1::Tag::Tag(File *file, offset_t tagOffset) : read(); } -ID3v1::Tag::~Tag() -{ - delete d; -} +ID3v1::Tag::~Tag() = default; ByteVector ID3v1::Tag::render() const { diff --git a/taglib/mpeg/id3v1/id3v1tag.h b/taglib/mpeg/id3v1/id3v1tag.h index bf787e8f..fd478a9b 100644 --- a/taglib/mpeg/id3v1/id3v1tag.h +++ b/taglib/mpeg/id3v1/id3v1tag.h @@ -64,6 +64,9 @@ namespace TagLib { virtual ~StringHandler(); + StringHandler(const StringHandler &) = delete; + StringHandler &operator=(const StringHandler &) = delete; + /*! * Decode a string from \a data. The default implementation assumes that * \a data is an ISO-8859-1 (Latin1) character array. @@ -83,7 +86,7 @@ namespace TagLib { private: class StringHandlerPrivate; - StringHandlerPrivate *d; + std::unique_ptr d; }; //! The main class in the ID3v1 implementation @@ -125,6 +128,9 @@ namespace TagLib { */ ~Tag() override; + Tag(const Tag &) = delete; + Tag &operator=(const Tag &) = delete; + /*! * Renders the in memory values to a ByteVector suitable for writing to * the file. @@ -194,11 +200,8 @@ namespace TagLib { void parse(const ByteVector &data); private: - Tag(const Tag &) = delete; - Tag &operator=(const Tag &) = delete; - class TagPrivate; - TagPrivate *d; + std::unique_ptr d; }; } // namespace ID3v1 } // namespace TagLib diff --git a/taglib/mpeg/id3v2/frames/attachedpictureframe.cpp b/taglib/mpeg/id3v2/frames/attachedpictureframe.cpp index 2e32f4c4..daaeca0c 100644 --- a/taglib/mpeg/id3v2/frames/attachedpictureframe.cpp +++ b/taglib/mpeg/id3v2/frames/attachedpictureframe.cpp @@ -50,21 +50,18 @@ public: AttachedPictureFrame::AttachedPictureFrame() : Frame("APIC"), - d(new AttachedPictureFramePrivate()) + d(std::make_unique()) { } AttachedPictureFrame::AttachedPictureFrame(const ByteVector &data) : Frame(data), - d(new AttachedPictureFramePrivate()) + d(std::make_unique()) { setData(data); } -AttachedPictureFrame::~AttachedPictureFrame() -{ - delete d; -} +AttachedPictureFrame::~AttachedPictureFrame() = default; String AttachedPictureFrame::toString() const { @@ -173,7 +170,7 @@ ByteVector AttachedPictureFrame::renderFields() const AttachedPictureFrame::AttachedPictureFrame(const ByteVector &data, Header *h) : Frame(h), - d(new AttachedPictureFramePrivate()) + d(std::make_unique()) { parseFields(fieldData(data)); } diff --git a/taglib/mpeg/id3v2/frames/attachedpictureframe.h b/taglib/mpeg/id3v2/frames/attachedpictureframe.h index f8aafc38..caaf07a7 100644 --- a/taglib/mpeg/id3v2/frames/attachedpictureframe.h +++ b/taglib/mpeg/id3v2/frames/attachedpictureframe.h @@ -113,6 +113,9 @@ namespace TagLib { */ ~AttachedPictureFrame() override; + AttachedPictureFrame(const AttachedPictureFrame &) = delete; + AttachedPictureFrame &operator=(const AttachedPictureFrame &) = delete; + /*! * Returns a string containing the description and mime-type */ @@ -206,13 +209,10 @@ namespace TagLib { void parseFields(const ByteVector &data) override; ByteVector renderFields() const override; class AttachedPictureFramePrivate; - AttachedPictureFramePrivate *d; + std::unique_ptr d; private: - AttachedPictureFrame(const AttachedPictureFrame &) = delete; - AttachedPictureFrame &operator=(const AttachedPictureFrame &) = delete; AttachedPictureFrame(const ByteVector &data, Header *h); - }; //! support for ID3v2.2 PIC frames diff --git a/taglib/mpeg/id3v2/frames/chapterframe.cpp b/taglib/mpeg/id3v2/frames/chapterframe.cpp index d5ffd149..3e0e0275 100644 --- a/taglib/mpeg/id3v2/frames/chapterframe.cpp +++ b/taglib/mpeg/id3v2/frames/chapterframe.cpp @@ -62,7 +62,7 @@ public: ChapterFrame::ChapterFrame(const ID3v2::Header *tagHeader, const ByteVector &data) : ID3v2::Frame(data), - d(new ChapterFramePrivate()) + d(std::make_unique()) { d->tagHeader = tagHeader; setData(data); @@ -73,7 +73,7 @@ ChapterFrame::ChapterFrame(const ByteVector &elementID, unsigned int startOffset, unsigned int endOffset, const FrameList &embeddedFrames) : ID3v2::Frame("CHAP"), - d(new ChapterFramePrivate()) + d(std::make_unique()) { // setElementID has a workaround for a previously silly API where you had to // specifically include the null byte. @@ -89,10 +89,7 @@ ChapterFrame::ChapterFrame(const ByteVector &elementID, addEmbeddedFrame(*it); } -ChapterFrame::~ChapterFrame() -{ - delete d; -} +ChapterFrame::~ChapterFrame() = default; ByteVector ChapterFrame::elementID() const { @@ -302,7 +299,7 @@ ByteVector ChapterFrame::renderFields() const ChapterFrame::ChapterFrame(const ID3v2::Header *tagHeader, const ByteVector &data, Header *h) : Frame(h), - d(new ChapterFramePrivate()) + d(std::make_unique()) { d->tagHeader = tagHeader; parseFields(fieldData(data)); diff --git a/taglib/mpeg/id3v2/frames/chapterframe.h b/taglib/mpeg/id3v2/frames/chapterframe.h index 0a11cc6b..a229e319 100644 --- a/taglib/mpeg/id3v2/frames/chapterframe.h +++ b/taglib/mpeg/id3v2/frames/chapterframe.h @@ -71,6 +71,9 @@ namespace TagLib { */ ~ChapterFrame() override; + ChapterFrame(const ChapterFrame &) = delete; + ChapterFrame &operator=(const ChapterFrame &) = delete; + /*! * Returns the element ID of the frame. Element ID * is a null terminated string, however it's not human-readable. @@ -237,11 +240,9 @@ namespace TagLib { private: ChapterFrame(const ID3v2::Header *tagHeader, const ByteVector &data, Header *h); - ChapterFrame(const ChapterFrame &) = delete; - ChapterFrame &operator=(const ChapterFrame &) = delete; class ChapterFramePrivate; - ChapterFramePrivate *d; + std::unique_ptr d; }; } // namespace ID3v2 } // namespace TagLib diff --git a/taglib/mpeg/id3v2/frames/commentsframe.cpp b/taglib/mpeg/id3v2/frames/commentsframe.cpp index 462e8bf3..16acde71 100644 --- a/taglib/mpeg/id3v2/frames/commentsframe.cpp +++ b/taglib/mpeg/id3v2/frames/commentsframe.cpp @@ -51,22 +51,19 @@ public: CommentsFrame::CommentsFrame(String::Type encoding) : Frame("COMM"), - d(new CommentsFramePrivate()) + d(std::make_unique()) { d->textEncoding = encoding; } CommentsFrame::CommentsFrame(const ByteVector &data) : Frame(data), - d(new CommentsFramePrivate()) + d(std::make_unique()) { setData(data); } -CommentsFrame::~CommentsFrame() -{ - delete d; -} +CommentsFrame::~CommentsFrame() = default; String CommentsFrame::toString() const { @@ -191,7 +188,7 @@ ByteVector CommentsFrame::renderFields() const CommentsFrame::CommentsFrame(const ByteVector &data, Header *h) : Frame(h), - d(new CommentsFramePrivate()) + d(std::make_unique()) { parseFields(fieldData(data)); } diff --git a/taglib/mpeg/id3v2/frames/commentsframe.h b/taglib/mpeg/id3v2/frames/commentsframe.h index b41be877..334ce682 100644 --- a/taglib/mpeg/id3v2/frames/commentsframe.h +++ b/taglib/mpeg/id3v2/frames/commentsframe.h @@ -61,6 +61,9 @@ namespace TagLib { */ ~CommentsFrame() override; + CommentsFrame(const CommentsFrame &) = delete; + CommentsFrame &operator=(const CommentsFrame &) = delete; + /*! * Returns the text of this comment. * @@ -167,11 +170,9 @@ namespace TagLib { * The constructor used by the FrameFactory. */ CommentsFrame(const ByteVector &data, Header *h); - CommentsFrame(const CommentsFrame &) = delete; - CommentsFrame &operator=(const CommentsFrame &) = delete; class CommentsFramePrivate; - CommentsFramePrivate *d; + std::unique_ptr d; }; } // namespace ID3v2 diff --git a/taglib/mpeg/id3v2/frames/eventtimingcodesframe.cpp b/taglib/mpeg/id3v2/frames/eventtimingcodesframe.cpp index c0423f90..2a402cec 100644 --- a/taglib/mpeg/id3v2/frames/eventtimingcodesframe.cpp +++ b/taglib/mpeg/id3v2/frames/eventtimingcodesframe.cpp @@ -47,21 +47,18 @@ public: EventTimingCodesFrame::EventTimingCodesFrame() : Frame("ETCO"), - d(new EventTimingCodesFramePrivate()) + d(std::make_unique()) { } EventTimingCodesFrame::EventTimingCodesFrame(const ByteVector &data) : Frame(data), - d(new EventTimingCodesFramePrivate()) + d(std::make_unique()) { setData(data); } -EventTimingCodesFrame::~EventTimingCodesFrame() -{ - delete d; -} +EventTimingCodesFrame::~EventTimingCodesFrame() = default; String EventTimingCodesFrame::toString() const { @@ -136,7 +133,7 @@ ByteVector EventTimingCodesFrame::renderFields() const EventTimingCodesFrame::EventTimingCodesFrame(const ByteVector &data, Header *h) : Frame(h), - d(new EventTimingCodesFramePrivate()) + d(std::make_unique()) { parseFields(fieldData(data)); } diff --git a/taglib/mpeg/id3v2/frames/eventtimingcodesframe.h b/taglib/mpeg/id3v2/frames/eventtimingcodesframe.h index 75f00b73..9a20b476 100644 --- a/taglib/mpeg/id3v2/frames/eventtimingcodesframe.h +++ b/taglib/mpeg/id3v2/frames/eventtimingcodesframe.h @@ -133,6 +133,9 @@ namespace TagLib { */ ~EventTimingCodesFrame() override; + EventTimingCodesFrame(const EventTimingCodesFrame &) = delete; + EventTimingCodesFrame &operator=(const EventTimingCodesFrame &) = delete; + /*! * Returns a null string. */ @@ -173,11 +176,9 @@ namespace TagLib { * The constructor used by the FrameFactory. */ EventTimingCodesFrame(const ByteVector &data, Header *h); - EventTimingCodesFrame(const EventTimingCodesFrame &) = delete; - EventTimingCodesFrame &operator=(const EventTimingCodesFrame &) = delete; class EventTimingCodesFramePrivate; - EventTimingCodesFramePrivate *d; + std::unique_ptr d; }; } // namespace ID3v2 diff --git a/taglib/mpeg/id3v2/frames/generalencapsulatedobjectframe.cpp b/taglib/mpeg/id3v2/frames/generalencapsulatedobjectframe.cpp index 90fc89c9..042e5e62 100644 --- a/taglib/mpeg/id3v2/frames/generalencapsulatedobjectframe.cpp +++ b/taglib/mpeg/id3v2/frames/generalencapsulatedobjectframe.cpp @@ -52,21 +52,18 @@ public: GeneralEncapsulatedObjectFrame::GeneralEncapsulatedObjectFrame() : Frame("GEOB"), - d(new GeneralEncapsulatedObjectFramePrivate()) + d(std::make_unique()) { } GeneralEncapsulatedObjectFrame::GeneralEncapsulatedObjectFrame(const ByteVector &data) : Frame(data), - d(new GeneralEncapsulatedObjectFramePrivate()) + d(std::make_unique()) { setData(data); } -GeneralEncapsulatedObjectFrame::~GeneralEncapsulatedObjectFrame() -{ - delete d; -} +GeneralEncapsulatedObjectFrame::~GeneralEncapsulatedObjectFrame() = default; String GeneralEncapsulatedObjectFrame::toString() const { @@ -181,7 +178,7 @@ ByteVector GeneralEncapsulatedObjectFrame::renderFields() const GeneralEncapsulatedObjectFrame::GeneralEncapsulatedObjectFrame(const ByteVector &data, Header *h) : Frame(h), - d(new GeneralEncapsulatedObjectFramePrivate()) + d(std::make_unique()) { parseFields(fieldData(data)); } diff --git a/taglib/mpeg/id3v2/frames/generalencapsulatedobjectframe.h b/taglib/mpeg/id3v2/frames/generalencapsulatedobjectframe.h index 3fb10cdd..b4e0d4f7 100644 --- a/taglib/mpeg/id3v2/frames/generalencapsulatedobjectframe.h +++ b/taglib/mpeg/id3v2/frames/generalencapsulatedobjectframe.h @@ -74,6 +74,9 @@ namespace TagLib { */ ~GeneralEncapsulatedObjectFrame() override; + GeneralEncapsulatedObjectFrame(const GeneralEncapsulatedObjectFrame &) = delete; + GeneralEncapsulatedObjectFrame &operator=(const GeneralEncapsulatedObjectFrame &) = delete; + /*! * Returns a string containing the description, file name and mime-type */ @@ -167,11 +170,9 @@ namespace TagLib { private: GeneralEncapsulatedObjectFrame(const ByteVector &data, Header *h); - GeneralEncapsulatedObjectFrame(const GeneralEncapsulatedObjectFrame &) = delete; - GeneralEncapsulatedObjectFrame &operator=(const GeneralEncapsulatedObjectFrame &) = delete; class GeneralEncapsulatedObjectFramePrivate; - GeneralEncapsulatedObjectFramePrivate *d; + std::unique_ptr d; }; } // namespace ID3v2 } // namespace TagLib diff --git a/taglib/mpeg/id3v2/frames/ownershipframe.cpp b/taglib/mpeg/id3v2/frames/ownershipframe.cpp index adba5319..0af4b5fc 100644 --- a/taglib/mpeg/id3v2/frames/ownershipframe.cpp +++ b/taglib/mpeg/id3v2/frames/ownershipframe.cpp @@ -47,22 +47,19 @@ public: OwnershipFrame::OwnershipFrame(String::Type encoding) : Frame("OWNE"), - d(new OwnershipFramePrivate()) + d(std::make_unique()) { d->textEncoding = encoding; } OwnershipFrame::OwnershipFrame(const ByteVector &data) : Frame(data), - d(new OwnershipFramePrivate()) + d(std::make_unique()) { setData(data); } -OwnershipFrame::~OwnershipFrame() -{ - delete d; -} +OwnershipFrame::~OwnershipFrame() = default; String OwnershipFrame::toString() const { @@ -170,7 +167,7 @@ ByteVector OwnershipFrame::renderFields() const OwnershipFrame::OwnershipFrame(const ByteVector &data, Header *h) : Frame(h), - d(new OwnershipFramePrivate()) + d(std::make_unique()) { parseFields(fieldData(data)); } diff --git a/taglib/mpeg/id3v2/frames/ownershipframe.h b/taglib/mpeg/id3v2/frames/ownershipframe.h index f2771440..abe4e7b2 100644 --- a/taglib/mpeg/id3v2/frames/ownershipframe.h +++ b/taglib/mpeg/id3v2/frames/ownershipframe.h @@ -60,6 +60,9 @@ namespace TagLib { */ ~OwnershipFrame() override; + OwnershipFrame(const OwnershipFrame &) = delete; + OwnershipFrame &operator=(const OwnershipFrame &) = delete; + /*! * Returns the text of this popularimeter. * @@ -139,11 +142,9 @@ namespace TagLib { * The constructor used by the FrameFactory. */ OwnershipFrame(const ByteVector &data, Header *h); - OwnershipFrame(const OwnershipFrame &) = delete; - OwnershipFrame &operator=(const OwnershipFrame &) = delete; class OwnershipFramePrivate; - OwnershipFramePrivate *d; + std::unique_ptr d; }; } // namespace ID3v2 diff --git a/taglib/mpeg/id3v2/frames/podcastframe.cpp b/taglib/mpeg/id3v2/frames/podcastframe.cpp index 8241e6aa..b45653e1 100644 --- a/taglib/mpeg/id3v2/frames/podcastframe.cpp +++ b/taglib/mpeg/id3v2/frames/podcastframe.cpp @@ -41,15 +41,12 @@ public: PodcastFrame::PodcastFrame() : Frame("PCST"), - d(new PodcastFramePrivate()) + d(std::make_unique()) { d->fieldData = ByteVector(4, '\0'); } -PodcastFrame::~PodcastFrame() -{ - delete d; -} +PodcastFrame::~PodcastFrame() = default; String PodcastFrame::toString() const { @@ -83,7 +80,7 @@ ByteVector PodcastFrame::renderFields() const PodcastFrame::PodcastFrame(const ByteVector &data, Header *h) : Frame(h), - d(new PodcastFramePrivate()) + d(std::make_unique()) { parseFields(fieldData(data)); } diff --git a/taglib/mpeg/id3v2/frames/podcastframe.h b/taglib/mpeg/id3v2/frames/podcastframe.h index a1a6121d..4fdc8e21 100644 --- a/taglib/mpeg/id3v2/frames/podcastframe.h +++ b/taglib/mpeg/id3v2/frames/podcastframe.h @@ -52,6 +52,9 @@ namespace TagLib { */ ~PodcastFrame() override; + PodcastFrame(const PodcastFrame &) = delete; + PodcastFrame &operator=(const PodcastFrame &) = delete; + /*! * Returns a null string. */ @@ -70,11 +73,9 @@ namespace TagLib { * The constructor used by the FrameFactory. */ PodcastFrame(const ByteVector &data, Header *h); - PodcastFrame(const PodcastFrame &) = delete; - PodcastFrame &operator=(const PodcastFrame &) = delete; class PodcastFramePrivate; - PodcastFramePrivate *d; + std::unique_ptr d; }; } // namespace ID3v2 diff --git a/taglib/mpeg/id3v2/frames/popularimeterframe.cpp b/taglib/mpeg/id3v2/frames/popularimeterframe.cpp index 32ec7a41..13a8bb4a 100644 --- a/taglib/mpeg/id3v2/frames/popularimeterframe.cpp +++ b/taglib/mpeg/id3v2/frames/popularimeterframe.cpp @@ -45,21 +45,18 @@ public: PopularimeterFrame::PopularimeterFrame() : Frame("POPM"), - d(new PopularimeterFramePrivate()) + d(std::make_unique()) { } PopularimeterFrame::PopularimeterFrame(const ByteVector &data) : Frame(data), - d(new PopularimeterFramePrivate()) + d(std::make_unique()) { setData(data); } -PopularimeterFrame::~PopularimeterFrame() -{ - delete d; -} +PopularimeterFrame::~PopularimeterFrame() = default; String PopularimeterFrame::toString() const { @@ -134,7 +131,7 @@ ByteVector PopularimeterFrame::renderFields() const PopularimeterFrame::PopularimeterFrame(const ByteVector &data, Header *h) : Frame(h), - d(new PopularimeterFramePrivate()) + d(std::make_unique()) { parseFields(fieldData(data)); } diff --git a/taglib/mpeg/id3v2/frames/popularimeterframe.h b/taglib/mpeg/id3v2/frames/popularimeterframe.h index ee18e38f..8e656444 100644 --- a/taglib/mpeg/id3v2/frames/popularimeterframe.h +++ b/taglib/mpeg/id3v2/frames/popularimeterframe.h @@ -1,4 +1,5 @@ /*************************************************************************** + * copyright : (C) 2008 by Lukas Lalinsky email : lalinsky@gmail.com ***************************************************************************/ @@ -60,6 +61,9 @@ namespace TagLib { */ ~PopularimeterFrame() override; + PopularimeterFrame(const PopularimeterFrame &) = delete; + PopularimeterFrame &operator=(const PopularimeterFrame &) = delete; + /*! * Returns the text of this popularimeter. * @@ -120,11 +124,9 @@ namespace TagLib { * The constructor used by the FrameFactory. */ PopularimeterFrame(const ByteVector &data, Header *h); - PopularimeterFrame(const PopularimeterFrame &) = delete; - PopularimeterFrame &operator=(const PopularimeterFrame &) = delete; class PopularimeterFramePrivate; - PopularimeterFramePrivate *d; + std::unique_ptr d; }; } // namespace ID3v2 diff --git a/taglib/mpeg/id3v2/frames/privateframe.cpp b/taglib/mpeg/id3v2/frames/privateframe.cpp index 5339d1cc..cbff9d57 100644 --- a/taglib/mpeg/id3v2/frames/privateframe.cpp +++ b/taglib/mpeg/id3v2/frames/privateframe.cpp @@ -47,21 +47,18 @@ public: PrivateFrame::PrivateFrame() : Frame("PRIV"), - d(new PrivateFramePrivate()) + d(std::make_unique()) { } PrivateFrame::PrivateFrame(const ByteVector &data) : Frame(data), - d(new PrivateFramePrivate()) + d(std::make_unique()) { Frame::setData(data); } -PrivateFrame::~PrivateFrame() -{ - delete d; -} +PrivateFrame::~PrivateFrame() = default; String PrivateFrame::toString() const { @@ -125,7 +122,7 @@ ByteVector PrivateFrame::renderFields() const PrivateFrame::PrivateFrame(const ByteVector &data, Header *h) : Frame(h), - d(new PrivateFramePrivate()) + d(std::make_unique()) { parseFields(fieldData(data)); } diff --git a/taglib/mpeg/id3v2/frames/privateframe.h b/taglib/mpeg/id3v2/frames/privateframe.h index a1765902..24d5ae5e 100644 --- a/taglib/mpeg/id3v2/frames/privateframe.h +++ b/taglib/mpeg/id3v2/frames/privateframe.h @@ -58,6 +58,9 @@ namespace TagLib { */ ~PrivateFrame() override; + PrivateFrame(const PrivateFrame &) = delete; + PrivateFrame &operator=(const PrivateFrame &) = delete; + /*! * Returns the text of this private frame, currently just the owner. * @@ -99,11 +102,8 @@ namespace TagLib { */ PrivateFrame(const ByteVector &data, Header *h); - PrivateFrame(const PrivateFrame &) = delete; - PrivateFrame &operator=(const PrivateFrame &) = delete; - class PrivateFramePrivate; - PrivateFramePrivate *d; + std::unique_ptr d; }; } // namespace ID3v2 diff --git a/taglib/mpeg/id3v2/frames/relativevolumeframe.cpp b/taglib/mpeg/id3v2/frames/relativevolumeframe.cpp index 34317851..8cb63158 100644 --- a/taglib/mpeg/id3v2/frames/relativevolumeframe.cpp +++ b/taglib/mpeg/id3v2/frames/relativevolumeframe.cpp @@ -53,21 +53,18 @@ public: RelativeVolumeFrame::RelativeVolumeFrame() : Frame("RVA2"), - d(new RelativeVolumeFramePrivate()) + d(std::make_unique()) { } RelativeVolumeFrame::RelativeVolumeFrame(const ByteVector &data) : Frame(data), - d(new RelativeVolumeFramePrivate()) + d(std::make_unique()) { setData(data); } -RelativeVolumeFrame::~RelativeVolumeFrame() -{ - delete d; -} +RelativeVolumeFrame::~RelativeVolumeFrame() = default; String RelativeVolumeFrame::toString() const { @@ -180,7 +177,7 @@ ByteVector RelativeVolumeFrame::renderFields() const RelativeVolumeFrame::RelativeVolumeFrame(const ByteVector &data, Header *h) : Frame(h), - d(new RelativeVolumeFramePrivate()) + d(std::make_unique()) { parseFields(fieldData(data)); } diff --git a/taglib/mpeg/id3v2/frames/relativevolumeframe.h b/taglib/mpeg/id3v2/frames/relativevolumeframe.h index 01f65ea3..9225b1e6 100644 --- a/taglib/mpeg/id3v2/frames/relativevolumeframe.h +++ b/taglib/mpeg/id3v2/frames/relativevolumeframe.h @@ -116,6 +116,9 @@ namespace TagLib { */ ~RelativeVolumeFrame() override; + RelativeVolumeFrame(const RelativeVolumeFrame &) = delete; + RelativeVolumeFrame &operator=(const RelativeVolumeFrame &) = delete; + /*! * Returns the frame's identification. * @@ -219,11 +222,9 @@ namespace TagLib { private: RelativeVolumeFrame(const ByteVector &data, Header *h); - RelativeVolumeFrame(const RelativeVolumeFrame &) = delete; - RelativeVolumeFrame &operator=(const RelativeVolumeFrame &) = delete; class RelativeVolumeFramePrivate; - RelativeVolumeFramePrivate *d; + std::unique_ptr d; }; } // namespace ID3v2 diff --git a/taglib/mpeg/id3v2/frames/synchronizedlyricsframe.cpp b/taglib/mpeg/id3v2/frames/synchronizedlyricsframe.cpp index bf7e3ab2..d89a8b95 100644 --- a/taglib/mpeg/id3v2/frames/synchronizedlyricsframe.cpp +++ b/taglib/mpeg/id3v2/frames/synchronizedlyricsframe.cpp @@ -53,22 +53,19 @@ public: SynchronizedLyricsFrame::SynchronizedLyricsFrame(String::Type encoding) : Frame("SYLT"), - d(new SynchronizedLyricsFramePrivate()) + d(std::make_unique()) { d->textEncoding = encoding; } SynchronizedLyricsFrame::SynchronizedLyricsFrame(const ByteVector &data) : Frame(data), - d(new SynchronizedLyricsFramePrivate()) + d(std::make_unique()) { setData(data); } -SynchronizedLyricsFrame::~SynchronizedLyricsFrame() -{ - delete d; -} +SynchronizedLyricsFrame::~SynchronizedLyricsFrame() = default; String SynchronizedLyricsFrame::toString() const { @@ -234,7 +231,7 @@ ByteVector SynchronizedLyricsFrame::renderFields() const SynchronizedLyricsFrame::SynchronizedLyricsFrame(const ByteVector &data, Header *h) : Frame(h), - d(new SynchronizedLyricsFramePrivate()) + d(std::make_unique()) { parseFields(fieldData(data)); } diff --git a/taglib/mpeg/id3v2/frames/synchronizedlyricsframe.h b/taglib/mpeg/id3v2/frames/synchronizedlyricsframe.h index 71d852db..c1e87366 100644 --- a/taglib/mpeg/id3v2/frames/synchronizedlyricsframe.h +++ b/taglib/mpeg/id3v2/frames/synchronizedlyricsframe.h @@ -112,6 +112,9 @@ namespace TagLib { */ ~SynchronizedLyricsFrame() override; + SynchronizedLyricsFrame(const SynchronizedLyricsFrame &) = delete; + SynchronizedLyricsFrame &operator=(const SynchronizedLyricsFrame &) = delete; + /*! * Returns the description of this synchronized lyrics frame. * @@ -220,11 +223,9 @@ namespace TagLib { * The constructor used by the FrameFactory. */ SynchronizedLyricsFrame(const ByteVector &data, Header *h); - SynchronizedLyricsFrame(const SynchronizedLyricsFrame &) = delete; - SynchronizedLyricsFrame &operator=(const SynchronizedLyricsFrame &) = delete; class SynchronizedLyricsFramePrivate; - SynchronizedLyricsFramePrivate *d; + std::unique_ptr d; }; } // namespace ID3v2 diff --git a/taglib/mpeg/id3v2/frames/tableofcontentsframe.cpp b/taglib/mpeg/id3v2/frames/tableofcontentsframe.cpp index d9f173c8..e47b948b 100644 --- a/taglib/mpeg/id3v2/frames/tableofcontentsframe.cpp +++ b/taglib/mpeg/id3v2/frames/tableofcontentsframe.cpp @@ -83,7 +83,7 @@ namespace { TableOfContentsFrame::TableOfContentsFrame(const ID3v2::Header *tagHeader, const ByteVector &data) : ID3v2::Frame(data), - d(new TableOfContentsFramePrivate()) + d(std::make_unique()) { d->tagHeader = tagHeader; setData(data); @@ -93,7 +93,7 @@ TableOfContentsFrame::TableOfContentsFrame(const ByteVector &elementID, const ByteVectorList &children, const FrameList &embeddedFrames) : ID3v2::Frame("CTOC"), - d(new TableOfContentsFramePrivate()) + d(std::make_unique()) { d->elementID = elementID; strip(d->elementID); @@ -103,10 +103,7 @@ TableOfContentsFrame::TableOfContentsFrame(const ByteVector &elementID, addEmbeddedFrame(*it); } -TableOfContentsFrame::~TableOfContentsFrame() -{ - delete d; -} +TableOfContentsFrame::~TableOfContentsFrame() = default; ByteVector TableOfContentsFrame::elementID() const { @@ -349,7 +346,7 @@ ByteVector TableOfContentsFrame::renderFields() const TableOfContentsFrame::TableOfContentsFrame(const ID3v2::Header *tagHeader, const ByteVector &data, Header *h) : Frame(h), - d(new TableOfContentsFramePrivate()) + d(std::make_unique()) { d->tagHeader = tagHeader; parseFields(fieldData(data)); diff --git a/taglib/mpeg/id3v2/frames/tableofcontentsframe.h b/taglib/mpeg/id3v2/frames/tableofcontentsframe.h index f29b0abc..eb3a95e6 100644 --- a/taglib/mpeg/id3v2/frames/tableofcontentsframe.h +++ b/taglib/mpeg/id3v2/frames/tableofcontentsframe.h @@ -67,6 +67,9 @@ namespace TagLib { */ ~TableOfContentsFrame() override; + TableOfContentsFrame(const TableOfContentsFrame &) = delete; + TableOfContentsFrame &operator=(const TableOfContentsFrame &) = delete; + /*! * Returns the elementID of the frame. Element ID * is a null terminated string, however it's not human-readable. @@ -248,11 +251,9 @@ namespace TagLib { private: TableOfContentsFrame(const ID3v2::Header *tagHeader, const ByteVector &data, Header *h); - TableOfContentsFrame(const TableOfContentsFrame &) = delete; - TableOfContentsFrame &operator=(const TableOfContentsFrame &) = delete; class TableOfContentsFramePrivate; - TableOfContentsFramePrivate *d; + std::unique_ptr d; }; } // namespace ID3v2 } // namespace TagLib diff --git a/taglib/mpeg/id3v2/frames/textidentificationframe.cpp b/taglib/mpeg/id3v2/frames/textidentificationframe.cpp index adc410c4..181da84d 100644 --- a/taglib/mpeg/id3v2/frames/textidentificationframe.cpp +++ b/taglib/mpeg/id3v2/frames/textidentificationframe.cpp @@ -42,20 +42,24 @@ public: StringList fieldList; }; +class UserTextIdentificationFrame::UserTextIdentificationFramePrivate +{ +}; + //////////////////////////////////////////////////////////////////////////////// // TextIdentificationFrame public members //////////////////////////////////////////////////////////////////////////////// TextIdentificationFrame::TextIdentificationFrame(const ByteVector &type, String::Type encoding) : Frame(type), - d(new TextIdentificationFramePrivate()) + d(std::make_unique()) { d->textEncoding = encoding; } TextIdentificationFrame::TextIdentificationFrame(const ByteVector &data) : Frame(data), - d(new TextIdentificationFramePrivate()) + d(std::make_unique()) { setData(data); } @@ -89,10 +93,7 @@ TextIdentificationFrame *TextIdentificationFrame::createTMCLFrame(const Property return frame; } -TextIdentificationFrame::~TextIdentificationFrame() -{ - delete d; -} +TextIdentificationFrame::~TextIdentificationFrame() = default; void TextIdentificationFrame::setText(const StringList &l) { @@ -278,7 +279,7 @@ ByteVector TextIdentificationFrame::renderFields() const TextIdentificationFrame::TextIdentificationFrame(const ByteVector &data, Header *h) : Frame(h), - d(new TextIdentificationFramePrivate()) + d(std::make_unique()) { parseFields(fieldData(data)); } @@ -336,9 +337,10 @@ PropertyMap TextIdentificationFrame::makeTMCLProperties() const // UserTextIdentificationFrame public members //////////////////////////////////////////////////////////////////////////////// +UserTextIdentificationFrame::~UserTextIdentificationFrame() = default; + UserTextIdentificationFrame::UserTextIdentificationFrame(String::Type encoding) : - TextIdentificationFrame("TXXX", encoding), - d(nullptr) + TextIdentificationFrame("TXXX", encoding) { StringList l; l.append(String()); @@ -354,8 +356,7 @@ UserTextIdentificationFrame::UserTextIdentificationFrame(const ByteVector &data) } UserTextIdentificationFrame::UserTextIdentificationFrame(const String &description, const StringList &values, String::Type encoding) : - TextIdentificationFrame("TXXX", encoding), - d(nullptr) + TextIdentificationFrame("TXXX", encoding) { setDescription(description); setText(values); diff --git a/taglib/mpeg/id3v2/frames/textidentificationframe.h b/taglib/mpeg/id3v2/frames/textidentificationframe.h index ee338d40..5314a7c5 100644 --- a/taglib/mpeg/id3v2/frames/textidentificationframe.h +++ b/taglib/mpeg/id3v2/frames/textidentificationframe.h @@ -144,6 +144,9 @@ namespace TagLib { */ ~TextIdentificationFrame() override; + TextIdentificationFrame(const TextIdentificationFrame &) = delete; + TextIdentificationFrame &operator=(const TextIdentificationFrame &) = delete; + /*! * Text identification frames are a list of string fields. * @@ -209,9 +212,6 @@ namespace TagLib { TextIdentificationFrame(const ByteVector &data, Header *h); private: - TextIdentificationFrame(const TextIdentificationFrame &) = delete; - TextIdentificationFrame &operator=(const TextIdentificationFrame &) = delete; - /*! * Parses the special structure of a TIPL frame * Only the whitelisted roles "ARRANGER", "ENGINEER", "PRODUCER", @@ -223,7 +223,7 @@ namespace TagLib { */ PropertyMap makeTMCLProperties() const; class TextIdentificationFramePrivate; - TextIdentificationFramePrivate *d; + std::unique_ptr d; }; /*! @@ -258,6 +258,11 @@ namespace TagLib { */ UserTextIdentificationFrame(const String &description, const StringList &values, String::Type encoding = String::UTF8); + ~UserTextIdentificationFrame() override; + + UserTextIdentificationFrame(const UserTextIdentificationFrame &) = delete; + UserTextIdentificationFrame &operator=(const UserTextIdentificationFrame &) = delete; + String toString() const override; /*! @@ -300,12 +305,11 @@ namespace TagLib { private: UserTextIdentificationFrame(const ByteVector &data, Header *h); UserTextIdentificationFrame(const TextIdentificationFrame &); - UserTextIdentificationFrame &operator=(const UserTextIdentificationFrame &); void checkFields(); class UserTextIdentificationFramePrivate; - UserTextIdentificationFramePrivate *d; + std::unique_ptr d; }; } // namespace ID3v2 diff --git a/taglib/mpeg/id3v2/frames/uniquefileidentifierframe.cpp b/taglib/mpeg/id3v2/frames/uniquefileidentifierframe.cpp index dff16539..33fd4ad9 100644 --- a/taglib/mpeg/id3v2/frames/uniquefileidentifierframe.cpp +++ b/taglib/mpeg/id3v2/frames/uniquefileidentifierframe.cpp @@ -47,23 +47,20 @@ public: UniqueFileIdentifierFrame::UniqueFileIdentifierFrame(const ByteVector &data) : ID3v2::Frame(data), - d(new UniqueFileIdentifierFramePrivate()) + d(std::make_unique()) { setData(data); } UniqueFileIdentifierFrame::UniqueFileIdentifierFrame(const String &owner, const ByteVector &id) : ID3v2::Frame("UFID"), - d(new UniqueFileIdentifierFramePrivate()) + d(std::make_unique()) { d->owner = owner; d->identifier = id; } -UniqueFileIdentifierFrame::~UniqueFileIdentifierFrame() -{ - delete d; -} +UniqueFileIdentifierFrame::~UniqueFileIdentifierFrame() = default; String UniqueFileIdentifierFrame::owner() const { @@ -141,7 +138,7 @@ ByteVector UniqueFileIdentifierFrame::renderFields() const UniqueFileIdentifierFrame::UniqueFileIdentifierFrame(const ByteVector &data, Header *h) : Frame(h), - d(new UniqueFileIdentifierFramePrivate()) + d(std::make_unique()) { parseFields(fieldData(data)); } diff --git a/taglib/mpeg/id3v2/frames/uniquefileidentifierframe.h b/taglib/mpeg/id3v2/frames/uniquefileidentifierframe.h index 5937ff7b..bcf835f7 100644 --- a/taglib/mpeg/id3v2/frames/uniquefileidentifierframe.h +++ b/taglib/mpeg/id3v2/frames/uniquefileidentifierframe.h @@ -61,6 +61,9 @@ namespace TagLib { */ ~UniqueFileIdentifierFrame() override; + UniqueFileIdentifierFrame(const UniqueFileIdentifierFrame &) = delete; + UniqueFileIdentifierFrame &operator=(const UniqueFileIdentifierFrame &) = delete; + /*! * Returns the owner for the frame; essentially this is the key for * determining which identification scheme this key belongs to. This @@ -109,13 +112,10 @@ namespace TagLib { ByteVector renderFields() const override; private: - UniqueFileIdentifierFrame(const UniqueFileIdentifierFrame &) = delete; - UniqueFileIdentifierFrame &operator=(const UniqueFileIdentifierFrame &) = delete; - UniqueFileIdentifierFrame(const ByteVector &data, Header *h); class UniqueFileIdentifierFramePrivate; - UniqueFileIdentifierFramePrivate *d; + std::unique_ptr d; }; } // namespace ID3v2 } // namespace TagLib diff --git a/taglib/mpeg/id3v2/frames/unknownframe.cpp b/taglib/mpeg/id3v2/frames/unknownframe.cpp index edb30084..8ccc6427 100644 --- a/taglib/mpeg/id3v2/frames/unknownframe.cpp +++ b/taglib/mpeg/id3v2/frames/unknownframe.cpp @@ -40,15 +40,12 @@ public: UnknownFrame::UnknownFrame(const ByteVector &data) : Frame(data), - d(new UnknownFramePrivate()) + d(std::make_unique()) { setData(data); } -UnknownFrame::~UnknownFrame() -{ - delete d; -} +UnknownFrame::~UnknownFrame() = default; String UnknownFrame::toString() const { @@ -80,7 +77,7 @@ ByteVector UnknownFrame::renderFields() const UnknownFrame::UnknownFrame(const ByteVector &data, Header *h) : Frame(h), - d(new UnknownFramePrivate()) + d(std::make_unique()) { parseFields(fieldData(data)); } diff --git a/taglib/mpeg/id3v2/frames/unknownframe.h b/taglib/mpeg/id3v2/frames/unknownframe.h index 7d64b5d8..7d8e2e15 100644 --- a/taglib/mpeg/id3v2/frames/unknownframe.h +++ b/taglib/mpeg/id3v2/frames/unknownframe.h @@ -54,6 +54,9 @@ namespace TagLib { UnknownFrame(const ByteVector &data); ~UnknownFrame() override; + UnknownFrame(const UnknownFrame &) = delete; + UnknownFrame &operator=(const UnknownFrame &) = delete; + String toString() const override; /*! @@ -67,11 +70,9 @@ namespace TagLib { private: UnknownFrame(const ByteVector &data, Header *h); - UnknownFrame(const UnknownFrame &) = delete; - UnknownFrame &operator=(const UnknownFrame &) = delete; class UnknownFramePrivate; - UnknownFramePrivate *d; + std::unique_ptr d; }; } // namespace ID3v2 diff --git a/taglib/mpeg/id3v2/frames/unsynchronizedlyricsframe.cpp b/taglib/mpeg/id3v2/frames/unsynchronizedlyricsframe.cpp index c3b7204f..50e796a0 100644 --- a/taglib/mpeg/id3v2/frames/unsynchronizedlyricsframe.cpp +++ b/taglib/mpeg/id3v2/frames/unsynchronizedlyricsframe.cpp @@ -51,22 +51,19 @@ public: UnsynchronizedLyricsFrame::UnsynchronizedLyricsFrame(String::Type encoding) : Frame("USLT"), - d(new UnsynchronizedLyricsFramePrivate()) + d(std::make_unique()) { d->textEncoding = encoding; } UnsynchronizedLyricsFrame::UnsynchronizedLyricsFrame(const ByteVector &data) : Frame(data), - d(new UnsynchronizedLyricsFramePrivate()) + d(std::make_unique()) { setData(data); } -UnsynchronizedLyricsFrame::~UnsynchronizedLyricsFrame() -{ - delete d; -} +UnsynchronizedLyricsFrame::~UnsynchronizedLyricsFrame() = default; String UnsynchronizedLyricsFrame::toString() const { @@ -192,7 +189,7 @@ ByteVector UnsynchronizedLyricsFrame::renderFields() const UnsynchronizedLyricsFrame::UnsynchronizedLyricsFrame(const ByteVector &data, Header *h) : Frame(h), - d(new UnsynchronizedLyricsFramePrivate()) + d(std::make_unique()) { parseFields(fieldData(data)); } diff --git a/taglib/mpeg/id3v2/frames/unsynchronizedlyricsframe.h b/taglib/mpeg/id3v2/frames/unsynchronizedlyricsframe.h index a034a5d3..90e75254 100644 --- a/taglib/mpeg/id3v2/frames/unsynchronizedlyricsframe.h +++ b/taglib/mpeg/id3v2/frames/unsynchronizedlyricsframe.h @@ -59,6 +59,9 @@ namespace TagLib { */ ~UnsynchronizedLyricsFrame() override; + UnsynchronizedLyricsFrame(const UnsynchronizedLyricsFrame &) = delete; + UnsynchronizedLyricsFrame &operator=(const UnsynchronizedLyricsFrame &) = delete; + /*! * Returns the text of this unsynchronized lyrics frame. * @@ -167,11 +170,9 @@ namespace TagLib { * The constructor used by the FrameFactory. */ UnsynchronizedLyricsFrame(const ByteVector &data, Header *h); - UnsynchronizedLyricsFrame(const UnsynchronizedLyricsFrame &) = delete; - UnsynchronizedLyricsFrame &operator=(const UnsynchronizedLyricsFrame &) = delete; class UnsynchronizedLyricsFramePrivate; - UnsynchronizedLyricsFramePrivate *d; + std::unique_ptr d; }; } // namespace ID3v2 diff --git a/taglib/mpeg/id3v2/frames/urllinkframe.cpp b/taglib/mpeg/id3v2/frames/urllinkframe.cpp index ea502caa..ea4cc4d9 100644 --- a/taglib/mpeg/id3v2/frames/urllinkframe.cpp +++ b/taglib/mpeg/id3v2/frames/urllinkframe.cpp @@ -55,15 +55,12 @@ public: UrlLinkFrame::UrlLinkFrame(const ByteVector &data) : Frame(data), - d(new UrlLinkFramePrivate()) + d(std::make_unique()) { setData(data); } -UrlLinkFrame::~UrlLinkFrame() -{ - delete d; -} +UrlLinkFrame::~UrlLinkFrame() = default; void UrlLinkFrame::setUrl(const String &s) { @@ -113,7 +110,7 @@ ByteVector UrlLinkFrame::renderFields() const UrlLinkFrame::UrlLinkFrame(const ByteVector &data, Header *h) : Frame(h), - d(new UrlLinkFramePrivate()) + d(std::make_unique()) { parseFields(fieldData(data)); } @@ -124,22 +121,19 @@ UrlLinkFrame::UrlLinkFrame(const ByteVector &data, Header *h) : UserUrlLinkFrame::UserUrlLinkFrame(String::Type encoding) : UrlLinkFrame("WXXX"), - d(new UserUrlLinkFramePrivate()) + d(std::make_unique()) { d->textEncoding = encoding; } UserUrlLinkFrame::UserUrlLinkFrame(const ByteVector &data) : UrlLinkFrame(data), - d(new UserUrlLinkFramePrivate()) + d(std::make_unique()) { setData(data); } -UserUrlLinkFrame::~UserUrlLinkFrame() -{ - delete d; -} +UserUrlLinkFrame::~UserUrlLinkFrame() = default; String UserUrlLinkFrame::toString() const { @@ -240,7 +234,7 @@ ByteVector UserUrlLinkFrame::renderFields() const UserUrlLinkFrame::UserUrlLinkFrame(const ByteVector &data, Header *h) : UrlLinkFrame(data, h), - d(new UserUrlLinkFramePrivate()) + d(std::make_unique()) { parseFields(fieldData(data)); } diff --git a/taglib/mpeg/id3v2/frames/urllinkframe.h b/taglib/mpeg/id3v2/frames/urllinkframe.h index 4300ee04..6c2d85eb 100644 --- a/taglib/mpeg/id3v2/frames/urllinkframe.h +++ b/taglib/mpeg/id3v2/frames/urllinkframe.h @@ -55,6 +55,9 @@ namespace TagLib { */ ~UrlLinkFrame() override; + UrlLinkFrame(const UrlLinkFrame &) = delete; + UrlLinkFrame &operator=(const UrlLinkFrame &) = delete; + /*! * Returns the URL. */ @@ -81,11 +84,8 @@ namespace TagLib { UrlLinkFrame(const ByteVector &data, Header *h); private: - UrlLinkFrame(const UrlLinkFrame &) = delete; - UrlLinkFrame &operator=(const UrlLinkFrame &) = delete; - class UrlLinkFramePrivate; - UrlLinkFramePrivate *d; + std::unique_ptr d; }; //! ID3v2 User defined URL frame @@ -119,6 +119,9 @@ namespace TagLib { */ ~UserUrlLinkFrame() override; + UserUrlLinkFrame(const UserUrlLinkFrame &) = delete; + UserUrlLinkFrame &operator=(const UserUrlLinkFrame &) = delete; + // Reimplementations. String toString() const override; @@ -178,11 +181,8 @@ namespace TagLib { UserUrlLinkFrame(const ByteVector &data, Header *h); private: - UserUrlLinkFrame(const UserUrlLinkFrame &) = delete; - UserUrlLinkFrame &operator=(const UserUrlLinkFrame &) = delete; - class UserUrlLinkFramePrivate; - UserUrlLinkFramePrivate *d; + std::unique_ptr d; }; } // namespace ID3v2 diff --git a/taglib/mpeg/id3v2/id3v2extendedheader.cpp b/taglib/mpeg/id3v2/id3v2extendedheader.cpp index 86eeee28..907dc0a7 100644 --- a/taglib/mpeg/id3v2/id3v2extendedheader.cpp +++ b/taglib/mpeg/id3v2/id3v2extendedheader.cpp @@ -42,14 +42,11 @@ public: //////////////////////////////////////////////////////////////////////////////// ExtendedHeader::ExtendedHeader() : - d(new ExtendedHeaderPrivate()) + d(std::make_unique()) { } -ExtendedHeader::~ExtendedHeader() -{ - delete d; -} +ExtendedHeader::~ExtendedHeader() = default; unsigned int ExtendedHeader::size() const { diff --git a/taglib/mpeg/id3v2/id3v2extendedheader.h b/taglib/mpeg/id3v2/id3v2extendedheader.h index 64cf79f0..6d075f35 100644 --- a/taglib/mpeg/id3v2/id3v2extendedheader.h +++ b/taglib/mpeg/id3v2/id3v2extendedheader.h @@ -58,6 +58,9 @@ namespace TagLib { */ virtual ~ExtendedHeader(); + ExtendedHeader(const ExtendedHeader &) = delete; + ExtendedHeader &operator=(const ExtendedHeader &) = delete; + /*! * Returns the size of the extended header. This is variable for the * extended header. @@ -81,11 +84,8 @@ namespace TagLib { void parse(const ByteVector &data); private: - ExtendedHeader(const ExtendedHeader &) = delete; - ExtendedHeader &operator=(const ExtendedHeader &) = delete; - class ExtendedHeaderPrivate; - ExtendedHeaderPrivate *d; + std::unique_ptr d; }; } // namespace ID3v2 diff --git a/taglib/mpeg/id3v2/id3v2footer.cpp b/taglib/mpeg/id3v2/id3v2footer.cpp index 78f7ea94..2eb14807 100644 --- a/taglib/mpeg/id3v2/id3v2footer.cpp +++ b/taglib/mpeg/id3v2/id3v2footer.cpp @@ -33,10 +33,7 @@ class Footer::FooterPrivate { }; -Footer::Footer() : - d(nullptr) -{ -} +Footer::Footer() = default; Footer::~Footer() = default; diff --git a/taglib/mpeg/id3v2/id3v2footer.h b/taglib/mpeg/id3v2/id3v2footer.h index a537eb37..a36ba107 100644 --- a/taglib/mpeg/id3v2/id3v2footer.h +++ b/taglib/mpeg/id3v2/id3v2footer.h @@ -59,6 +59,9 @@ namespace TagLib { */ virtual ~Footer(); + Footer(const Footer &) = delete; + Footer &operator=(const Footer &) = delete; + /*! * Returns the size of the footer. Presently this is always 10 bytes. */ @@ -70,11 +73,8 @@ namespace TagLib { ByteVector render(const Header *header) const; private: - Footer(const Footer &) = delete; - Footer &operator=(const Footer &) = delete; - class FooterPrivate; - FooterPrivate *d; + std::unique_ptr d; }; } // namespace ID3v2 diff --git a/taglib/mpeg/id3v2/id3v2frame.cpp b/taglib/mpeg/id3v2/id3v2frame.cpp index d986e781..26ae8c3e 100644 --- a/taglib/mpeg/id3v2/id3v2frame.cpp +++ b/taglib/mpeg/id3v2/id3v2frame.cpp @@ -59,6 +59,9 @@ public: delete header; } + FramePrivate(const FramePrivate &) = delete; + FramePrivate &operator=(const FramePrivate &) = delete; + Frame::Header *header; }; @@ -153,10 +156,7 @@ Frame *Frame::createTextualFrame(const String &key, const StringList &values) // return new UserTextIdentificationFrame(keyToTXXX(key), values, String::UTF8); } -Frame::~Frame() -{ - delete d; -} +Frame::~Frame() = default; ByteVector Frame::frameID() const { @@ -196,13 +196,13 @@ ByteVector Frame::render() const //////////////////////////////////////////////////////////////////////////////// Frame::Frame(const ByteVector &data) : - d(new FramePrivate()) + d(std::make_unique()) { d->header = new Header(data); } Frame::Frame(Header *h) : - d(new FramePrivate()) + d(std::make_unique()) { d->header = h; } @@ -539,15 +539,12 @@ unsigned int Frame::Header::size() } Frame::Header::Header(const ByteVector &data, unsigned int version) : - d(new HeaderPrivate()) + d(std::make_unique()) { setData(data, version); } -Frame::Header::~Header() -{ - delete d; -} +Frame::Header::~Header() = default; void Frame::Header::setData(const ByteVector &data, unsigned int version) { diff --git a/taglib/mpeg/id3v2/id3v2frame.h b/taglib/mpeg/id3v2/id3v2frame.h index d6d267e7..7e59a002 100644 --- a/taglib/mpeg/id3v2/id3v2frame.h +++ b/taglib/mpeg/id3v2/id3v2frame.h @@ -72,6 +72,9 @@ namespace TagLib { */ virtual ~Frame(); + Frame(const Frame &) = delete; + Frame &operator=(const Frame &) = delete; + /*! * Returns the Frame ID (Structure, 4) * (Frames, 4) @@ -272,12 +275,9 @@ namespace TagLib { PropertyMap &tiplProperties, PropertyMap &tmclProperties); private: - Frame(const Frame &) = delete; - Frame &operator=(const Frame &) = delete; - class FramePrivate; friend class FramePrivate; - FramePrivate *d; + std::unique_ptr d; }; //! ID3v2 frame header implementation @@ -311,6 +311,9 @@ namespace TagLib { */ virtual ~Header(); + Header(const Header &) = delete; + Header &operator=(const Header &) = delete; + /*! * Sets the data for the Header. \a version should indicate the ID3v2 * version number of the tag that this frame is contained in. @@ -440,11 +443,8 @@ namespace TagLib { ByteVector render() const; private: - Header(const Header &) = delete; - Header &operator=(const Header &) = delete; - class HeaderPrivate; - HeaderPrivate *d; + std::unique_ptr d; }; } // namespace ID3v2 diff --git a/taglib/mpeg/id3v2/id3v2framefactory.cpp b/taglib/mpeg/id3v2/id3v2framefactory.cpp index e6c8bd9d..4f03c142 100644 --- a/taglib/mpeg/id3v2/id3v2framefactory.cpp +++ b/taglib/mpeg/id3v2/id3v2framefactory.cpp @@ -382,14 +382,11 @@ void FrameFactory::setDefaultTextEncoding(String::Type encoding) //////////////////////////////////////////////////////////////////////////////// FrameFactory::FrameFactory() : - d(new FrameFactoryPrivate()) + d(std::make_unique()) { } -FrameFactory::~FrameFactory() -{ - delete d; -} +FrameFactory::~FrameFactory() = default; namespace { diff --git a/taglib/mpeg/id3v2/id3v2framefactory.h b/taglib/mpeg/id3v2/id3v2framefactory.h index 7a2ed610..733ad533 100644 --- a/taglib/mpeg/id3v2/id3v2framefactory.h +++ b/taglib/mpeg/id3v2/id3v2framefactory.h @@ -65,6 +65,9 @@ namespace TagLib { class TAGLIB_EXPORT FrameFactory { public: + FrameFactory(const FrameFactory &) = delete; + FrameFactory &operator=(const FrameFactory &) = delete; + static FrameFactory *instance(); /*! @@ -153,13 +156,10 @@ namespace TagLib { const Header *tagHeader) const; private: - FrameFactory(const FrameFactory &) = delete; - FrameFactory &operator=(const FrameFactory &) = delete; - static FrameFactory factory; class FrameFactoryPrivate; - FrameFactoryPrivate *d; + std::unique_ptr d; }; } // namespace ID3v2 diff --git a/taglib/mpeg/id3v2/id3v2header.cpp b/taglib/mpeg/id3v2/id3v2header.cpp index 46574ef3..e608b200 100644 --- a/taglib/mpeg/id3v2/id3v2header.cpp +++ b/taglib/mpeg/id3v2/id3v2header.cpp @@ -79,20 +79,17 @@ ByteVector Header::fileIdentifier() //////////////////////////////////////////////////////////////////////////////// Header::Header() : - d(new HeaderPrivate()) + d(std::make_unique()) { } Header::Header(const ByteVector &data) : - d(new HeaderPrivate()) + d(std::make_unique()) { parse(data); } -Header::~Header() -{ - delete d; -} +Header::~Header() = default; unsigned int Header::majorVersion() const { diff --git a/taglib/mpeg/id3v2/id3v2header.h b/taglib/mpeg/id3v2/id3v2header.h index fc4babe5..5ea58df9 100644 --- a/taglib/mpeg/id3v2/id3v2header.h +++ b/taglib/mpeg/id3v2/id3v2header.h @@ -64,6 +64,9 @@ namespace TagLib { */ virtual ~Header(); + Header(const Header &) = delete; + Header &operator=(const Header &) = delete; + /*! * Returns the major version number. (Note: This is the 4, not the 2 in * ID3v2.4.0. The 2 is implied.) @@ -163,11 +166,8 @@ namespace TagLib { void parse(const ByteVector &data); private: - Header(const Header &) = delete; - Header &operator=(const Header &) = delete; - class HeaderPrivate; - HeaderPrivate *d; + std::unique_ptr d; }; } // namespace ID3v2 diff --git a/taglib/mpeg/id3v2/id3v2tag.cpp b/taglib/mpeg/id3v2/id3v2tag.cpp index e8a48c36..37601803 100644 --- a/taglib/mpeg/id3v2/id3v2tag.cpp +++ b/taglib/mpeg/id3v2/id3v2tag.cpp @@ -86,6 +86,9 @@ public: delete footer; } + TagPrivate(const TagPrivate &) = delete; + TagPrivate &operator=(const TagPrivate &) = delete; + const FrameFactory *factory; File *file; @@ -99,6 +102,10 @@ public: FrameList frameList; }; +class ID3v2::Latin1StringHandler::Latin1StringHandlerPrivate +{ +}; + //////////////////////////////////////////////////////////////////////////////// // StringHandler implementation //////////////////////////////////////////////////////////////////////////////// @@ -117,13 +124,13 @@ String Latin1StringHandler::parse(const ByteVector &data) const //////////////////////////////////////////////////////////////////////////////// ID3v2::Tag::Tag() : - d(new TagPrivate()) + d(std::make_unique()) { d->factory = FrameFactory::instance(); } ID3v2::Tag::Tag(File *file, offset_t tagOffset, const FrameFactory *factory) : - d(new TagPrivate()) + d(std::make_unique()) { d->factory = factory; d->file = file; @@ -132,10 +139,7 @@ ID3v2::Tag::Tag(File *file, offset_t tagOffset, const FrameFactory *factory) : read(); } -ID3v2::Tag::~Tag() -{ - delete d; -} +ID3v2::Tag::~Tag() = default; String ID3v2::Tag::title() const { diff --git a/taglib/mpeg/id3v2/id3v2tag.h b/taglib/mpeg/id3v2/id3v2tag.h index 7bbc9f12..e50bef35 100644 --- a/taglib/mpeg/id3v2/id3v2tag.h +++ b/taglib/mpeg/id3v2/id3v2tag.h @@ -70,6 +70,8 @@ namespace TagLib { public: Latin1StringHandler(); virtual ~Latin1StringHandler(); + Latin1StringHandler(const Latin1StringHandler &) = delete; + Latin1StringHandler &operator=(const Latin1StringHandler &) = delete; /*! * Decode a string from \a data. The default implementation assumes that @@ -79,7 +81,7 @@ namespace TagLib { private: class Latin1StringHandlerPrivate; - Latin1StringHandlerPrivate *d; + std::unique_ptr d; }; //! The main class in the ID3v2 implementation @@ -157,6 +159,9 @@ namespace TagLib { */ ~Tag() override; + Tag(const Tag &) = delete; + Tag &operator=(const Tag &) = delete; + // Reimplementations. String title() const override; @@ -386,11 +391,8 @@ namespace TagLib { void downgradeFrames(FrameList *existingFrames, FrameList *newFrames) const; private: - Tag(const Tag &) = delete; - Tag &operator=(const Tag &) = delete; - class TagPrivate; - TagPrivate *d; + std::unique_ptr d; }; } // namespace ID3v2 diff --git a/taglib/mpeg/mpegfile.cpp b/taglib/mpeg/mpegfile.cpp index bf45bb42..c792698e 100644 --- a/taglib/mpeg/mpegfile.cpp +++ b/taglib/mpeg/mpegfile.cpp @@ -62,6 +62,9 @@ public: delete properties; } + FilePrivate(const FilePrivate &) = delete; + FilePrivate &operator=(const FilePrivate &) = delete; + const ID3v2::FrameFactory *ID3v2FrameFactory; offset_t ID3v2Location; @@ -135,7 +138,7 @@ bool MPEG::File::isSupported(IOStream *stream) MPEG::File::File(FileName file, bool readProperties, Properties::ReadStyle) : TagLib::File(file), - d(new FilePrivate()) + d(std::make_unique()) { if(isOpen()) read(readProperties); @@ -144,7 +147,7 @@ MPEG::File::File(FileName file, bool readProperties, Properties::ReadStyle) : MPEG::File::File(FileName file, ID3v2::FrameFactory *frameFactory, bool readProperties, Properties::ReadStyle) : TagLib::File(file), - d(new FilePrivate(frameFactory)) + d(std::make_unique(frameFactory)) { if(isOpen()) read(readProperties); @@ -153,16 +156,13 @@ MPEG::File::File(FileName file, ID3v2::FrameFactory *frameFactory, MPEG::File::File(IOStream *stream, ID3v2::FrameFactory *frameFactory, bool readProperties, Properties::ReadStyle) : TagLib::File(stream), - d(new FilePrivate(frameFactory)) + d(std::make_unique(frameFactory)) { if(isOpen()) read(readProperties); } -MPEG::File::~File() -{ - delete d; -} +MPEG::File::~File() = default; TagLib::Tag *MPEG::File::tag() const { diff --git a/taglib/mpeg/mpegfile.h b/taglib/mpeg/mpegfile.h index a56aba8f..cf26a3bf 100644 --- a/taglib/mpeg/mpegfile.h +++ b/taglib/mpeg/mpegfile.h @@ -119,6 +119,9 @@ namespace TagLib { */ ~File() override; + File(const File &) = delete; + File &operator=(const File &) = delete; + /*! * Returns a pointer to a tag that is the union of the ID3v2 and ID3v1 * tags. The ID3v2 tag is given priority in reading the information -- if @@ -320,14 +323,11 @@ namespace TagLib { static bool isSupported(IOStream *stream); private: - File(const File &) = delete; - File &operator=(const File &) = delete; - void read(bool readProperties); offset_t findID3v2(); class FilePrivate; - FilePrivate *d; + std::unique_ptr d; }; } // namespace MPEG } // namespace TagLib diff --git a/taglib/mpeg/mpegproperties.cpp b/taglib/mpeg/mpegproperties.cpp index f81e0cbc..0e58875c 100644 --- a/taglib/mpeg/mpegproperties.cpp +++ b/taglib/mpeg/mpegproperties.cpp @@ -56,6 +56,9 @@ public: delete xingHeader; } + PropertiesPrivate(const PropertiesPrivate &) = delete; + PropertiesPrivate &operator=(const PropertiesPrivate &) = delete; + XingHeader *xingHeader; int length; int bitrate; @@ -75,15 +78,12 @@ public: MPEG::Properties::Properties(File *file, ReadStyle style) : AudioProperties(style), - d(new PropertiesPrivate()) + d(std::make_unique()) { read(file); } -MPEG::Properties::~Properties() -{ - delete d; -} +MPEG::Properties::~Properties() = default; int MPEG::Properties::lengthInMilliseconds() const { diff --git a/taglib/mpeg/mpegproperties.h b/taglib/mpeg/mpegproperties.h index e0d5bec7..dbd9c56f 100644 --- a/taglib/mpeg/mpegproperties.h +++ b/taglib/mpeg/mpegproperties.h @@ -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. * @@ -118,13 +121,10 @@ namespace TagLib { bool isOriginal() const; private: - Properties(const Properties &) = delete; - Properties &operator=(const Properties &) = delete; - void read(File *file); class PropertiesPrivate; - PropertiesPrivate *d; + std::unique_ptr d; }; } // namespace MPEG } // namespace TagLib diff --git a/taglib/mpeg/xingheader.cpp b/taglib/mpeg/xingheader.cpp index 629425f6..92faa340 100644 --- a/taglib/mpeg/xingheader.cpp +++ b/taglib/mpeg/xingheader.cpp @@ -52,15 +52,12 @@ public: //////////////////////////////////////////////////////////////////////////////// MPEG::XingHeader::XingHeader(const ByteVector &data) : - d(new XingHeaderPrivate()) + d(std::make_unique()) { parse(data); } -MPEG::XingHeader::~XingHeader() -{ - delete d; -} +MPEG::XingHeader::~XingHeader() = default; bool MPEG::XingHeader::isValid() const { diff --git a/taglib/mpeg/xingheader.h b/taglib/mpeg/xingheader.h index 28cf0f56..58be461d 100644 --- a/taglib/mpeg/xingheader.h +++ b/taglib/mpeg/xingheader.h @@ -29,6 +29,8 @@ #include "mpegheader.h" #include "taglib_export.h" +#include + namespace TagLib { class ByteVector; @@ -84,6 +86,9 @@ namespace TagLib { */ virtual ~XingHeader(); + XingHeader(const XingHeader &) = delete; + XingHeader &operator=(const XingHeader &) = delete; + /*! * Returns true if the data was parsed properly and if there is a valid * Xing/VBRI header present. @@ -106,13 +111,10 @@ namespace TagLib { HeaderType type() const; private: - XingHeader(const XingHeader &) = delete; - XingHeader &operator=(const XingHeader &) = delete; - void parse(const ByteVector &data); class XingHeaderPrivate; - XingHeaderPrivate *d; + std::unique_ptr d; }; } // namespace MPEG } // namespace TagLib diff --git a/taglib/ogg/flac/oggflacfile.cpp b/taglib/ogg/flac/oggflacfile.cpp index 9b2625ca..981fc7d9 100644 --- a/taglib/ogg/flac/oggflacfile.cpp +++ b/taglib/ogg/flac/oggflacfile.cpp @@ -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()) { 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()) { if(isOpen()) read(readProperties, propertiesStyle); } -Ogg::FLAC::File::~File() -{ - delete d; -} +Ogg::FLAC::File::~File() = default; Ogg::XiphComment *Ogg::FLAC::File::tag() const { diff --git a/taglib/ogg/flac/oggflacfile.h b/taglib/ogg/flac/oggflacfile.h index e314da5a..f543ea6c 100644 --- a/taglib/ogg/flac/oggflacfile.h +++ b/taglib/ogg/flac/oggflacfile.h @@ -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 d; }; } // namespace FLAC } // namespace Ogg diff --git a/taglib/ogg/oggfile.cpp b/taglib/ogg/oggfile.cpp index 320e42b0..88bb00df 100644 --- a/taglib/ogg/oggfile.cpp +++ b/taglib/ogg/oggfile.cpp @@ -62,6 +62,9 @@ public: delete lastPageHeader; } + FilePrivate(const FilePrivate &) = delete; + FilePrivate &operator=(const FilePrivate &) = delete; + unsigned int streamSerialNumber; List 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()) { } Ogg::File::File(IOStream *stream) : TagLib::File(stream), - d(new FilePrivate()) + d(std::make_unique()) { } diff --git a/taglib/ogg/oggfile.h b/taglib/ogg/oggfile.h index b14afc06..3e5d717d 100644 --- a/taglib/ogg/oggfile.h +++ b/taglib/ogg/oggfile.h @@ -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 d; }; } // namespace Ogg diff --git a/taglib/ogg/oggpage.cpp b/taglib/ogg/oggpage.cpp index 50b2aa9b..c1e85b8f 100644 --- a/taglib/ogg/oggpage.cpp +++ b/taglib/ogg/oggpage.cpp @@ -120,14 +120,11 @@ public: //////////////////////////////////////////////////////////////////////////////// Ogg::Page::Page(Ogg::File *file, offset_t pageOffset) : - d(new PagePrivate(file, pageOffset)) + d(std::make_unique(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()) { d->header.setFirstPageOfStream(pageNumber == 0 && !firstPacketContinued); d->header.setLastPageOfStream(containsLastPacket); diff --git a/taglib/ogg/oggpage.h b/taglib/ogg/oggpage.h index ab199161..b72d59ec 100644 --- a/taglib/ogg/oggpage.h +++ b/taglib/ogg/oggpage.h @@ -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 d; }; } // namespace Ogg } // namespace TagLib diff --git a/taglib/ogg/oggpageheader.cpp b/taglib/ogg/oggpageheader.cpp index a0aa7193..b5c7af54 100644 --- a/taglib/ogg/oggpageheader.cpp +++ b/taglib/ogg/oggpageheader.cpp @@ -68,16 +68,13 @@ public: //////////////////////////////////////////////////////////////////////////////// Ogg::PageHeader::PageHeader(Ogg::File *file, offset_t pageOffset) : - d(new PageHeaderPrivate()) + d(std::make_unique()) { if(file && pageOffset >= 0) read(file, pageOffset); } -Ogg::PageHeader::~PageHeader() -{ - delete d; -} +Ogg::PageHeader::~PageHeader() = default; bool Ogg::PageHeader::isValid() const { diff --git a/taglib/ogg/oggpageheader.h b/taglib/ogg/oggpageheader.h index c3b24c10..fbc28f13 100644 --- a/taglib/ogg/oggpageheader.h +++ b/taglib/ogg/oggpageheader.h @@ -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 d; }; } // namespace Ogg diff --git a/taglib/ogg/opus/opusfile.cpp b/taglib/ogg/opus/opusfile.cpp index eb2c3a1a..d331c70f 100644 --- a/taglib/ogg/opus/opusfile.cpp +++ b/taglib/ogg/opus/opusfile.cpp @@ -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()) { 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()) { if(isOpen()) read(readProperties); } -Opus::File::~File() -{ - delete d; -} +Opus::File::~File() = default; Ogg::XiphComment *Opus::File::tag() const { diff --git a/taglib/ogg/opus/opusfile.h b/taglib/ogg/opus/opusfile.h index 5b311dda..0156f1d7 100644 --- a/taglib/ogg/opus/opusfile.h +++ b/taglib/ogg/opus/opusfile.h @@ -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 d; }; } // namespace Opus } // namespace Ogg diff --git a/taglib/ogg/opus/opusproperties.cpp b/taglib/ogg/opus/opusproperties.cpp index d0a6ceaa..b42e399d 100644 --- a/taglib/ogg/opus/opusproperties.cpp +++ b/taglib/ogg/opus/opusproperties.cpp @@ -62,15 +62,12 @@ public: Opus::Properties::Properties(File *file, ReadStyle style) : AudioProperties(style), - d(new PropertiesPrivate()) + d(std::make_unique()) { read(file); } -Opus::Properties::~Properties() -{ - delete d; -} +Opus::Properties::~Properties() = default; int Ogg::Opus::Properties::lengthInMilliseconds() const { diff --git a/taglib/ogg/opus/opusproperties.h b/taglib/ogg/opus/opusproperties.h index 5a8e8300..8c4c7910 100644 --- a/taglib/ogg/opus/opusproperties.h +++ b/taglib/ogg/opus/opusproperties.h @@ -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 d; }; } // namespace Opus } // namespace Ogg diff --git a/taglib/ogg/speex/speexfile.cpp b/taglib/ogg/speex/speexfile.cpp index fc7551d0..07583e30 100644 --- a/taglib/ogg/speex/speexfile.cpp +++ b/taglib/ogg/speex/speexfile.cpp @@ -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()) { 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()) { if(isOpen()) read(readProperties); } -Speex::File::~File() -{ - delete d; -} +Speex::File::~File() = default; Ogg::XiphComment *Speex::File::tag() const { diff --git a/taglib/ogg/speex/speexfile.h b/taglib/ogg/speex/speexfile.h index db822990..919f6233 100644 --- a/taglib/ogg/speex/speexfile.h +++ b/taglib/ogg/speex/speexfile.h @@ -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 d; }; } // namespace Speex } // namespace Ogg diff --git a/taglib/ogg/speex/speexproperties.cpp b/taglib/ogg/speex/speexproperties.cpp index f7daa2c0..6c6128f1 100644 --- a/taglib/ogg/speex/speexproperties.cpp +++ b/taglib/ogg/speex/speexproperties.cpp @@ -68,15 +68,12 @@ public: Speex::Properties::Properties(File *file, ReadStyle style) : AudioProperties(style), - d(new PropertiesPrivate()) + d(std::make_unique()) { read(file); } -Speex::Properties::~Properties() -{ - delete d; -} +Speex::Properties::~Properties() = default; int Speex::Properties::lengthInMilliseconds() const { diff --git a/taglib/ogg/speex/speexproperties.h b/taglib/ogg/speex/speexproperties.h index 8de29d88..a2beba47 100644 --- a/taglib/ogg/speex/speexproperties.h +++ b/taglib/ogg/speex/speexproperties.h @@ -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 d; }; } // namespace Speex } // namespace Ogg diff --git a/taglib/ogg/vorbis/vorbisfile.cpp b/taglib/ogg/vorbis/vorbisfile.cpp index bce42462..c5509f85 100644 --- a/taglib/ogg/vorbis/vorbisfile.cpp +++ b/taglib/ogg/vorbis/vorbisfile.cpp @@ -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()) { 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()) { if(isOpen()) read(readProperties); } -Vorbis::File::~File() -{ - delete d; -} +Vorbis::File::~File() = default; Ogg::XiphComment *Vorbis::File::tag() const { diff --git a/taglib/ogg/vorbis/vorbisfile.h b/taglib/ogg/vorbis/vorbisfile.h index d61eb452..40279de2 100644 --- a/taglib/ogg/vorbis/vorbisfile.h +++ b/taglib/ogg/vorbis/vorbisfile.h @@ -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 d; }; } // namespace Vorbis diff --git a/taglib/ogg/vorbis/vorbisproperties.cpp b/taglib/ogg/vorbis/vorbisproperties.cpp index d4b993d2..658cd700 100644 --- a/taglib/ogg/vorbis/vorbisproperties.cpp +++ b/taglib/ogg/vorbis/vorbisproperties.cpp @@ -71,15 +71,12 @@ namespace TagLib { Vorbis::Properties::Properties(File *file, ReadStyle style) : AudioProperties(style), - d(new PropertiesPrivate()) + d(std::make_unique()) { read(file); } -Vorbis::Properties::~Properties() -{ - delete d; -} +Vorbis::Properties::~Properties() = default; int Vorbis::Properties::lengthInMilliseconds() const { diff --git a/taglib/ogg/vorbis/vorbisproperties.h b/taglib/ogg/vorbis/vorbisproperties.h index 0bbf5c30..7bf82ff6 100644 --- a/taglib/ogg/vorbis/vorbisproperties.h +++ b/taglib/ogg/vorbis/vorbisproperties.h @@ -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 d; }; } // namespace Vorbis diff --git a/taglib/ogg/xiphcomment.cpp b/taglib/ogg/xiphcomment.cpp index bf7d0da5..1f326221 100644 --- a/taglib/ogg/xiphcomment.cpp +++ b/taglib/ogg/xiphcomment.cpp @@ -62,20 +62,17 @@ public: //////////////////////////////////////////////////////////////////////////////// Ogg::XiphComment::XiphComment() : - d(new XiphCommentPrivate()) + d(std::make_unique()) { } Ogg::XiphComment::XiphComment(const ByteVector &data) : - d(new XiphCommentPrivate()) + d(std::make_unique()) { parse(data); } -Ogg::XiphComment::~XiphComment() -{ - delete d; -} +Ogg::XiphComment::~XiphComment() = default; String Ogg::XiphComment::title() const { diff --git a/taglib/ogg/xiphcomment.h b/taglib/ogg/xiphcomment.h index 78ce8697..eb1a8dab 100644 --- a/taglib/ogg/xiphcomment.h +++ b/taglib/ogg/xiphcomment.h @@ -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 d; }; } // namespace Ogg } // namespace TagLib diff --git a/taglib/riff/aiff/aifffile.cpp b/taglib/riff/aiff/aifffile.cpp index 78e509cd..23069854 100644 --- a/taglib/riff/aiff/aifffile.cpp +++ b/taglib/riff/aiff/aifffile.cpp @@ -48,6 +48,9 @@ public: delete tag; } + FilePrivate(const FilePrivate &) = delete; + FilePrivate &operator=(const FilePrivate &) = delete; + Properties *properties; ID3v2::Tag *tag; @@ -72,7 +75,7 @@ bool RIFF::AIFF::File::isSupported(IOStream *stream) RIFF::AIFF::File::File(FileName file, bool readProperties, Properties::ReadStyle) : RIFF::File(file, BigEndian), - d(new FilePrivate()) + d(std::make_unique()) { if(isOpen()) read(readProperties); @@ -80,16 +83,13 @@ RIFF::AIFF::File::File(FileName file, bool readProperties, Properties::ReadStyle RIFF::AIFF::File::File(IOStream *stream, bool readProperties, Properties::ReadStyle) : RIFF::File(stream, BigEndian), - d(new FilePrivate()) + d(std::make_unique()) { if(isOpen()) read(readProperties); } -RIFF::AIFF::File::~File() -{ - delete d; -} +RIFF::AIFF::File::~File() = default; ID3v2::Tag *RIFF::AIFF::File::tag() const { diff --git a/taglib/riff/aiff/aifffile.h b/taglib/riff/aiff/aifffile.h index d5748a30..fe7b5207 100644 --- a/taglib/riff/aiff/aifffile.h +++ b/taglib/riff/aiff/aifffile.h @@ -83,6 +83,9 @@ namespace TagLib { */ ~File() override; + File(const File &) = delete; + File &operator=(const File &) = delete; + /*! * Returns the Tag for this file. * @@ -140,15 +143,12 @@ namespace TagLib { static bool isSupported(IOStream *stream); private: - File(const File &) = delete; - File &operator=(const File &) = delete; - void read(bool readProperties); friend class Properties; class FilePrivate; - FilePrivate *d; + std::unique_ptr d; }; } // namespace AIFF } // namespace RIFF diff --git a/taglib/riff/aiff/aiffproperties.cpp b/taglib/riff/aiff/aiffproperties.cpp index 70900c55..cf8ab5da 100644 --- a/taglib/riff/aiff/aiffproperties.cpp +++ b/taglib/riff/aiff/aiffproperties.cpp @@ -59,15 +59,12 @@ public: RIFF::AIFF::Properties::Properties(File *file, ReadStyle style) : AudioProperties(style), - d(new PropertiesPrivate()) + d(std::make_unique()) { read(file); } -RIFF::AIFF::Properties::~Properties() -{ - delete d; -} +RIFF::AIFF::Properties::~Properties() = default; int RIFF::AIFF::Properties::lengthInMilliseconds() const { diff --git a/taglib/riff/aiff/aiffproperties.h b/taglib/riff/aiff/aiffproperties.h index 8e175d87..28983144 100644 --- a/taglib/riff/aiff/aiffproperties.h +++ b/taglib/riff/aiff/aiffproperties.h @@ -58,6 +58,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 { String compressionName() const; private: - Properties(const Properties &) = delete; - Properties &operator=(const Properties &) = delete; - void read(File *file); class PropertiesPrivate; - PropertiesPrivate *d; + std::unique_ptr d; }; } // namespace AIFF } // namespace RIFF diff --git a/taglib/riff/rifffile.cpp b/taglib/riff/rifffile.cpp index f50d00f3..0ede4b50 100644 --- a/taglib/riff/rifffile.cpp +++ b/taglib/riff/rifffile.cpp @@ -64,10 +64,7 @@ public: // public members //////////////////////////////////////////////////////////////////////////////// -RIFF::File::~File() -{ - delete d; -} +RIFF::File::~File() = default; //////////////////////////////////////////////////////////////////////////////// // protected members @@ -75,7 +72,7 @@ RIFF::File::~File() RIFF::File::File(FileName file, Endianness endianness) : TagLib::File(file), - d(new FilePrivate(endianness)) + d(std::make_unique(endianness)) { if(isOpen()) read(); @@ -83,7 +80,7 @@ RIFF::File::File(FileName file, Endianness endianness) : RIFF::File::File(IOStream *stream, Endianness endianness) : TagLib::File(stream), - d(new FilePrivate(endianness)) + d(std::make_unique(endianness)) { if(isOpen()) read(); diff --git a/taglib/riff/rifffile.h b/taglib/riff/rifffile.h index b2020277..6d8a6bf5 100644 --- a/taglib/riff/rifffile.h +++ b/taglib/riff/rifffile.h @@ -51,6 +51,9 @@ namespace TagLib { */ ~File() override; + File(const File &) = delete; + File &operator=(const File &) = delete; + protected: enum Endianness { BigEndian, LittleEndian }; @@ -140,9 +143,6 @@ namespace TagLib { void removeChunk(const ByteVector &name); private: - File(const File &) = delete; - File &operator=(const File &) = delete; - void read(); void writeChunk(const ByteVector &name, const ByteVector &data, offset_t offset, unsigned long replace = 0); @@ -153,7 +153,7 @@ namespace TagLib { void updateGlobalSize(); class FilePrivate; - FilePrivate *d; + std::unique_ptr d; }; } // namespace RIFF } // namespace TagLib diff --git a/taglib/riff/wav/infotag.cpp b/taglib/riff/wav/infotag.cpp index b6e9a563..ca3af4b7 100644 --- a/taglib/riff/wav/infotag.cpp +++ b/taglib/riff/wav/infotag.cpp @@ -45,6 +45,10 @@ public: FieldListMap fieldListMap; }; +class RIFF::Info::StringHandler::StringHandlerPrivate +{ +}; + //////////////////////////////////////////////////////////////////////////////// // StringHandler implementation //////////////////////////////////////////////////////////////////////////////// @@ -68,20 +72,17 @@ ByteVector RIFF::Info::StringHandler::render(const String &s) const //////////////////////////////////////////////////////////////////////////////// RIFF::Info::Tag::Tag(const ByteVector &data) : - d(new TagPrivate()) + d(std::make_unique()) { parse(data); } RIFF::Info::Tag::Tag() : - d(new TagPrivate()) + d(std::make_unique()) { } -RIFF::Info::Tag::~Tag() -{ - delete d; -} +RIFF::Info::Tag::~Tag() = default; String RIFF::Info::Tag::title() const { diff --git a/taglib/riff/wav/infotag.h b/taglib/riff/wav/infotag.h index 7d28dfbb..e25236d5 100644 --- a/taglib/riff/wav/infotag.h +++ b/taglib/riff/wav/infotag.h @@ -63,6 +63,9 @@ namespace TagLib { StringHandler(); virtual ~StringHandler(); + StringHandler(const StringHandler &) = delete; + StringHandler &operator=(const StringHandler &) = delete; + /*! * Decode a string from \a data. The default implementation assumes that * \a data is an UTF-8 character array. @@ -77,7 +80,7 @@ namespace TagLib { private: class StringHandlerPrivate; - StringHandlerPrivate *d; + std::unique_ptr d; }; //! The main class in the ID3v2 implementation @@ -104,6 +107,9 @@ namespace TagLib { ~Tag() override; + Tag(const Tag &) = delete; + Tag &operator=(const Tag &) = delete; + // Reimplementations String title() const override; @@ -182,13 +188,9 @@ namespace TagLib { */ void parse(const ByteVector &data); - private: - Tag(const Tag &) = delete; - Tag &operator=(const Tag &) = delete; - class TagPrivate; - TagPrivate *d; + std::unique_ptr d; }; } // namespace Info } // namespace RIFF diff --git a/taglib/riff/wav/wavfile.cpp b/taglib/riff/wav/wavfile.cpp index 740c9d57..1bc0c52b 100644 --- a/taglib/riff/wav/wavfile.cpp +++ b/taglib/riff/wav/wavfile.cpp @@ -55,6 +55,9 @@ public: delete properties; } + FilePrivate(const FilePrivate &) = delete; + FilePrivate &operator=(const FilePrivate &) = delete; + Properties *properties; TagUnion tag; @@ -80,7 +83,7 @@ bool RIFF::WAV::File::isSupported(IOStream *stream) RIFF::WAV::File::File(FileName file, bool readProperties, Properties::ReadStyle) : RIFF::File(file, LittleEndian), - d(new FilePrivate()) + d(std::make_unique()) { if(isOpen()) read(readProperties); @@ -88,16 +91,13 @@ RIFF::WAV::File::File(FileName file, bool readProperties, Properties::ReadStyle) RIFF::WAV::File::File(IOStream *stream, bool readProperties, Properties::ReadStyle) : RIFF::File(stream, LittleEndian), - d(new FilePrivate()) + d(std::make_unique()) { if(isOpen()) read(readProperties); } -RIFF::WAV::File::~File() -{ - delete d; -} +RIFF::WAV::File::~File() = default; ID3v2::Tag *RIFF::WAV::File::tag() const { diff --git a/taglib/riff/wav/wavfile.h b/taglib/riff/wav/wavfile.h index 768b0d4a..8f5e9219 100644 --- a/taglib/riff/wav/wavfile.h +++ b/taglib/riff/wav/wavfile.h @@ -95,6 +95,9 @@ namespace TagLib { */ ~File() override; + File(const File &) = delete; + File &operator=(const File &) = delete; + /*! * Returns the ID3v2 Tag for this file. * @@ -192,16 +195,13 @@ namespace TagLib { static bool isSupported(IOStream *stream); private: - File(const File &) = delete; - File &operator=(const File &) = delete; - void read(bool readProperties); void removeTagChunks(TagTypes tags); friend class Properties; class FilePrivate; - FilePrivate *d; + std::unique_ptr d; }; } // namespace WAV } // namespace RIFF diff --git a/taglib/riff/wav/wavproperties.cpp b/taglib/riff/wav/wavproperties.cpp index dc9bdbbc..ae3d5687 100644 --- a/taglib/riff/wav/wavproperties.cpp +++ b/taglib/riff/wav/wavproperties.cpp @@ -67,15 +67,12 @@ public: TagLib::RIFF::WAV::Properties::Properties(File *file, ReadStyle style) : AudioProperties(style), - d(new PropertiesPrivate()) + d(std::make_unique()) { read(file); } -RIFF::WAV::Properties::~Properties() -{ - delete d; -} +RIFF::WAV::Properties::~Properties() = default; int RIFF::WAV::Properties::lengthInMilliseconds() const { diff --git a/taglib/riff/wav/wavproperties.h b/taglib/riff/wav/wavproperties.h index 208f6138..ea0acad6 100644 --- a/taglib/riff/wav/wavproperties.h +++ b/taglib/riff/wav/wavproperties.h @@ -60,6 +60,9 @@ namespace TagLib { */ ~Properties() override; + Properties(const Properties &) = delete; + Properties &operator=(const Properties &) = delete; + /*! * Returns the length of the file in milliseconds. * @@ -103,13 +106,10 @@ namespace TagLib { int format() const; private: - Properties(const Properties &) = delete; - Properties &operator=(const Properties &) = delete; - void read(File *file); class PropertiesPrivate; - PropertiesPrivate *d; + std::unique_ptr d; }; } // namespace WAV } // namespace RIFF diff --git a/taglib/s3m/s3mfile.cpp b/taglib/s3m/s3mfile.cpp index da788290..7ab3ea16 100644 --- a/taglib/s3m/s3mfile.cpp +++ b/taglib/s3m/s3mfile.cpp @@ -50,7 +50,7 @@ public: S3M::File::File(FileName file, bool readProperties, AudioProperties::ReadStyle propertiesStyle) : Mod::FileBase(file), - d(new FilePrivate(propertiesStyle)) + d(std::make_unique(propertiesStyle)) { if(isOpen()) read(readProperties); @@ -59,16 +59,13 @@ S3M::File::File(FileName file, bool readProperties, S3M::File::File(IOStream *stream, bool readProperties, AudioProperties::ReadStyle propertiesStyle) : Mod::FileBase(stream), - d(new FilePrivate(propertiesStyle)) + d(std::make_unique(propertiesStyle)) { if(isOpen()) read(readProperties); } -S3M::File::~File() -{ - delete d; -} +S3M::File::~File() = default; Mod::Tag *S3M::File::tag() const { diff --git a/taglib/s3m/s3mfile.h b/taglib/s3m/s3mfile.h index e5858ca7..2eaa723f 100644 --- a/taglib/s3m/s3mfile.h +++ b/taglib/s3m/s3mfile.h @@ -69,6 +69,9 @@ namespace TagLib { */ ~File() override; + File(const File &) = delete; + File &operator=(const File &) = delete; + Mod::Tag *tag() const override; /*! @@ -98,13 +101,10 @@ namespace TagLib { bool save() override; private: - File(const File &) = delete; - File &operator=(const File &) = delete; - void read(bool readProperties); class FilePrivate; - FilePrivate *d; + std::unique_ptr d; }; } // namespace S3M } // namespace TagLib diff --git a/taglib/s3m/s3mproperties.cpp b/taglib/s3m/s3mproperties.cpp index 84a97c1f..35daa4f1 100644 --- a/taglib/s3m/s3mproperties.cpp +++ b/taglib/s3m/s3mproperties.cpp @@ -64,14 +64,11 @@ public: S3M::Properties::Properties(AudioProperties::ReadStyle propertiesStyle) : AudioProperties(propertiesStyle), - d(new PropertiesPrivate()) + d(std::make_unique()) { } -S3M::Properties::~Properties() -{ - delete d; -} +S3M::Properties::~Properties() = default; int S3M::Properties::channels() const { diff --git a/taglib/s3m/s3mproperties.h b/taglib/s3m/s3mproperties.h index a3b76079..eaad0c32 100644 --- a/taglib/s3m/s3mproperties.h +++ b/taglib/s3m/s3mproperties.h @@ -47,6 +47,9 @@ namespace TagLib { Properties(AudioProperties::ReadStyle propertiesStyle); ~Properties() override; + Properties(const Properties &) = delete; + Properties &operator=(const Properties &) = delete; + int channels() const override; unsigned short lengthInPatterns() const; @@ -76,11 +79,8 @@ namespace TagLib { void setBpmSpeed(unsigned char bpmSpeed); private: - Properties(const Properties&) = delete; - Properties &operator=(const Properties&) = delete; - class PropertiesPrivate; - PropertiesPrivate *d; + std::unique_ptr d; }; } // namespace S3M } // namespace TagLib diff --git a/taglib/tag.cpp b/taglib/tag.cpp index 75ff178b..68f37fdf 100644 --- a/taglib/tag.cpp +++ b/taglib/tag.cpp @@ -31,7 +31,6 @@ using namespace TagLib; class Tag::TagPrivate { - }; Tag::Tag() = default; diff --git a/taglib/tag.h b/taglib/tag.h index 132c053b..3176f45e 100644 --- a/taglib/tag.h +++ b/taglib/tag.h @@ -52,6 +52,9 @@ namespace TagLib { */ virtual ~Tag(); + Tag(const Tag &) = delete; + Tag &operator=(const Tag &) = delete; + /*! * Exports the tags of the file as dictionary mapping (human readable) tag * names (Strings) to StringLists of tag values. @@ -187,11 +190,8 @@ namespace TagLib { Tag(); private: - Tag(const Tag &) = delete; - Tag &operator=(const Tag &) = delete; - class TagPrivate; - TagPrivate *d; + std::unique_ptr d; }; } // namespace TagLib diff --git a/taglib/tagunion.cpp b/taglib/tagunion.cpp index 751d3d45..bc4afdb3 100644 --- a/taglib/tagunion.cpp +++ b/taglib/tagunion.cpp @@ -66,7 +66,6 @@ class TagUnion::TagUnionPrivate public: TagUnionPrivate() : tags(3, static_cast(nullptr)) { - } ~TagUnionPrivate() @@ -76,21 +75,21 @@ public: delete tags[2]; } + TagUnionPrivate(const TagUnionPrivate &) = delete; + TagUnionPrivate &operator=(const TagUnionPrivate &) = delete; + std::vector tags; }; TagUnion::TagUnion(Tag *first, Tag *second, Tag *third) : - d(new TagUnionPrivate()) + d(std::make_unique()) { d->tags[0] = first; d->tags[1] = second; d->tags[2] = third; } -TagUnion::~TagUnion() -{ - delete d; -} +TagUnion::~TagUnion() = default; Tag *TagUnion::operator[](int index) const { diff --git a/taglib/tagunion.h b/taglib/tagunion.h index ff9eab3c..a6b4cfc4 100644 --- a/taglib/tagunion.h +++ b/taglib/tagunion.h @@ -51,6 +51,9 @@ namespace TagLib { ~TagUnion() override; + TagUnion(const TagUnion &) = delete; + TagUnion &operator=(const TagUnion &) = delete; + Tag *operator[](int index) const; Tag *tag(int index) const; @@ -90,7 +93,7 @@ namespace TagLib { TagUnion &operator=(const Tag &); class TagUnionPrivate; - TagUnionPrivate *d; + std::unique_ptr d; }; } // namespace TagLib diff --git a/taglib/toolkit/tbytevector.cpp b/taglib/toolkit/tbytevector.cpp index 9b411adc..2de88116 100644 --- a/taglib/toolkit/tbytevector.cpp +++ b/taglib/toolkit/tbytevector.cpp @@ -325,44 +325,41 @@ ByteVector ByteVector::fromFloat64BE(double value) //////////////////////////////////////////////////////////////////////////////// ByteVector::ByteVector() : - d(new ByteVectorPrivate(0, '\0')) + d(std::make_unique(0, '\0')) { } ByteVector::ByteVector(unsigned int size, char value) : - d(new ByteVectorPrivate(size, value)) + d(std::make_unique(size, value)) { } ByteVector::ByteVector(const ByteVector &v) : - d(new ByteVectorPrivate(*v.d, 0, v.d->length)) + d(std::make_unique(*v.d, 0, v.d->length)) { } ByteVector::ByteVector(const ByteVector &v, unsigned int offset, unsigned int length) : - d(new ByteVectorPrivate(*v.d, offset, length)) + d(std::make_unique(*v.d, offset, length)) { } ByteVector::ByteVector(char c) : - d(new ByteVectorPrivate(1, c)) + d(std::make_unique(1, c)) { } ByteVector::ByteVector(const char *data, unsigned int length) : - d(new ByteVectorPrivate(data, length)) + d(std::make_unique(data, length)) { } ByteVector::ByteVector(const char *data) : - d(new ByteVectorPrivate(data, static_cast(::strlen(data)))) + d(std::make_unique(data, static_cast(::strlen(data)))) { } -ByteVector::~ByteVector() -{ - delete d; -} +ByteVector::~ByteVector() = default; ByteVector &ByteVector::setData(const char *s, unsigned int length) { diff --git a/taglib/toolkit/tbytevector.h b/taglib/toolkit/tbytevector.h index 42a12aca..c463d5f9 100644 --- a/taglib/toolkit/tbytevector.h +++ b/taglib/toolkit/tbytevector.h @@ -599,7 +599,7 @@ namespace TagLib { private: class ByteVectorPrivate; - ByteVectorPrivate *d; + std::unique_ptr d; }; } // namespace TagLib diff --git a/taglib/toolkit/tbytevectorlist.cpp b/taglib/toolkit/tbytevectorlist.cpp index 218f55b1..d2dac08f 100644 --- a/taglib/toolkit/tbytevectorlist.cpp +++ b/taglib/toolkit/tbytevectorlist.cpp @@ -27,9 +27,8 @@ using namespace TagLib; -class ByteVectorListPrivate +class ByteVectorList::ByteVectorListPrivate { - }; //////////////////////////////////////////////////////////////////////////////// @@ -66,12 +65,21 @@ ByteVectorList ByteVectorList::split(const ByteVector &v, const ByteVector &patt ByteVectorList::ByteVectorList() = default; -ByteVectorList::ByteVectorList(const ByteVectorList &l) : List(l) -{ +ByteVectorList::~ByteVectorList() = default; +ByteVectorList::ByteVectorList(const ByteVectorList &l) : + List(l) +{ } -ByteVectorList::~ByteVectorList() = default; +ByteVectorList &ByteVectorList::operator=(const ByteVectorList &l) +{ + if(this == &l) + return *this; + + List::operator=(l); + return *this; +} ByteVector ByteVectorList::toByteVector(const ByteVector &separator) const { diff --git a/taglib/toolkit/tbytevectorlist.h b/taglib/toolkit/tbytevectorlist.h index bcc72df3..ef1fae9d 100644 --- a/taglib/toolkit/tbytevectorlist.h +++ b/taglib/toolkit/tbytevectorlist.h @@ -59,6 +59,8 @@ namespace TagLib { */ ByteVectorList(const ByteVectorList &l); + ByteVectorList &operator=(const ByteVectorList &); + /*! * Convert the ByteVectorList to a ByteVector separated by \a separator. By * default a space is used. @@ -76,7 +78,7 @@ namespace TagLib { int byteAlign = 1, int max = 0); private: class ByteVectorListPrivate; - ByteVectorListPrivate *d; + std::unique_ptr d; }; } // namespace TagLib diff --git a/taglib/toolkit/tbytevectorstream.cpp b/taglib/toolkit/tbytevectorstream.cpp index 8fb8a8b9..189258fe 100644 --- a/taglib/toolkit/tbytevectorstream.cpp +++ b/taglib/toolkit/tbytevectorstream.cpp @@ -54,14 +54,11 @@ ByteVectorStream::ByteVectorStreamPrivate::ByteVectorStreamPrivate(const ByteVec //////////////////////////////////////////////////////////////////////////////// ByteVectorStream::ByteVectorStream(const ByteVector &data) : - d(new ByteVectorStreamPrivate(data)) + d(std::make_unique(data)) { } -ByteVectorStream::~ByteVectorStream() -{ - delete d; -} +ByteVectorStream::~ByteVectorStream() = default; FileName ByteVectorStream::name() const { diff --git a/taglib/toolkit/tbytevectorstream.h b/taglib/toolkit/tbytevectorstream.h index 6d2f6453..3a29d718 100644 --- a/taglib/toolkit/tbytevectorstream.h +++ b/taglib/toolkit/tbytevectorstream.h @@ -53,6 +53,9 @@ namespace TagLib { */ ~ByteVectorStream() override; + ByteVectorStream(const ByteVectorStream &) = delete; + ByteVectorStream &operator=(const ByteVectorStream &) = delete; + /*! * Returns the file name in the local file system encoding. */ @@ -137,7 +140,7 @@ namespace TagLib { private: class ByteVectorStreamPrivate; - ByteVectorStreamPrivate *d; + std::unique_ptr d; }; } // namespace TagLib diff --git a/taglib/toolkit/tdebuglistener.cpp b/taglib/toolkit/tdebuglistener.cpp index eb4a15a0..fcbe6308 100644 --- a/taglib/toolkit/tdebuglistener.cpp +++ b/taglib/toolkit/tdebuglistener.cpp @@ -65,6 +65,10 @@ namespace namespace TagLib { + class DebugListener::DebugListenerPrivate + { + }; + DebugListener *debugListener = &defaultListener; DebugListener::DebugListener() = default; diff --git a/taglib/toolkit/tdebuglistener.h b/taglib/toolkit/tdebuglistener.h index dfcf9748..ca12298a 100644 --- a/taglib/toolkit/tdebuglistener.h +++ b/taglib/toolkit/tdebuglistener.h @@ -45,6 +45,8 @@ namespace TagLib public: DebugListener(); virtual ~DebugListener(); + DebugListener(const DebugListener &) = delete; + DebugListener &operator=(const DebugListener &) = delete; /*! * When overridden in a derived class, redirects \a msg to your preferred @@ -53,12 +55,8 @@ namespace TagLib virtual void printMessage(const String &msg) = 0; private: - // Noncopyable - DebugListener(const DebugListener &) = delete; - DebugListener &operator=(const DebugListener &) = delete; - class DebugListenerPrivate; - DebugListenerPrivate *d; + std::unique_ptr d; }; /*! diff --git a/taglib/toolkit/tfile.cpp b/taglib/toolkit/tfile.cpp index 6c3e088d..8d5de869 100644 --- a/taglib/toolkit/tfile.cpp +++ b/taglib/toolkit/tfile.cpp @@ -79,6 +79,9 @@ public: delete stream; } + FilePrivate(const FilePrivate &) = delete; + FilePrivate &operator=(const FilePrivate &) = delete; + IOStream *stream; bool streamOwner; bool valid; @@ -89,19 +92,16 @@ public: //////////////////////////////////////////////////////////////////////////////// File::File(FileName fileName) : - d(new FilePrivate(new FileStream(fileName), true)) + d(std::make_unique(new FileStream(fileName), true)) { } File::File(IOStream *stream) : - d(new FilePrivate(stream, false)) + d(std::make_unique(stream, false)) { } -File::~File() -{ - delete d; -} +File::~File() = default; FileName File::name() const { diff --git a/taglib/toolkit/tfile.h b/taglib/toolkit/tfile.h index 2c44f335..d0945998 100644 --- a/taglib/toolkit/tfile.h +++ b/taglib/toolkit/tfile.h @@ -84,6 +84,9 @@ namespace TagLib { */ virtual ~File(); + File(const File &) = delete; + File &operator=(const File &) = delete; + /*! * Returns the file name in the local file system encoding. */ @@ -293,11 +296,8 @@ namespace TagLib { static unsigned int bufferSize(); private: - File(const File &) = delete; - File &operator=(const File &) = delete; - class FilePrivate; - FilePrivate *d; + std::unique_ptr d; }; } // namespace TagLib diff --git a/taglib/toolkit/tfilestream.cpp b/taglib/toolkit/tfilestream.cpp index 458f228e..753d8af0 100644 --- a/taglib/toolkit/tfilestream.cpp +++ b/taglib/toolkit/tfilestream.cpp @@ -145,8 +145,8 @@ public: // public members //////////////////////////////////////////////////////////////////////////////// -FileStream::FileStream(FileName fileName, bool openReadOnly) - : d(new FileStreamPrivate(fileName)) +FileStream::FileStream(FileName fileName, bool openReadOnly) : + d(std::make_unique(fileName)) { // First try with read / write mode, if that fails, fall back to read only. @@ -166,8 +166,8 @@ FileStream::FileStream(FileName fileName, bool openReadOnly) # endif } -FileStream::FileStream(int fileDescriptor, bool openReadOnly) - : d(new FileStreamPrivate("")) +FileStream::FileStream(int fileDescriptor, bool openReadOnly) : + d(std::make_unique("")) { // First try with read / write mode, if that fails, fall back to read only. @@ -187,8 +187,6 @@ FileStream::~FileStream() { if(isOpen()) closeFile(d->file); - - delete d; } FileName FileStream::name() const diff --git a/taglib/toolkit/tfilestream.h b/taglib/toolkit/tfilestream.h index d4b7599c..36c02f71 100644 --- a/taglib/toolkit/tfilestream.h +++ b/taglib/toolkit/tfilestream.h @@ -64,6 +64,9 @@ namespace TagLib { */ ~FileStream() override; + FileStream(const FileStream &) = delete; + FileStream &operator=(const FileStream &) = delete; + /*! * Returns the file name in the local file system encoding. */ @@ -151,7 +154,7 @@ namespace TagLib { private: class FileStreamPrivate; - FileStreamPrivate *d; + std::unique_ptr d; }; } // namespace TagLib diff --git a/taglib/toolkit/tiostream.cpp b/taglib/toolkit/tiostream.cpp index 6033729e..ab715de0 100644 --- a/taglib/toolkit/tiostream.cpp +++ b/taglib/toolkit/tiostream.cpp @@ -81,6 +81,10 @@ String FileName::toString() const #endif // _WIN32 +class IOStream::IOStreamPrivate +{ +}; + //////////////////////////////////////////////////////////////////////////////// // public members //////////////////////////////////////////////////////////////////////////////// diff --git a/taglib/toolkit/tiostream.h b/taglib/toolkit/tiostream.h index adc9314a..eae0279f 100644 --- a/taglib/toolkit/tiostream.h +++ b/taglib/toolkit/tiostream.h @@ -78,6 +78,9 @@ namespace TagLib { */ virtual ~IOStream(); + IOStream(const IOStream &) = delete; + IOStream &operator=(const IOStream &) = delete; + /*! * Returns the stream name in the local file system encoding. */ @@ -158,11 +161,8 @@ namespace TagLib { virtual void truncate(offset_t length) = 0; private: - IOStream(const IOStream &) = delete; - IOStream &operator=(const IOStream &) = delete; - class IOStreamPrivate; - IOStreamPrivate *d; + std::unique_ptr d; }; } // namespace TagLib diff --git a/taglib/toolkit/tlist.tcc b/taglib/toolkit/tlist.tcc index c228bea4..d344bd73 100644 --- a/taglib/toolkit/tlist.tcc +++ b/taglib/toolkit/tlist.tcc @@ -71,6 +71,8 @@ public: ~ListPrivate() { clear(); } + ListPrivate(const ListPrivate &) = delete; + ListPrivate &operator=(const ListPrivate &) = delete; void clear() { if(autoDelete) { for(auto &m : list) diff --git a/taglib/toolkit/tpropertymap.cpp b/taglib/toolkit/tpropertymap.cpp index 183b5ab4..f3f8e34c 100644 --- a/taglib/toolkit/tpropertymap.cpp +++ b/taglib/toolkit/tpropertymap.cpp @@ -34,20 +34,20 @@ public: }; PropertyMap::PropertyMap() : - d(new PropertyMapPrivate) + d(std::make_unique()) { } PropertyMap::PropertyMap(const PropertyMap &m) : SimplePropertyMap(m), - d(new PropertyMapPrivate) + d(std::make_unique()) { *d = *m.d; } PropertyMap::PropertyMap(const SimplePropertyMap &m) : - d(new PropertyMapPrivate) + d(std::make_unique()) { for(auto [key, value] : m) { if(!key.isEmpty()) @@ -57,10 +57,7 @@ PropertyMap::PropertyMap(const SimplePropertyMap &m) : } } -PropertyMap::~PropertyMap() -{ - delete d; -} +PropertyMap::~PropertyMap() = default; bool PropertyMap::insert(const String &key, const StringList &values) { diff --git a/taglib/toolkit/tpropertymap.h b/taglib/toolkit/tpropertymap.h index 27992cad..ed090615 100644 --- a/taglib/toolkit/tpropertymap.h +++ b/taglib/toolkit/tpropertymap.h @@ -126,6 +126,8 @@ namespace TagLib { PropertyMap(const PropertyMap &m); + PropertyMap &operator=(const PropertyMap &other); + /*! * Creates a PropertyMap initialized from a SimplePropertyMap. Copies all * entries from \a m that have valid keys. @@ -248,11 +250,9 @@ namespace TagLib { String toString() const; - PropertyMap &operator=(const PropertyMap &other); - private: class PropertyMapPrivate; - PropertyMapPrivate *d; + std::unique_ptr d; }; } // namespace TagLib diff --git a/taglib/toolkit/trefcounter.h b/taglib/toolkit/trefcounter.h new file mode 100644 index 00000000..95e82547 --- /dev/null +++ b/taglib/toolkit/trefcounter.h @@ -0,0 +1,63 @@ +/*************************************************************************** + copyright : (C) 2013 by Tsuda Kageyu + email : tsuda.kageyu@gmail.com + ***************************************************************************/ + +/*************************************************************************** + * This library is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Lesser General Public License version * + * 2.1 as published by the Free Software Foundation. * + * * + * This library is distributed in the hope that it will be useful, but * + * WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * + * Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this library; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * + * 02110-1301 USA * + * * + * Alternatively, this file is available under the Mozilla Public * + * License Version 1.1. You may obtain a copy of the License at * + * http://www.mozilla.org/MPL/ * + ***************************************************************************/ + +#ifndef TAGLIB_REFCOUNTER_H +#define TAGLIB_REFCOUNTER_H + +#include "taglib_export.h" +#include "taglib.h" + +#ifndef DO_NOT_DOCUMENT // Tell Doxygen to skip this class. +/*! + * \internal + * This is just used as a base class for shared classes in TagLib. + * + * \warning This is not part of the TagLib public API! + */ +namespace TagLib +{ + + class TAGLIB_EXPORT RefCounter + { + public: + RefCounter(); + ~RefCounter(); + + RefCounter(const RefCounter &) = delete; + RefCounter &operator=(const RefCounter &) = delete; + + void ref(); + bool deref(); + int count() const; + + private: + class RefCounterPrivate; + RefCounterPrivate *d; + }; + +} // namespace TagLib + +#endif // DO_NOT_DOCUMENT +#endif diff --git a/taglib/toolkit/tstringlist.cpp b/taglib/toolkit/tstringlist.cpp index bd9b5914..e62cb5ae 100644 --- a/taglib/toolkit/tstringlist.cpp +++ b/taglib/toolkit/tstringlist.cpp @@ -27,9 +27,8 @@ using namespace TagLib; -class StringListPrivate +class StringList::StringListPrivate { - }; //////////////////////////////////////////////////////////////////////////////// @@ -57,9 +56,18 @@ StringList StringList::split(const String &s, const String &pattern) StringList::StringList() = default; -StringList::StringList(const StringList &l) : List(l) +StringList::StringList(const StringList &l) : + List(l) { +} +StringList &StringList::operator=(const StringList &l) +{ + if(this == &l) + return *this; + + List::operator=(l); + return *this; } StringList::StringList(const String &s) @@ -74,8 +82,7 @@ StringList::StringList(const ByteVectorList &bl, String::Type t) } } -StringList::~StringList() -= default; +StringList::~StringList() = default; String StringList::toString(const String &separator) const { diff --git a/taglib/toolkit/tstringlist.h b/taglib/toolkit/tstringlist.h index c657e498..c634ffca 100644 --- a/taglib/toolkit/tstringlist.h +++ b/taglib/toolkit/tstringlist.h @@ -58,6 +58,8 @@ namespace TagLib { */ StringList(const StringList &l); + StringList &operator=(const StringList &); + /*! * Constructs a StringList with \a s as a member. */ @@ -101,7 +103,7 @@ namespace TagLib { private: class StringListPrivate; - StringListPrivate *d; + std::unique_ptr d; }; } // namespace TagLib diff --git a/taglib/trueaudio/trueaudiofile.cpp b/taglib/trueaudio/trueaudiofile.cpp index db5cd4b1..f2eb6b87 100644 --- a/taglib/trueaudio/trueaudiofile.cpp +++ b/taglib/trueaudio/trueaudiofile.cpp @@ -63,6 +63,9 @@ public: delete properties; } + FilePrivate(const FilePrivate &) = delete; + FilePrivate &operator=(const FilePrivate &) = delete; + const ID3v2::FrameFactory *ID3v2FrameFactory; offset_t ID3v2Location; long ID3v2OriginalSize; @@ -92,7 +95,7 @@ bool TrueAudio::File::isSupported(IOStream *stream) TrueAudio::File::File(FileName file, bool readProperties, Properties::ReadStyle) : TagLib::File(file), - d(new FilePrivate()) + d(std::make_unique()) { if(isOpen()) read(readProperties); @@ -101,7 +104,7 @@ TrueAudio::File::File(FileName file, bool readProperties, Properties::ReadStyle) TrueAudio::File::File(FileName file, ID3v2::FrameFactory *frameFactory, bool readProperties, Properties::ReadStyle) : TagLib::File(file), - d(new FilePrivate(frameFactory)) + d(std::make_unique(frameFactory)) { if(isOpen()) read(readProperties); @@ -109,7 +112,7 @@ TrueAudio::File::File(FileName file, ID3v2::FrameFactory *frameFactory, TrueAudio::File::File(IOStream *stream, bool readProperties, Properties::ReadStyle) : TagLib::File(stream), - d(new FilePrivate()) + d(std::make_unique()) { if(isOpen()) read(readProperties); @@ -118,16 +121,13 @@ TrueAudio::File::File(IOStream *stream, bool readProperties, Properties::ReadSty TrueAudio::File::File(IOStream *stream, ID3v2::FrameFactory *frameFactory, bool readProperties, Properties::ReadStyle) : TagLib::File(stream), - d(new FilePrivate(frameFactory)) + d(std::make_unique(frameFactory)) { if(isOpen()) read(readProperties); } -TrueAudio::File::~File() -{ - delete d; -} +TrueAudio::File::~File() = default; TagLib::Tag *TrueAudio::File::tag() const { diff --git a/taglib/trueaudio/trueaudiofile.h b/taglib/trueaudio/trueaudiofile.h index ab1956e6..79079979 100644 --- a/taglib/trueaudio/trueaudiofile.h +++ b/taglib/trueaudio/trueaudiofile.h @@ -133,6 +133,9 @@ namespace TagLib { */ ~File() override; + File(const File &) = delete; + File &operator=(const File &) = delete; + /*! * Returns the Tag for this file. */ @@ -237,13 +240,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 d; }; } // namespace TrueAudio } // namespace TagLib diff --git a/taglib/trueaudio/trueaudioproperties.cpp b/taglib/trueaudio/trueaudioproperties.cpp index 832a7807..caf4f316 100644 --- a/taglib/trueaudio/trueaudioproperties.cpp +++ b/taglib/trueaudio/trueaudioproperties.cpp @@ -64,15 +64,12 @@ public: TrueAudio::Properties::Properties(const ByteVector &data, offset_t streamLength, ReadStyle style) : AudioProperties(style), - d(new PropertiesPrivate()) + d(std::make_unique()) { read(data, streamLength); } -TrueAudio::Properties::~Properties() -{ - delete d; -} +TrueAudio::Properties::~Properties() = default; int TrueAudio::Properties::lengthInSeconds() const { diff --git a/taglib/trueaudio/trueaudioproperties.h b/taglib/trueaudio/trueaudioproperties.h index 633c1017..80f14ca3 100644 --- a/taglib/trueaudio/trueaudioproperties.h +++ b/taglib/trueaudio/trueaudioproperties.h @@ -60,6 +60,9 @@ namespace TagLib { */ ~Properties() override; + Properties(const Properties &) = delete; + Properties &operator=(const Properties &) = delete; + /*! * Returns the length of the file in seconds. The length is rounded down to * the nearest whole second. @@ -106,13 +109,10 @@ namespace TagLib { int ttaVersion() const; private: - Properties(const Properties &) = delete; - Properties &operator=(const Properties &) = delete; - void read(const ByteVector &data, offset_t streamLength); class PropertiesPrivate; - PropertiesPrivate *d; + std::unique_ptr d; }; } // namespace TrueAudio } // namespace TagLib diff --git a/taglib/wavpack/wavpackfile.cpp b/taglib/wavpack/wavpackfile.cpp index 7f786d46..8687b67a 100644 --- a/taglib/wavpack/wavpackfile.cpp +++ b/taglib/wavpack/wavpackfile.cpp @@ -62,6 +62,9 @@ public: delete properties; } + FilePrivate(const FilePrivate &) = delete; + FilePrivate &operator=(const FilePrivate &) = delete; + offset_t APELocation; long APESize; @@ -90,7 +93,7 @@ bool WavPack::File::isSupported(IOStream *stream) WavPack::File::File(FileName file, bool readProperties, Properties::ReadStyle) : TagLib::File(file), - d(new FilePrivate()) + d(std::make_unique()) { if(isOpen()) read(readProperties); @@ -98,16 +101,13 @@ WavPack::File::File(FileName file, bool readProperties, Properties::ReadStyle) : WavPack::File::File(IOStream *stream, bool readProperties, Properties::ReadStyle) : TagLib::File(stream), - d(new FilePrivate()) + d(std::make_unique()) { if(isOpen()) read(readProperties); } -WavPack::File::~File() -{ - delete d; -} +WavPack::File::~File() = default; TagLib::Tag *WavPack::File::tag() const { diff --git a/taglib/wavpack/wavpackfile.h b/taglib/wavpack/wavpackfile.h index 73216515..e9f396ea 100644 --- a/taglib/wavpack/wavpackfile.h +++ b/taglib/wavpack/wavpackfile.h @@ -103,6 +103,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. @@ -209,13 +212,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 d; }; } // namespace WavPack } // namespace TagLib diff --git a/taglib/wavpack/wavpackproperties.cpp b/taglib/wavpack/wavpackproperties.cpp index 809530ee..6bb7e2c8 100644 --- a/taglib/wavpack/wavpackproperties.cpp +++ b/taglib/wavpack/wavpackproperties.cpp @@ -71,15 +71,12 @@ public: WavPack::Properties::Properties(File *file, offset_t streamLength, ReadStyle style) : AudioProperties(style), - d(new PropertiesPrivate()) + d(std::make_unique()) { read(file, streamLength); } -WavPack::Properties::~Properties() -{ - delete d; -} +WavPack::Properties::~Properties() = default; int WavPack::Properties::lengthInMilliseconds() const { diff --git a/taglib/wavpack/wavpackproperties.h b/taglib/wavpack/wavpackproperties.h index 952988e1..3999e62a 100644 --- a/taglib/wavpack/wavpackproperties.h +++ b/taglib/wavpack/wavpackproperties.h @@ -62,6 +62,9 @@ namespace TagLib { */ ~Properties() override; + Properties(const Properties &) = delete; + Properties &operator=(const Properties &) = delete; + /*! * Returns the length of the file in milliseconds. * @@ -105,14 +108,11 @@ namespace TagLib { int version() const; private: - Properties(const Properties &) = delete; - Properties &operator=(const Properties &) = delete; - void read(File *file, offset_t streamLength); unsigned int seekFinalIndex(File *file, offset_t streamLength); class PropertiesPrivate; - PropertiesPrivate *d; + std::unique_ptr d; }; } // namespace WavPack } // namespace TagLib diff --git a/taglib/xm/xmfile.cpp b/taglib/xm/xmfile.cpp index 7d133423..2da807ed 100644 --- a/taglib/xm/xmfile.cpp +++ b/taglib/xm/xmfile.cpp @@ -362,7 +362,7 @@ public: XM::File::File(FileName file, bool readProperties, AudioProperties::ReadStyle propertiesStyle) : Mod::FileBase(file), - d(new FilePrivate(propertiesStyle)) + d(std::make_unique(propertiesStyle)) { if(isOpen()) read(readProperties); @@ -371,16 +371,13 @@ XM::File::File(FileName file, bool readProperties, XM::File::File(IOStream *stream, bool readProperties, AudioProperties::ReadStyle propertiesStyle) : Mod::FileBase(stream), - d(new FilePrivate(propertiesStyle)) + d(std::make_unique(propertiesStyle)) { if(isOpen()) read(readProperties); } -XM::File::~File() -{ - delete d; -} +XM::File::~File() = default; Mod::Tag *XM::File::tag() const { diff --git a/taglib/xm/xmfile.h b/taglib/xm/xmfile.h index 9e64acef..ccba537a 100644 --- a/taglib/xm/xmfile.h +++ b/taglib/xm/xmfile.h @@ -69,6 +69,9 @@ namespace TagLib { */ ~File() override; + File(const File &) = delete; + File &operator=(const File &) = delete; + Mod::Tag *tag() const override; /*! @@ -98,13 +101,10 @@ namespace TagLib { bool save() override; private: - File(const File &) = delete; - File &operator=(const File &) = delete; - void read(bool readProperties); class FilePrivate; - FilePrivate *d; + std::unique_ptr d; }; } // namespace XM } // namespace TagLib diff --git a/taglib/xm/xmproperties.cpp b/taglib/xm/xmproperties.cpp index 4360f773..c9a347e5 100644 --- a/taglib/xm/xmproperties.cpp +++ b/taglib/xm/xmproperties.cpp @@ -60,14 +60,11 @@ public: XM::Properties::Properties(AudioProperties::ReadStyle propertiesStyle) : AudioProperties(propertiesStyle), - d(new PropertiesPrivate()) + d(std::make_unique()) { } -XM::Properties::~Properties() -{ - delete d; -} +XM::Properties::~Properties() = default; int XM::Properties::channels() const { diff --git a/taglib/xm/xmproperties.h b/taglib/xm/xmproperties.h index 901a2422..e9c44779 100644 --- a/taglib/xm/xmproperties.h +++ b/taglib/xm/xmproperties.h @@ -42,6 +42,9 @@ namespace TagLib { Properties(AudioProperties::ReadStyle propertiesStyle); ~Properties() override; + Properties(const Properties &) = delete; + Properties &operator=(const Properties &) = delete; + int channels() const override; unsigned short lengthInPatterns() const; @@ -67,11 +70,8 @@ namespace TagLib { void setBpmSpeed(unsigned short bpmSpeed); private: - Properties(const Properties&) = delete; - Properties &operator=(const Properties&) = delete; - class PropertiesPrivate; - PropertiesPrivate *d; + std::unique_ptr d; }; } // namespace XM } // namespace TagLib diff --git a/tests/utils.h b/tests/utils.h index cacf4b01..47dcb354 100644 --- a/tests/utils.h +++ b/tests/utils.h @@ -139,6 +139,9 @@ public: deleteFile(m_filename); } + ScopedFileCopy(const ScopedFileCopy &) = delete; + ScopedFileCopy &operator=(const ScopedFileCopy &) = delete; + string fileName() const { return m_filename;