diff --git a/abstractattachment.cpp b/abstractattachment.cpp index e89f605..9d586dd 100644 --- a/abstractattachment.cpp +++ b/abstractattachment.cpp @@ -14,6 +14,9 @@ using namespace CppUtilities; namespace TagParser { +/// \brief The AbstractAttachmentPrivate struct contains private fields of the AbstractAttachment class. +struct AbstractAttachmentPrivate {}; + /*! * \class TagParser::StreamDataBlock * \brief The StreamDataBlock class is a reference to a certain data block of a stream. @@ -127,6 +130,23 @@ FileDataBlock::~FileDataBlock() * \brief The AbstractAttachment class parses and stores attachment information. */ +/*! + * \brief Constructs a new attachment. + */ +AbstractAttachment::AbstractAttachment() + : m_id(0) + , m_isDataFromFile(false) + , m_ignored(false) +{ +} + +/*! + * \brief Destroys the attachment. + */ +AbstractAttachment::~AbstractAttachment() +{ +} + /*! * \brief Returns a label for the track. */ diff --git a/abstractattachment.h b/abstractattachment.h index 95ade0d..96a77c9 100644 --- a/abstractattachment.h +++ b/abstractattachment.h @@ -102,6 +102,8 @@ inline const MediaFileInfo *FileDataBlock::fileInfo() const return m_fileInfo.get(); } +struct AbstractAttachmentPrivate; + class TAG_PARSER_EXPORT AbstractAttachment { public: const std::string &description() const; @@ -123,7 +125,8 @@ public: bool isEmpty() const; protected: - AbstractAttachment(); + explicit AbstractAttachment(); + virtual ~AbstractAttachment(); private: std::string m_description; @@ -131,20 +134,11 @@ private: std::string m_mimeType; std::uint64_t m_id; std::unique_ptr m_data; + std::unique_ptr m_p; bool m_isDataFromFile; bool m_ignored; }; -/*! - * \brief Constructs a new attachment. - */ -inline AbstractAttachment::AbstractAttachment() - : m_id(0) - , m_isDataFromFile(false) - , m_ignored(false) -{ -} - /*! * \brief Returns a description of the attachment. */ diff --git a/abstractchapter.cpp b/abstractchapter.cpp index e96f53d..aa05126 100644 --- a/abstractchapter.cpp +++ b/abstractchapter.cpp @@ -8,6 +8,9 @@ using namespace CppUtilities; namespace TagParser { +/// \brief The AbstractChapterPrivate struct contains private fields of the AbstractChapter class. +struct AbstractChapterPrivate {}; + /*! * \class TagParser::AbstractChapter * \brief The AbstractChapter class parses chapter information. diff --git a/abstractchapter.h b/abstractchapter.h index a47c645..6ee0ce3 100644 --- a/abstractchapter.h +++ b/abstractchapter.h @@ -5,6 +5,7 @@ #include +#include #include #include @@ -12,6 +13,7 @@ namespace TagParser { class AbortableProgressFeedback; class Diagnostics; +struct AbstractChapterPrivate; class TAG_PARSER_EXPORT AbstractChapter { public: @@ -41,6 +43,7 @@ protected: CppUtilities::TimeSpan m_startTime; CppUtilities::TimeSpan m_endTime; std::vector m_tracks; + std::unique_ptr m_p; bool m_hidden; bool m_enabled; }; diff --git a/abstractcontainer.cpp b/abstractcontainer.cpp index 9cd2bfc..cbd2723 100644 --- a/abstractcontainer.cpp +++ b/abstractcontainer.cpp @@ -6,6 +6,9 @@ using namespace CppUtilities; namespace TagParser { +/// \brief The AbstractContainerPrivate struct contains private fields of the AbstractContainer class. +struct AbstractContainerPrivate {}; + /*! * \class TagParser::AbstractContainer * \brief The AbstractContainer class provides an interface and common functionality to parse and make a certain container format. diff --git a/abstractcontainer.h b/abstractcontainer.h index 1b53806..db7e5bf 100644 --- a/abstractcontainer.h +++ b/abstractcontainer.h @@ -11,6 +11,7 @@ #include #include +#include namespace CppUtilities { class BinaryReader; @@ -25,6 +26,7 @@ class AbstractChapter; class AbstractAttachment; class Diagnostics; class AbortableProgressFeedback; +struct AbstractContainerPrivate; class TAG_PARSER_EXPORT AbstractContainer { public: @@ -119,6 +121,7 @@ private: std::iostream *m_stream; CppUtilities::BinaryReader m_reader; CppUtilities::BinaryWriter m_writer; + std::unique_ptr m_p; }; /*! diff --git a/abstracttrack.cpp b/abstracttrack.cpp index b959f43..800877c 100644 --- a/abstracttrack.cpp +++ b/abstracttrack.cpp @@ -11,6 +11,9 @@ using namespace CppUtilities; namespace TagParser { +/// \brief The AbstractTrackPrivate struct contains private fields of the AbstractTrack class. +struct AbstractTrackPrivate {}; + /*! * \class TagParser::AbstractTrack * \brief The AbstractTrack class parses and stores technical information about diff --git a/abstracttrack.h b/abstracttrack.h index 9b38d4d..249141a 100644 --- a/abstracttrack.h +++ b/abstracttrack.h @@ -15,6 +15,7 @@ #include #include +#include #include #include @@ -104,6 +105,8 @@ CPP_UTILITIES_MARK_FLAG_ENUM_CLASS(TagParser, TagParser::TrackFlags) namespace TagParser { +struct AbstractTrackPrivate; + class TAG_PARSER_EXPORT AbstractTrack { friend class MpegAudioFrameStream; friend class WaveAudioStream; @@ -232,6 +235,7 @@ protected: AlphaMode m_alphaMode; DisplayUnit m_displayUnit; AspectRatioType m_aspectRatioType; + std::unique_ptr m_p; private: std::string makeDescription(bool verbose) const; diff --git a/mediafileinfo.cpp b/mediafileinfo.cpp index 407f81d..112c13e 100644 --- a/mediafileinfo.cpp +++ b/mediafileinfo.cpp @@ -59,6 +59,9 @@ using namespace CppUtilities; namespace TagParser { +/// \brief The MediaFileInfoPrivate struct contains private fields of the MediaFileInfo class. +struct MediaFileInfoPrivate {}; + /*! * \class TagParser::MediaFileInfo * \brief The MediaFileInfo class allows to read and write tag information providing diff --git a/mediafileinfo.h b/mediafileinfo.h index 4fa5ba8..80d068b 100644 --- a/mediafileinfo.h +++ b/mediafileinfo.h @@ -73,6 +73,8 @@ CPP_UTILITIES_MARK_FLAG_ENUM_CLASS(TagParser, TagParser::MediaFileHandlingFlags) namespace TagParser { +struct MediaFileInfoPrivate; + class TAG_PARSER_EXPORT MediaFileInfo : public BasicFileInfo { public: // constructor, destructor @@ -226,6 +228,7 @@ private: ElementPosition m_tagPosition; ElementPosition m_indexPosition; MediaFileHandlingFlags m_fileHandlingFlags; + std::unique_ptr m_p; }; /*! diff --git a/tag.cpp b/tag.cpp index c995ed2..5701109 100644 --- a/tag.cpp +++ b/tag.cpp @@ -4,6 +4,9 @@ using namespace std; namespace TagParser { +/// \brief The TagPrivate struct contains private fields of the Tag class. +struct TagPrivate {}; + /*! * \class TagParser::Tag * \brief The Tag class is used to store, read and write tag information. diff --git a/tag.h b/tag.h index 587e33a..5fe6c51 100644 --- a/tag.h +++ b/tag.h @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -160,6 +161,8 @@ constexpr KnownField nextKnownField(KnownField field) return isKnownFieldDeprecated(next) ? nextKnownField(next) : next; } +struct TagPrivate; + class TAG_PARSER_EXPORT Tag { public: virtual ~Tag(); @@ -199,6 +202,7 @@ protected: std::string m_version; std::uint64_t m_size; + std::unique_ptr m_p; TagTarget m_target; }; diff --git a/tagvalue.cpp b/tagvalue.cpp index fd9c26c..eab61ff 100644 --- a/tagvalue.cpp +++ b/tagvalue.cpp @@ -22,6 +22,9 @@ using namespace CppUtilities; namespace TagParser { +/// \brief The TagValuePrivate struct contains private fields of the TagValue class. +struct TagValuePrivate {}; + /*! * \brief Returns the string representation of the specified \a dataType. */ @@ -145,6 +148,140 @@ TagValue::TagValue(const TagValue &other) } } +TagValue::TagValue(TagValue &&other) = default; + +/*! + * \brief Constructs an empty TagValue. + */ +TagValue::TagValue() + : m_size(0) + , m_type(TagDataType::Undefined) + , m_encoding(TagTextEncoding::Latin1) + , m_descEncoding(TagTextEncoding::Latin1) + , m_flags(TagValueFlags::None) +{ +} + +/*! + * \brief Constructs a new TagValue holding a copy of the given \a text. + * \param text Specifies the text to be assigned. + * \param textSize Specifies the size of \a text. (The actual number of bytes, not the number of characters.) + * \param textEncoding Specifies the encoding of the given \a text. + * \param convertTo Specifies the encoding to convert \a text to; set to TagTextEncoding::Unspecified to + * use \a textEncoding without any character set conversions. + * \throws Throws a ConversionException if the conversion the specified character set fails. + * \remarks Strips the BOM of the specified \a text. + */ +TagValue::TagValue(const char *text, std::size_t textSize, TagTextEncoding textEncoding, TagTextEncoding convertTo) + : m_descEncoding(TagTextEncoding::Latin1) + , m_flags(TagValueFlags::None) +{ + assignText(text, textSize, textEncoding, convertTo); +} + +/*! + * \brief Constructs a new TagValue holding a copy of the given \a text. + * \param text Specifies the text to be assigned. This string must be null-terminated. + * \param textEncoding Specifies the encoding of the given \a text. + * \param convertTo Specifies the encoding to convert \a text to; set to TagTextEncoding::Unspecified to + * use \a textEncoding without any character set conversions. + * \throws Throws a ConversionException if the conversion the specified character set fails. + * \remarks Strips the BOM of the specified \a text. + */ +TagValue::TagValue(const char *text, TagTextEncoding textEncoding, TagTextEncoding convertTo) +{ + assignText(text, std::strlen(text), textEncoding, convertTo); +} + +/*! + * \brief Constructs a new TagValue holding a copy of the given \a text. + * \param text Specifies the text to be assigned. + * \param textEncoding Specifies the encoding of the given \a text. + * \param convertTo Specifies the encoding to convert \a text to; set to TagTextEncoding::Unspecified to + * use \a textEncoding without any character set conversions. + * \throws Throws a ConversionException if the conversion the specified character set fails. + * \remarks Strips the BOM of the specified \a text. + */ +TagValue::TagValue(const std::string &text, TagTextEncoding textEncoding, TagTextEncoding convertTo) + : m_descEncoding(TagTextEncoding::Latin1) + , m_flags(TagValueFlags::None) +{ + assignText(text, textEncoding, convertTo); +} + +/*! + * \brief Constructs a new TagValue holding a copy of the given \a text. + * \param text Specifies the text to be assigned. + * \param textEncoding Specifies the encoding of the given \a text. + * \param convertTo Specifies the encoding to convert \a text to; set to TagTextEncoding::Unspecified to + * use \a textEncoding without any character set conversions. + * \throws Throws a ConversionException if the conversion the specified character set fails. + * \remarks Strips the BOM of the specified \a text. + */ +TagValue::TagValue(std::string_view text, TagTextEncoding textEncoding, TagTextEncoding convertTo) + : m_descEncoding(TagTextEncoding::Latin1) + , m_flags(TagValueFlags::None) +{ + assignText(text, textEncoding, convertTo); +} + +/*! + * \brief Destroys the TagValue. + */ +TagValue::~TagValue() +{ +} + +/*! + * \brief Constructs a new TagValue with a copy of the given \a data. + * + * \param data Specifies a pointer to the data. + * \param length Specifies the length of the data. + * \param type Specifies the type of the data as TagDataType. + * \param encoding Specifies the encoding of the data as TagTextEncoding. The + * encoding will only be considered if a text is assigned. + * \remarks Strips the BOM of the specified \a data if \a type is TagDataType::Text. + */ +TagValue::TagValue(const char *data, std::size_t length, TagDataType type, TagTextEncoding encoding) + : m_size(length) + , m_type(type) + , m_encoding(encoding) + , m_descEncoding(TagTextEncoding::Latin1) + , m_flags(TagValueFlags::None) +{ + if (length) { + if (type == TagDataType::Text) { + stripBom(data, m_size, encoding); + } + m_ptr = std::make_unique(m_size); + std::copy(data, data + m_size, m_ptr.get()); + } +} + +/*! + * \brief Constructs a new TagValue holding with the given \a data. + * + * The \a data is not copied. It is moved. + * + * \param data Specifies a pointer to the data. + * \param length Specifies the length of the data. + * \param type Specifies the type of the data as TagDataType. + * \param encoding Specifies the encoding of the data as TagTextEncoding. The + * encoding will only be considered if a text is assigned. + * \remarks Does not strip the BOM so for consistency the caller must ensure there is no BOM present. + */ +TagValue::TagValue(std::unique_ptr &&data, std::size_t length, TagDataType type, TagTextEncoding encoding) + : m_size(length) + , m_type(type) + , m_encoding(encoding) + , m_descEncoding(TagTextEncoding::Latin1) + , m_flags(TagValueFlags::None) +{ + if (length) { + m_ptr = std::move(data); + } +} + /*! * \brief Assigns the value of another TagValue to the current instance. */ @@ -170,6 +307,8 @@ TagValue &TagValue::operator=(const TagValue &other) return *this; } +TagValue &TagValue::operator=(TagValue &&other) = default; + /// \cond TagTextEncoding pickUtfEncoding(TagTextEncoding encoding1, TagTextEncoding encoding2) { diff --git a/tagvalue.h b/tagvalue.h index 1f57ddf..7b540d1 100644 --- a/tagvalue.h +++ b/tagvalue.h @@ -140,6 +140,8 @@ enum class TagValueComparisionFlags : unsigned int { IgnoreMetaData = 0x2, /**< do *not* take meta-data like description and MIME-types into account */ }; +struct TagValuePrivate; + class TAG_PARSER_EXPORT TagValue { public: // constructor, destructor @@ -164,12 +166,12 @@ public: explicit TagValue(CppUtilities::TimeSpan value); explicit TagValue(const Popularity &value); TagValue(const TagValue &other); - TagValue(TagValue &&other) = default; + TagValue(TagValue &&other); ~TagValue(); // operators TagValue &operator=(const TagValue &other); - TagValue &operator=(TagValue &&other) = default; + TagValue &operator=(TagValue &&other); bool operator==(const TagValue &other) const; bool operator!=(const TagValue &other) const; operator bool() const; @@ -260,90 +262,9 @@ private: TagTextEncoding m_encoding; TagTextEncoding m_descEncoding; TagValueFlags m_flags; + std::unique_ptr m_p; }; -/*! - * \brief Constructs an empty TagValue. - */ -inline TagValue::TagValue() - : m_size(0) - , m_type(TagDataType::Undefined) - , m_encoding(TagTextEncoding::Latin1) - , m_descEncoding(TagTextEncoding::Latin1) - , m_flags(TagValueFlags::None) -{ -} - -/*! - * \brief Destroys the TagValue. - */ -inline TagValue::~TagValue() -{ -} - -/*! - * \brief Constructs a new TagValue holding a copy of the given \a text. - * \param text Specifies the text to be assigned. - * \param textSize Specifies the size of \a text. (The actual number of bytes, not the number of characters.) - * \param textEncoding Specifies the encoding of the given \a text. - * \param convertTo Specifies the encoding to convert \a text to; set to TagTextEncoding::Unspecified to - * use \a textEncoding without any character set conversions. - * \throws Throws a ConversionException if the conversion the specified character set fails. - * \remarks Strips the BOM of the specified \a text. - */ -inline TagValue::TagValue(const char *text, std::size_t textSize, TagTextEncoding textEncoding, TagTextEncoding convertTo) - : m_descEncoding(TagTextEncoding::Latin1) - , m_flags(TagValueFlags::None) -{ - assignText(text, textSize, textEncoding, convertTo); -} - -/*! - * \brief Constructs a new TagValue holding a copy of the given \a text. - * \param text Specifies the text to be assigned. This string must be null-terminated. - * \param textEncoding Specifies the encoding of the given \a text. - * \param convertTo Specifies the encoding to convert \a text to; set to TagTextEncoding::Unspecified to - * use \a textEncoding without any character set conversions. - * \throws Throws a ConversionException if the conversion the specified character set fails. - * \remarks Strips the BOM of the specified \a text. - */ -inline TagValue::TagValue(const char *text, TagTextEncoding textEncoding, TagTextEncoding convertTo) -{ - assignText(text, std::strlen(text), textEncoding, convertTo); -} - -/*! - * \brief Constructs a new TagValue holding a copy of the given \a text. - * \param text Specifies the text to be assigned. - * \param textEncoding Specifies the encoding of the given \a text. - * \param convertTo Specifies the encoding to convert \a text to; set to TagTextEncoding::Unspecified to - * use \a textEncoding without any character set conversions. - * \throws Throws a ConversionException if the conversion the specified character set fails. - * \remarks Strips the BOM of the specified \a text. - */ -inline TagValue::TagValue(const std::string &text, TagTextEncoding textEncoding, TagTextEncoding convertTo) - : m_descEncoding(TagTextEncoding::Latin1) - , m_flags(TagValueFlags::None) -{ - assignText(text, textEncoding, convertTo); -} - -/*! - * \brief Constructs a new TagValue holding a copy of the given \a text. - * \param text Specifies the text to be assigned. - * \param textEncoding Specifies the encoding of the given \a text. - * \param convertTo Specifies the encoding to convert \a text to; set to TagTextEncoding::Unspecified to - * use \a textEncoding without any character set conversions. - * \throws Throws a ConversionException if the conversion the specified character set fails. - * \remarks Strips the BOM of the specified \a text. - */ -inline TagValue::TagValue(std::string_view text, TagTextEncoding textEncoding, TagTextEncoding convertTo) - : m_descEncoding(TagTextEncoding::Latin1) - , m_flags(TagValueFlags::None) -{ - assignText(text, textEncoding, convertTo); -} - /*! * \brief Constructs a new TagValue holding the given integer \a value. */ @@ -360,56 +281,6 @@ inline TagParser::TagValue::TagValue(std::uint64_t value) { } -/*! - * \brief Constructs a new TagValue with a copy of the given \a data. - * - * \param data Specifies a pointer to the data. - * \param length Specifies the length of the data. - * \param type Specifies the type of the data as TagDataType. - * \param encoding Specifies the encoding of the data as TagTextEncoding. The - * encoding will only be considered if a text is assigned. - * \remarks Strips the BOM of the specified \a data if \a type is TagDataType::Text. - */ -inline TagValue::TagValue(const char *data, std::size_t length, TagDataType type, TagTextEncoding encoding) - : m_size(length) - , m_type(type) - , m_encoding(encoding) - , m_descEncoding(TagTextEncoding::Latin1) - , m_flags(TagValueFlags::None) -{ - if (length) { - if (type == TagDataType::Text) { - stripBom(data, m_size, encoding); - } - m_ptr = std::make_unique(m_size); - std::copy(data, data + m_size, m_ptr.get()); - } -} - -/*! - * \brief Constructs a new TagValue holding with the given \a data. - * - * The \a data is not copied. It is moved. - * - * \param data Specifies a pointer to the data. - * \param length Specifies the length of the data. - * \param type Specifies the type of the data as TagDataType. - * \param encoding Specifies the encoding of the data as TagTextEncoding. The - * encoding will only be considered if a text is assigned. - * \remarks Does not strip the BOM so for consistency the caller must ensure there is no BOM present. - */ -inline TagValue::TagValue(std::unique_ptr &&data, std::size_t length, TagDataType type, TagTextEncoding encoding) - : m_size(length) - , m_type(type) - , m_encoding(encoding) - , m_descEncoding(TagTextEncoding::Latin1) - , m_flags(TagValueFlags::None) -{ - if (length) { - m_ptr = std::move(data); - } -} - /*! * \brief Constructs a new TagValue holding a copy of the given PositionInSet \a value. */