From 7a02e8a325a1792067da94ab486de6197fbd3a55 Mon Sep 17 00:00:00 2001 From: Martchus Date: Tue, 7 Mar 2017 17:16:17 +0100 Subject: [PATCH] Uniform/simplify typedefs in templates * Begin type names with capital letter * Remove typedefs for implementation type * Remove useless/obsolete comments * Simplify relevant code --- fieldbasedtag.h | 79 +++++++++--------- genericcontainer.h | 8 +- genericfileelement.h | 137 +++++++++++++++----------------- generictagfield.h | 44 +++++----- id3/id3v2frame.cpp | 2 +- id3/id3v2frame.h | 26 ++---- id3/id3v2tag.cpp | 4 +- id3/id3v2tag.h | 9 +-- matroska/ebmlelement.cpp | 27 ++++--- matroska/ebmlelement.h | 32 ++------ matroska/matroskaattachment.cpp | 6 +- matroska/matroskacontainer.cpp | 2 +- matroska/matroskaseekinfo.cpp | 4 +- matroska/matroskaseekinfo.h | 14 ++-- matroska/matroskatag.cpp | 4 +- matroska/matroskatag.h | 9 +-- matroska/matroskatagfield.h | 17 +--- mp4/mp4atom.cpp | 6 +- mp4/mp4atom.h | 30 ++----- mp4/mp4tag.cpp | 8 +- mp4/mp4tag.h | 9 +-- mp4/mp4tagfield.cpp | 2 +- mp4/mp4tagfield.h | 26 ++---- mp4/mpeg4descriptor.cpp | 10 +-- mp4/mpeg4descriptor.h | 26 ++---- vorbis/vorbiscomment.cpp | 6 +- vorbis/vorbiscomment.h | 9 +-- vorbis/vorbiscommentfield.cpp | 2 +- vorbis/vorbiscommentfield.h | 16 +--- 29 files changed, 235 insertions(+), 339 deletions(-) diff --git a/fieldbasedtag.h b/fieldbasedtag.h index 6172d07..f9b5fd0 100644 --- a/fieldbasedtag.h +++ b/fieldbasedtag.h @@ -35,49 +35,48 @@ class FieldMapBasedTag : public Tag friend class FieldMapBasedTagTraits; public: - typedef typename FieldMapBasedTagTraits::implementationType implementationType; - typedef typename FieldMapBasedTagTraits::fieldType fieldType; - typedef typename FieldMapBasedTagTraits::fieldType::identifierType identifierType; - typedef typename FieldMapBasedTagTraits::compare compare; + typedef typename FieldMapBasedTagTraits::FieldType FieldType; + typedef typename FieldMapBasedTagTraits::FieldType::IdentifierType IdentifierType; + typedef typename FieldMapBasedTagTraits::Compare Compare; FieldMapBasedTag(); TagType type() const; const char *typeName() const; TagTextEncoding proposedTextEncoding() const; - const TagValue &value(const identifierType &id) const; + const TagValue &value(const IdentifierType &id) const; const TagValue &value(KnownField field) const; - std::vector values(const identifierType &id) const; + std::vector values(const IdentifierType &id) const; std::vector values(KnownField field) const; - bool setValue(const identifierType &id, const TagValue &value); + bool setValue(const IdentifierType &id, const TagValue &value); bool setValue(KnownField field, const TagValue &value); - bool setValues(const identifierType &id, const std::vector &values); + bool setValues(const IdentifierType &id, const std::vector &values); bool setValues(KnownField field, const std::vector &values); bool hasField(KnownField field) const; - bool hasField(const identifierType &id) const; + bool hasField(const IdentifierType &id) const; void removeAllFields(); - const std::multimap &fields() const; - std::multimap &fields(); + const std::multimap &fields() const; + std::multimap &fields(); unsigned int fieldCount() const; - identifierType fieldId(KnownField value) const; - KnownField knownField(const identifierType &id) const; + IdentifierType fieldId(KnownField value) const; + KnownField knownField(const IdentifierType &id) const; bool supportsField(KnownField field) const; using Tag::proposedDataType; - TagDataType proposedDataType(const identifierType &id) const; + TagDataType proposedDataType(const IdentifierType &id) const; int insertFields(const FieldMapBasedTag &from, bool overwrite); unsigned int insertValues(const Tag &from, bool overwrite); void ensureTextValuesAreProperlyEncoded(); protected: - const TagValue &internallyGetValue(const identifierType &id) const; - bool internallySetValue(const identifierType &id, const TagValue &value); - bool internallyHasField(const identifierType &id) const; - // no default implementation: identifierType internallyGetFieldId(KnownField field) const; - // no default implementation: KnownField internallyGetKnownField(const identifierType &id) const; - TagDataType internallyGetProposedDataType(const identifierType &id) const; + const TagValue &internallyGetValue(const IdentifierType &id) const; + bool internallySetValue(const IdentifierType &id, const TagValue &value); + bool internallyHasField(const IdentifierType &id) const; + // no default implementation: IdentifierType internallyGetFieldId(KnownField field) const; + // no default implementation: KnownField internallyGetKnownField(const IdentifierType &id) const; + TagDataType internallyGetProposedDataType(const IdentifierType &id) const; private: - std::multimap m_fields; + std::multimap m_fields; }; /*! @@ -124,7 +123,7 @@ TagTextEncoding FieldMapBasedTag::proposedTextEncoding() con * \remarks Shadow in subclass to provide custom implementation. */ template -const TagValue &FieldMapBasedTag::internallyGetValue(const identifierType &id) const +const TagValue &FieldMapBasedTag::internallyGetValue(const IdentifierType &id) const { auto i = m_fields.find(id); return i != m_fields.end() ? i->second.value() : TagValue::empty(); @@ -135,7 +134,7 @@ const TagValue &FieldMapBasedTag::internallyGetValue(const i * \sa Tag::value() */ template -inline const TagValue &FieldMapBasedTag::value(const identifierType &id) const +inline const TagValue &FieldMapBasedTag::value(const IdentifierType &id) const { return static_cast(this)->internallyGetValue(id); } @@ -151,7 +150,7 @@ inline const TagValue &FieldMapBasedTag::value(KnownField fi * \sa Tag::values() */ template -inline std::vector FieldMapBasedTag::values(const identifierType &id) const +inline std::vector FieldMapBasedTag::values(const IdentifierType &id) const { auto range = m_fields.equal_range(id); std::vector values; @@ -180,13 +179,13 @@ inline bool FieldMapBasedTag::setValue(KnownField field, con * \remarks Shadow in subclass to provide custom implementation. */ template -bool FieldMapBasedTag::internallySetValue(const identifierType &id, const TagValue &value) +bool FieldMapBasedTag::internallySetValue(const IdentifierType &id, const TagValue &value) { auto i = m_fields.find(id); if(i != m_fields.end()) { // field already exists -> set its value i->second.setValue(value); } else if(!value.isEmpty()) { // field doesn't exist -> create new one if value is not null - m_fields.insert(std::make_pair(id, fieldType(id, value))); + m_fields.insert(std::make_pair(id, FieldType(id, value))); } else { // otherwise return false return false; } @@ -198,7 +197,7 @@ bool FieldMapBasedTag::internallySetValue(const identifierTy * \sa Tag::setValue() */ template -bool FieldMapBasedTag::setValue(const identifierType &id, const Media::TagValue &value) +bool FieldMapBasedTag::setValue(const IdentifierType &id, const Media::TagValue &value) { return static_cast(this)->internallySetValue(id, value); } @@ -210,7 +209,7 @@ bool FieldMapBasedTag::setValue(const identifierType &id, co * \sa Tag::setValues() */ template -bool FieldMapBasedTag::setValues(const identifierType &id, const std::vector &values) +bool FieldMapBasedTag::setValues(const IdentifierType &id, const std::vector &values) { auto valuesIterator = values.cbegin(); auto range = m_fields.equal_range(id); @@ -224,7 +223,7 @@ bool FieldMapBasedTag::setValues(const identifierType &id, c } // add remaining specified values (there are more specified values than existing ones) for(; valuesIterator != values.cend(); ++valuesIterator) { - m_fields.insert(std::make_pair(id, fieldType(id, *valuesIterator))); + m_fields.insert(std::make_pair(id, FieldType(id, *valuesIterator))); } // remove remaining existing values (there are more existing values than specified ones) for(; range.first != range.second; ++range.first) { @@ -256,7 +255,7 @@ inline bool FieldMapBasedTag::hasField(KnownField field) con * \remarks Shadow in subclass to provide custom implementation. */ template -bool FieldMapBasedTag::internallyHasField(const identifierType &id) const +bool FieldMapBasedTag::internallyHasField(const IdentifierType &id) const { for (auto range = m_fields.equal_range(id); range.first != range.second; ++range.first) { if(!range.first->second.value().isEmpty()) { @@ -270,7 +269,7 @@ bool FieldMapBasedTag::internallyHasField(const identifierTy * \brief Returns an indication whether the field with the specified \a id is present. */ template -inline bool FieldMapBasedTag::hasField(const identifierType &id) const +inline bool FieldMapBasedTag::hasField(const IdentifierType &id) const { return static_cast(this)->internallyHasField(id); } @@ -285,7 +284,7 @@ inline void FieldMapBasedTag::removeAllFields() * \brief Returns the fields of the tag by providing direct access to the field map of the tag. */ template -inline auto FieldMapBasedTag::fields() const -> const std::multimap & +inline auto FieldMapBasedTag::fields() const -> const std::multimap & { return m_fields; } @@ -294,7 +293,7 @@ inline auto FieldMapBasedTag::fields() const -> const std::m * \brief Returns the fields of the tag by providing direct access to the field map of the tag. */ template -inline auto FieldMapBasedTag::fields() -> std::multimap & +inline auto FieldMapBasedTag::fields() -> std::multimap & { return m_fields; } @@ -316,7 +315,7 @@ unsigned int FieldMapBasedTag::fieldCount() const * \remarks Must be implemented in internallyGetFieldId() when creating subclass. */ template -inline typename FieldMapBasedTag::identifierType FieldMapBasedTag::fieldId(KnownField value) const +inline typename FieldMapBasedTag::IdentifierType FieldMapBasedTag::fieldId(KnownField value) const { return static_cast(this)->internallyGetFieldId(value); } @@ -326,7 +325,7 @@ inline typename FieldMapBasedTag::identifierType FieldMapBas * \remarks Must be implemented in internallyGetKnownField() when creating subclass. */ template -inline KnownField FieldMapBasedTag::knownField(const identifierType &id) const +inline KnownField FieldMapBasedTag::knownField(const IdentifierType &id) const { return static_cast *>(this)->internallyGetKnownField(id); } @@ -334,7 +333,7 @@ inline KnownField FieldMapBasedTag::knownField(const identif template inline bool FieldMapBasedTag::supportsField(KnownField field) const { - static identifierType def; + static IdentifierType def; return fieldId(field) != def; } @@ -343,7 +342,7 @@ inline bool FieldMapBasedTag::supportsField(KnownField field * \remarks Shadow in subclass to provide custom implementation. */ template -inline TagDataType FieldMapBasedTag::internallyGetProposedDataType(const identifierType &id) const +inline TagDataType FieldMapBasedTag::internallyGetProposedDataType(const IdentifierType &id) const { return Tag::proposedDataType(knownField(id)); } @@ -352,7 +351,7 @@ inline TagDataType FieldMapBasedTag::internallyGetProposedDa * \brief Returns the proposed data type for the field with the specified \a id. */ template -inline TagDataType FieldMapBasedTag::proposedDataType(const identifierType &id) const +inline TagDataType FieldMapBasedTag::proposedDataType(const IdentifierType &id) const { return static_cast(this)->determineProposedDataType(id); } @@ -368,13 +367,13 @@ int FieldMapBasedTag::insertFields(const FieldMapBasedTagsecond; + FieldType &ownField = i->second; if((fromField.isTypeInfoAssigned() && ownField.isTypeInfoAssigned() && fromField.typeInfo() == ownField.typeInfo()) || (!fromField.isTypeInfoAssigned() && ! ownField.isTypeInfoAssigned())) { diff --git a/genericcontainer.h b/genericcontainer.h index 9da5d8a..7fbc42f 100644 --- a/genericcontainer.h +++ b/genericcontainer.h @@ -52,10 +52,10 @@ public: void removeAllTracks(); void reset(); - typedef FileInfoType fileInfoType; - typedef TagType tagType; - typedef TrackType trackType; - typedef ElementType elementType; + typedef FileInfoType ContainerFileInfoType; + typedef TagType ContainerTagType; + typedef TrackType ContainerTrackType; + typedef ElementType ContainerElementType; protected: std::unique_ptr m_firstElement; diff --git a/genericfileelement.h b/genericfileelement.h index 0e1253e..5897dee 100644 --- a/genericfileelement.h +++ b/genericfileelement.h @@ -121,61 +121,56 @@ public: /*! * \brief Specifies the type of the corresponding container. */ - typedef typename FileElementTraits::containerType containerType; + typedef typename FileElementTraits::ContainerType ContainerType; /*! * \brief Specifies the type used to store identifiers. */ - typedef typename FileElementTraits::identifierType identifierType; + typedef typename FileElementTraits::IdentifierType IdentifierType; /*! * \brief Specifies the type used to store data sizes. */ - typedef typename FileElementTraits::dataSizeType dataSizeType; + typedef typename FileElementTraits::DataSizeType DataSizeType; - /*! - * \brief Specifies the type of the actual implementation. - */ - typedef typename FileElementTraits::implementationType implementationType; - - GenericFileElement(containerType &container, uint64 startOffset); - GenericFileElement(implementationType &parent, uint64 startOffset); - GenericFileElement(containerType &container, uint64 startOffset, uint64 maxSize); + GenericFileElement(ContainerType &container, uint64 startOffset); + GenericFileElement(ImplementationType &parent, uint64 startOffset); + GenericFileElement(ContainerType &container, uint64 startOffset, uint64 maxSize); GenericFileElement(const GenericFileElement& other) = delete; GenericFileElement(GenericFileElement& other) = delete; GenericFileElement& operator =(const GenericFileElement& other) = delete; - containerType& container(); - const containerType& container() const; + ContainerType& container(); + const ContainerType& container() const; std::iostream &stream(); IoUtilities::BinaryReader &reader(); IoUtilities::BinaryWriter &writer(); uint64 startOffset() const; uint64 relativeStartOffset() const; - const identifierType &id() const; + const IdentifierType &id() const; std::string idToString() const; uint32 idLength() const; uint32 headerSize() const; - dataSizeType dataSize() const; + DataSizeType dataSize() const; uint32 sizeLength() const; uint64 dataOffset() const; uint64 totalSize() const; uint64 endOffset() const; uint64 maxTotalSize() const; - implementationType* parent(); - const implementationType* parent() const; - implementationType* nextSibling(); - const implementationType* nextSibling() const; - implementationType* firstChild(); - const implementationType* firstChild() const; - implementationType* subelementByPath(const std::initializer_list &path); - implementationType* subelementByPath(std::list &path); - implementationType* childById(const identifierType &id); - implementationType* siblingById(const identifierType &id, bool includeThis = false); - FileElementIterator begin(); - FileElementIterator end(); - const FileElementIterator begin() const; - const FileElementIterator end() const; + ImplementationType* parent(); + const ImplementationType* parent() const; + ImplementationType* nextSibling(); + const ImplementationType* nextSibling() const; + ImplementationType* firstChild(); + const ImplementationType* firstChild() const; + ImplementationType* subelementByPath(const std::initializer_list &path); + ImplementationType* subelementByPath(std::list &path); + ImplementationType* childById(const IdentifierType &id); + ImplementationType* siblingById(const IdentifierType &id, bool includeThis = false); + FileElementIterator begin(); + FileElementIterator end(); + const FileElementIterator begin() const; + const FileElementIterator end() const; bool isParent() const; bool isPadding() const; uint64 firstChildOffset() const; @@ -195,24 +190,24 @@ public: void copyBuffer(std::ostream &targetStream); void copyPreferablyFromBuffer(std::ostream &targetStream); const std::unique_ptr &buffer(); - implementationType *denoteFirstChild(uint32 offset); + ImplementationType *denoteFirstChild(uint32 offset); protected: - identifierType m_id; + IdentifierType m_id; uint64 m_startOffset; uint64 m_maxSize; uint32 m_idLength; - dataSizeType m_dataSize; + DataSizeType m_dataSize; uint32 m_sizeLength; - implementationType* m_parent; - std::unique_ptr m_nextSibling; - std::unique_ptr m_firstChild; + ImplementationType* m_parent; + std::unique_ptr m_nextSibling; + std::unique_ptr m_firstChild; std::unique_ptr m_buffer; private: void copyInternal(std::ostream &targetStream, uint64 startOffset, uint64 bytesToCopy); - containerType* m_container; + ContainerType* m_container; bool m_parsed; }; @@ -221,8 +216,8 @@ private: * \remarks The available size is obtained using the stream of the \a container. */ template -GenericFileElement::GenericFileElement(GenericFileElement::containerType &container, uint64 startOffset) : - m_id(identifierType()), +GenericFileElement::GenericFileElement(GenericFileElement::ContainerType &container, uint64 startOffset) : + m_id(IdentifierType()), m_startOffset(startOffset), m_idLength(0), m_dataSize(0), @@ -244,8 +239,8 @@ GenericFileElement::GenericFileElement(GenericFileElement -GenericFileElement::GenericFileElement(GenericFileElement::implementationType &parent, uint64 startOffset) : - m_id(identifierType()), +GenericFileElement::GenericFileElement(ImplementationType &parent, uint64 startOffset) : + m_id(IdentifierType()), m_startOffset(startOffset), m_maxSize(parent.startOffset() + parent.totalSize() - startOffset), m_idLength(0), @@ -260,8 +255,8 @@ GenericFileElement::GenericFileElement(GenericFileElement -GenericFileElement::GenericFileElement(GenericFileElement::containerType &container, uint64 startOffset, uint64 maxSize) : - m_id(identifierType()), +GenericFileElement::GenericFileElement(GenericFileElement::ContainerType &container, uint64 startOffset, uint64 maxSize) : + m_id(IdentifierType()), m_startOffset(startOffset), m_maxSize(maxSize), m_idLength(0), @@ -276,7 +271,7 @@ GenericFileElement::GenericFileElement(GenericFileElement -inline typename GenericFileElement::containerType& GenericFileElement::container() +inline typename GenericFileElement::ContainerType& GenericFileElement::container() { return *m_container; } @@ -285,7 +280,7 @@ inline typename GenericFileElement::containerType& GenericFi * \brief Returns the related container. */ template -inline const typename GenericFileElement::containerType &GenericFileElement::container() const +inline const typename GenericFileElement::ContainerType &GenericFileElement::container() const { return *m_container; } @@ -339,7 +334,7 @@ inline uint64 GenericFileElement::relativeStartOffset() cons * \brief Returns the element ID. */ template -inline const typename GenericFileElement::identifierType &GenericFileElement::id() const +inline const typename GenericFileElement::IdentifierType &GenericFileElement::id() const { return m_id; } @@ -379,7 +374,7 @@ inline uint32 GenericFileElement::headerSize() const * This is the size of the element excluding the header. */ template -inline typename GenericFileElement::dataSizeType GenericFileElement::dataSize() const +inline typename GenericFileElement::DataSizeType GenericFileElement::dataSize() const { return m_dataSize; } @@ -443,7 +438,7 @@ inline uint64 GenericFileElement::maxTotalSize() const * If the current element is a top level element nullptr is returned. */ template -inline typename GenericFileElement::implementationType *GenericFileElement::parent() +inline ImplementationType *GenericFileElement::parent() { return m_parent; } @@ -455,7 +450,7 @@ inline typename GenericFileElement::implementationType *Gene * If the current element is a top level element nullptr is returned. */ template -inline const typename GenericFileElement::implementationType *GenericFileElement::parent() const +inline const ImplementationType *GenericFileElement::parent() const { return m_parent; } @@ -469,7 +464,7 @@ inline const typename GenericFileElement::implementationType * \remarks parse() needs to be called before. */ template -inline typename GenericFileElement::implementationType *GenericFileElement::nextSibling() +inline ImplementationType *GenericFileElement::nextSibling() { return m_nextSibling.get(); } @@ -483,7 +478,7 @@ inline typename GenericFileElement::implementationType *Gene * \remarks parse() needs to be called before. */ template -inline const typename GenericFileElement::implementationType *GenericFileElement::nextSibling() const +inline const ImplementationType *GenericFileElement::nextSibling() const { return m_nextSibling.get(); } @@ -497,7 +492,7 @@ inline const typename GenericFileElement::implementationType * \remarks parse() needs to be called before. */ template -inline typename GenericFileElement::implementationType *GenericFileElement::firstChild() +inline ImplementationType *GenericFileElement::firstChild() { return m_firstChild.get(); } @@ -511,7 +506,7 @@ inline typename GenericFileElement::implementationType *Gene * \remarks parse() needs to be called before. */ template -inline const typename GenericFileElement::implementationType *GenericFileElement::firstChild() const +inline const ImplementationType *GenericFileElement::firstChild() const { return m_firstChild.get(); } @@ -526,9 +521,9 @@ inline const typename GenericFileElement::implementationType * \throws Throws std::ios_base::failure when an IO error occurs. */ template -inline typename GenericFileElement::implementationType *GenericFileElement::subelementByPath(const std::initializer_list &path) +inline ImplementationType *GenericFileElement::subelementByPath(const std::initializer_list &path) { - std::list::identifierType> list(path); + std::list::IdentifierType> list(path); return subelementByPath(list); } @@ -543,13 +538,13 @@ inline typename GenericFileElement::implementationType *Gene * \throws Throws std::ios_base::failure when an IO error occurs. */ template -typename GenericFileElement::implementationType *GenericFileElement::subelementByPath(std::list::identifierType> &path) +ImplementationType *GenericFileElement::subelementByPath(std::list &path) { parse(); // ensure element is parsed if(path.size()) { if(path.front() == id()) { if(path.size() == 1) { - return static_cast(this); + return static_cast(this); } else { if(firstChild()) { path.pop_front(); @@ -575,10 +570,10 @@ typename GenericFileElement::implementationType *GenericFile * \throws Throws std::ios_base::failure when an IO error occurs. */ template -typename GenericFileElement::implementationType *GenericFileElement::childById(const GenericFileElement::identifierType &id) +ImplementationType *GenericFileElement::childById(const IdentifierType &id) { parse(); // ensure element is parsed - for(implementationType *child = firstChild(); child; child = child->nextSibling()) { + for(ImplementationType *child = firstChild(); child; child = child->nextSibling()) { child->parse(); if(child->id() == id) { return child; @@ -602,10 +597,10 @@ typename GenericFileElement::implementationType *GenericFile * \throws Throws std::ios_base::failure when an IO error occurs. */ template -typename GenericFileElement::implementationType *GenericFileElement::siblingById(const GenericFileElement::identifierType &id, bool includeThis) +ImplementationType *GenericFileElement::siblingById(const IdentifierType &id, bool includeThis) { parse(); // ensure element is parsed - for(implementationType *sibling = includeThis ? static_cast(this) : nextSibling(); sibling; sibling = sibling->nextSibling()) { + for(ImplementationType *sibling = includeThis ? static_cast(this) : nextSibling(); sibling; sibling = sibling->nextSibling()) { sibling->parse(); if(sibling->id() == id) { return sibling; @@ -618,25 +613,25 @@ typename GenericFileElement::implementationType *GenericFile * \brief Returns an iterator for iterating over the element's childs. */ template -FileElementIterator::implementationType> GenericFileElement::begin() +FileElementIterator GenericFileElement::begin() { - return FileElementIterator(firstChild()); + return FileElementIterator(firstChild()); } /*! * \brief Returns an iterator for iterating over the element's childs (constant). */ template -const FileElementIterator::implementationType> GenericFileElement::begin() const +const FileElementIterator GenericFileElement::begin() const { - return FileElementIterator(firstChild()); + return FileElementIterator(firstChild()); } /*! * \brief Returns an invalid iterator. */ template -FileElementIterator::implementationType> GenericFileElement::end() +FileElementIterator GenericFileElement::end() { return FileElementIterator(); } @@ -645,7 +640,7 @@ FileElementIterator::implementat * \brief Returns an invalid iterator. */ template -const FileElementIterator::implementationType> GenericFileElement::end() const +const FileElementIterator GenericFileElement::end() const { return FileElementIterator(); } @@ -695,7 +690,7 @@ inline bool GenericFileElement::isParsed() const template void GenericFileElement::clear() { - m_id = identifierType(); + m_id = IdentifierType(); //m_startOffset = 0; m_idLength = 0; m_dataSize = 0; @@ -906,10 +901,10 @@ void GenericFileElement::copyInternal(std::ostream &targetSt * \remarks A new first child is constructed. A possibly existing subtree is invalidated. */ template -typename GenericFileElement::implementationType *GenericFileElement::denoteFirstChild(uint32 relativeFirstChildOffset) +ImplementationType *GenericFileElement::denoteFirstChild(uint32 relativeFirstChildOffset) { if(relativeFirstChildOffset + minimumElementSize() <= totalSize()) { - m_firstChild.reset(new implementationType(static_cast(*this), startOffset() + relativeFirstChildOffset)); + m_firstChild.reset(new ImplementationType(static_cast(*this), startOffset() + relativeFirstChildOffset)); } else { m_firstChild.reset(); } @@ -922,7 +917,7 @@ typename GenericFileElement::implementationType *GenericFile template constexpr uint32 GenericFileElement::maximumIdLengthSupported() { - return sizeof(identifierType); + return sizeof(IdentifierType); } /*! @@ -931,7 +926,7 @@ constexpr uint32 GenericFileElement::maximumIdLengthSupporte template constexpr uint32 GenericFileElement::maximumSizeLengthSupported() { - return sizeof(dataSizeType); + return sizeof(DataSizeType); } /*! diff --git a/generictagfield.h b/generictagfield.h index 45c03ee..73c0b30 100644 --- a/generictagfield.h +++ b/generictagfield.h @@ -32,19 +32,19 @@ class TagFieldTraits template class TAG_PARSER_EXPORT TagField { -public: friend class TagFieldTraits; - typedef typename TagFieldTraits::implementationType implementationType; - typedef typename TagFieldTraits::identifierType identifierType; - typedef typename TagFieldTraits::typeInfoType typeInfoType; + +public: + typedef typename TagFieldTraits::IdentifierType IdentifierType; + typedef typename TagFieldTraits::TypeInfoType TypeInfoType; TagField(); - TagField(const identifierType &id, const TagValue &value); + TagField(const IdentifierType &id, const TagValue &value); ~TagField(); - const identifierType &id() const; + const IdentifierType &id() const; std::string idToString() const; - void setId(const identifierType &id); + void setId(const IdentifierType &id); void clearId(); TagValue &value(); @@ -52,8 +52,8 @@ public: void setValue(const TagValue &value); void clearValue(); - const typeInfoType &typeInfo() const; - void setTypeInfo(const typeInfoType &typeInfo); + const TypeInfoType &typeInfo() const; + void setTypeInfo(const TypeInfoType &typeInfo); void removeTypeInfo(); bool isTypeInfoAssigned() const; @@ -72,9 +72,9 @@ private: void cleared(); private: - identifierType m_id; + IdentifierType m_id; TagValue m_value; - typeInfoType m_typeInfo; + TypeInfoType m_typeInfo; bool m_typeInfoAssigned; bool m_default; std::vector m_nestedFields; @@ -85,9 +85,9 @@ private: */ template TagField::TagField() : - m_id(identifierType()), + m_id(IdentifierType()), m_value(TagValue()), - m_typeInfo(typeInfoType()), + m_typeInfo(TypeInfoType()), m_typeInfoAssigned(false), m_default(false) {} @@ -96,10 +96,10 @@ TagField::TagField() : * \brief Constructs a new TagField with the specified \a id and \a value. */ template -TagField::TagField(const identifierType &id, const TagValue &value) : +TagField::TagField(const IdentifierType &id, const TagValue &value) : m_id(id), m_value(value), - m_typeInfo(typeInfoType()), + m_typeInfo(TypeInfoType()), m_typeInfoAssigned(false), m_default(false) {} @@ -115,7 +115,7 @@ TagField::~TagField() * \brief Returns the id of the current TagField. */ template -inline const typename TagField::identifierType &TagField::id() const +inline const typename TagField::IdentifierType &TagField::id() const { return m_id; } @@ -130,7 +130,7 @@ inline std::string TagField::idToString() const * \brief Sets the id of the current Tag Field. */ template -inline void TagField::setId(const identifierType &id) +inline void TagField::setId(const IdentifierType &id) { m_id = id; } @@ -141,7 +141,7 @@ inline void TagField::setId(const identifierType &id) template inline void TagField::clearId() { - m_id = identifierType(); + m_id = IdentifierType(); } /*! @@ -184,7 +184,7 @@ inline void TagField::clearValue() * \brief Returns the type info of the current TagField. */ template -inline const typename TagField::typeInfoType &TagField::typeInfo() const +inline const typename TagField::TypeInfoType &TagField::typeInfo() const { return m_typeInfo; } @@ -193,7 +193,7 @@ inline const typename TagField::typeInfoType &TagField -inline void TagField::setTypeInfo(const typeInfoType &typeInfo) +inline void TagField::setTypeInfo(const TypeInfoType &typeInfo) { m_typeInfo = typeInfo; m_typeInfoAssigned = true; @@ -205,7 +205,7 @@ inline void TagField::setTypeInfo(const typeInfoType &typeIn template inline void TagField::removeTypeInfo() { - m_typeInfo = typeInfoType(); + m_typeInfo = TypeInfoType(); m_typeInfoAssigned = false; } @@ -244,7 +244,7 @@ void TagField::clear() { clearId(); clearValue(); - m_typeInfo = typeInfoType(); + m_typeInfo = TypeInfoType(); m_typeInfoAssigned = false; m_default = true; static_cast(this)->cleared(); diff --git a/id3/id3v2frame.cpp b/id3/id3v2frame.cpp index 5440348..eba4927 100644 --- a/id3/id3v2frame.cpp +++ b/id3/id3v2frame.cpp @@ -50,7 +50,7 @@ Id3v2Frame::Id3v2Frame() : /*! * \brief Constructs a new Id3v2Frame with the specified \a id, \a value, \a group and \a flag. */ -Id3v2Frame::Id3v2Frame(const identifierType &id, const TagValue &value, const byte group, const int16 flag) : +Id3v2Frame::Id3v2Frame(const IdentifierType &id, const TagValue &value, const byte group, const int16 flag) : TagField(id, value), m_flag(flag), m_group(group), diff --git a/id3/id3v2frame.h b/id3/id3v2frame.h index e270237..df0b924 100644 --- a/id3/id3v2frame.h +++ b/id3/id3v2frame.h @@ -81,20 +81,8 @@ template <> class TAG_PARSER_EXPORT TagFieldTraits { public: - /*! - * \brief Fields in an ID3 tag are identified by 32-bit unsigned integers. - */ - typedef uint32 identifierType; - - /*! - * \brief The type info is stored using bytes. - */ - typedef byte typeInfoType; - - /*! - * \brief The implementation type is Id3v2Frame. - */ - typedef Id3v2Frame implementationType; + typedef uint32 IdentifierType; + typedef byte TypeInfoType; }; class TAG_PARSER_EXPORT Id3v2Frame : public TagField, public StatusProvider @@ -103,7 +91,7 @@ class TAG_PARSER_EXPORT Id3v2Frame : public TagField, public StatusP public: Id3v2Frame(); - Id3v2Frame(const identifierType &id, const TagValue &value, const byte group = 0, const int16 flag = 0); + Id3v2Frame(const IdentifierType &id, const TagValue &value, const byte group = 0, const int16 flag = 0); // parsing/making void parse(IoUtilities::BinaryReader &reader, const uint32 version, const uint32 maximalSize = 0); @@ -153,8 +141,8 @@ public: void makeCommentConsideringVersion(std::unique_ptr &buffer, uint32 &bufferSize, const TagValue &comment, byte version); void makeComment(std::unique_ptr &buffer, uint32 &bufferSize, const TagValue &comment); - static identifierType fieldIdFromString(const char *idString, std::size_t idStringSize = std::string::npos); - static std::string fieldIdToString(identifierType id); + static IdentifierType fieldIdFromString(const char *idString, std::size_t idStringSize = std::string::npos); + static std::string fieldIdToString(IdentifierType id); protected: void cleared(); @@ -334,7 +322,7 @@ inline bool Id3v2Frame::supportsNestedFields() const /*! * \brief Converts the specified ID string representation to an actual ID. */ -inline Id3v2Frame::identifierType Id3v2Frame::fieldIdFromString(const char *idString, std::size_t idStringSize) +inline Id3v2Frame::IdentifierType Id3v2Frame::fieldIdFromString(const char *idString, std::size_t idStringSize) { switch(idStringSize != std::string::npos ? idStringSize : std::strlen(idString)) { case 3: @@ -349,7 +337,7 @@ inline Id3v2Frame::identifierType Id3v2Frame::fieldIdFromString(const char *idSt /*! * \brief Returns the string representation for the specified \a id. */ -inline std::string Id3v2Frame::fieldIdToString(Id3v2Frame::identifierType id) +inline std::string Id3v2Frame::fieldIdToString(Id3v2Frame::IdentifierType id) { return ConversionUtilities::interpretIntegerAsString(id, Id3v2FrameIds::isLongId(id) ? 0 : 1); } diff --git a/id3/id3v2tag.cpp b/id3/id3v2tag.cpp index 62adf94..391cce5 100644 --- a/id3/id3v2tag.cpp +++ b/id3/id3v2tag.cpp @@ -17,7 +17,7 @@ namespace Media { * \brief Implementation of Media::Tag for ID3v2 tags. */ -Id3v2Tag::identifierType Id3v2Tag::internallyGetFieldId(KnownField field) const +Id3v2Tag::IdentifierType Id3v2Tag::internallyGetFieldId(KnownField field) const { using namespace Id3v2FrameIds; if(m_majorVersion >= 3) { @@ -78,7 +78,7 @@ Id3v2Tag::identifierType Id3v2Tag::internallyGetFieldId(KnownField field) const return 0; } -KnownField Id3v2Tag::internallyGetKnownField(const identifierType &id) const +KnownField Id3v2Tag::internallyGetKnownField(const IdentifierType &id) const { using namespace Id3v2FrameIds; switch(id) { diff --git a/id3/id3v2tag.h b/id3/id3v2tag.h index 4aa0fa1..4cdf1d0 100644 --- a/id3/id3v2tag.h +++ b/id3/id3v2tag.h @@ -59,9 +59,8 @@ template <> class TAG_PARSER_EXPORT FieldMapBasedTagTraits { public: - typedef Id3v2Tag implementationType; - typedef Id3v2Frame fieldType; - typedef FrameComparer compare; + typedef Id3v2Frame FieldType; + typedef FrameComparer Compare; }; class TAG_PARSER_EXPORT Id3v2Tag : public FieldMapBasedTag @@ -96,8 +95,8 @@ public: uint32 paddingSize() const; protected: - identifierType internallyGetFieldId(KnownField field) const; - KnownField internallyGetKnownField(const identifierType &id) const; + IdentifierType internallyGetFieldId(KnownField field) const; + KnownField internallyGetKnownField(const IdentifierType &id) const; TagDataType internallyGetProposedDataType(const uint32 &id) const; private: diff --git a/matroska/ebmlelement.cpp b/matroska/ebmlelement.cpp index 0138e72..1617c4f 100644 --- a/matroska/ebmlelement.cpp +++ b/matroska/ebmlelement.cpp @@ -81,11 +81,11 @@ void EbmlElement::internalParse() char buf[maximumIdLengthSupported() > maximumSizeLengthSupported() ? maximumIdLengthSupported() : maximumSizeLengthSupported()] = {0}; byte beg = static_cast(stream().peek()), mask = 0x80; m_idLength = 1; - while(m_idLength <= GenericFileElement::maximumIdLengthSupported() && (beg & mask) == 0) { + while(m_idLength <= maximumIdLengthSupported() && (beg & mask) == 0) { ++m_idLength; mask >>= 1; } - if(m_idLength > GenericFileElement::maximumIdLengthSupported()) { + if(m_idLength > maximumIdLengthSupported()) { if(!skipped) { addNotification(NotificationType::Critical, argsToString("EBML ID length at ", startOffset(), " is not supported, trying to skip."), context); } @@ -97,7 +97,7 @@ void EbmlElement::internalParse() } continue; // try again } - reader().read(buf + (GenericFileElement::maximumIdLengthSupported() - m_idLength), m_idLength); + reader().read(buf + (maximumIdLengthSupported() - m_idLength), m_idLength); m_id = BE::toUInt32(buf); // read size @@ -108,11 +108,11 @@ void EbmlElement::internalParse() // -> just assume the element takes the maximum available size m_dataSize = maxTotalSize() - headerSize(); } else { - while(m_sizeLength <= GenericFileElement::maximumSizeLengthSupported() && (beg & mask) == 0) { + while(m_sizeLength <= maximumSizeLengthSupported() && (beg & mask) == 0) { ++m_sizeLength; mask >>= 1; } - if(m_sizeLength > GenericFileElement::maximumSizeLengthSupported()) { + if(m_sizeLength > maximumSizeLengthSupported()) { if(!skipped) { addNotification(NotificationType::Critical, "EBML size length is not supported.", parsingContext()); } @@ -125,9 +125,10 @@ void EbmlElement::internalParse() continue; // try again } // read size into buffer - memset(buf, 0, sizeof(dataSizeType)); // reset buffer - reader().read(buf + (GenericFileElement::maximumSizeLengthSupported() - m_sizeLength), m_sizeLength); - *(buf + (GenericFileElement::maximumSizeLengthSupported() - m_sizeLength)) ^= mask; // xor the first byte in buffer which has been read from the file with mask + memset(buf, 0, sizeof(DataSizeType)); // reset buffer + reader().read(buf + (maximumSizeLengthSupported() - m_sizeLength), m_sizeLength); + // xor the first byte in buffer which has been read from the file with mask + *(buf + (maximumSizeLengthSupported() - m_sizeLength)) ^= mask; m_dataSize = ConversionUtilities::BE::toUInt64(buf); // check if element is truncated if(totalSize() > maxTotalSize()) { @@ -223,7 +224,7 @@ float64 EbmlElement::readFloat() * \brief Returns the length of the specified \a id in byte. * \throws Throws InvalidDataException() if \a id can not be represented. */ -byte EbmlElement::calculateIdLength(GenericFileElement::identifierType id) +byte EbmlElement::calculateIdLength(GenericFileElement::IdentifierType id) { if(id <= 0xFF) { return 1; @@ -271,7 +272,7 @@ byte EbmlElement::calculateSizeDenotationLength(uint64 size) * \returns Returns the number of bytes written to \a buff. * \throws Throws InvalidDataException() if \a id can not be represented. */ -byte EbmlElement::makeId(GenericFileElement::identifierType id, char *buff) +byte EbmlElement::makeId(GenericFileElement::IdentifierType id, char *buff) { if(id <= 0xFF) { *buff = static_cast(id); @@ -465,7 +466,7 @@ byte EbmlElement::makeUInteger(uint64 value, char *buff, byte minBytes) * \param id Specifies the element ID. * \param content Specifies the value of the element as unsigned integer. */ -void EbmlElement::makeSimpleElement(ostream &stream, identifierType id, uint64 content) +void EbmlElement::makeSimpleElement(ostream &stream, IdentifierType id, uint64 content) { char buff1[8]; char buff2[8]; @@ -483,7 +484,7 @@ void EbmlElement::makeSimpleElement(ostream &stream, identifierType id, uint64 c * \param id Specifies the element ID. * \param content Specifies the value of the element as string. */ -void EbmlElement::makeSimpleElement(std::ostream &stream, GenericFileElement::identifierType id, const std::string &content) +void EbmlElement::makeSimpleElement(std::ostream &stream, GenericFileElement::IdentifierType id, const std::string &content) { char buff1[8]; byte sizeLength = EbmlElement::makeId(id, buff1); @@ -500,7 +501,7 @@ void EbmlElement::makeSimpleElement(std::ostream &stream, GenericFileElement::id * \param data Specifies the data of the element. * \param dataSize Specifies the size of \a data. */ -void EbmlElement::makeSimpleElement(ostream &stream, GenericFileElement::identifierType id, const char *data, std::size_t dataSize) +void EbmlElement::makeSimpleElement(ostream &stream, GenericFileElement::IdentifierType id, const char *data, std::size_t dataSize) { char buff1[8]; byte sizeLength = EbmlElement::makeId(id, buff1); diff --git a/matroska/ebmlelement.h b/matroska/ebmlelement.h index baee0c2..59422e2 100644 --- a/matroska/ebmlelement.h +++ b/matroska/ebmlelement.h @@ -26,25 +26,9 @@ template <> class TAG_PARSER_EXPORT FileElementTraits { public: - /*! - * \brief The container type used to store such elements is MatroskaContainer. - */ - typedef MatroskaContainer containerType; - - /*! - * \brief The type used to store element IDs is an unsigned 32-bit integer. - */ - typedef uint32 identifierType; - - /*! - * \brief The type used to store element sizes is an unsigned 64-bit integer. - */ - typedef uint64 dataSizeType; - - /*! - * \brief The implementation type is EbmlElement. - */ - typedef EbmlElement implementationType; + typedef MatroskaContainer ContainerType; + typedef uint32 IdentifierType; + typedef uint64 DataSizeType; }; class TAG_PARSER_EXPORT EbmlElement : public GenericFileElement @@ -62,17 +46,17 @@ public: uint64 readUInteger(); float64 readFloat(); - static byte calculateIdLength(identifierType id); + static byte calculateIdLength(IdentifierType id); static byte calculateSizeDenotationLength(uint64 size); - static byte makeId(identifierType id, char *buff); + static byte makeId(IdentifierType id, char *buff); static byte makeSizeDenotation(uint64 size, char *buff); static byte makeSizeDenotation(uint64 size, char *buff, byte minBytes); static byte calculateUIntegerLength(uint64 integer); static byte makeUInteger(uint64 value, char *buff); static byte makeUInteger(uint64 value, char *buff, byte minBytes); - static void makeSimpleElement(std::ostream &stream, identifierType id, uint64 content); - static void makeSimpleElement(std::ostream &stream, identifierType id, const std::string &content); - static void makeSimpleElement(std::ostream &stream, GenericFileElement::identifierType id, const char *data, std::size_t dataSize); + static void makeSimpleElement(std::ostream &stream, IdentifierType id, uint64 content); + static void makeSimpleElement(std::ostream &stream, IdentifierType id, const std::string &content); + static void makeSimpleElement(std::ostream &stream, IdentifierType id, const char *data, std::size_t dataSize); static uint64 bytesToBeSkipped; protected: diff --git a/matroska/matroskaattachment.cpp b/matroska/matroskaattachment.cpp index 87e3671..135751e 100644 --- a/matroska/matroskaattachment.cpp +++ b/matroska/matroskaattachment.cpp @@ -124,7 +124,7 @@ MatroskaAttachmentMaker::MatroskaAttachmentMaker(MatroskaAttachment &attachment) } if(attachment.attachedFileElement()) { EbmlElement *child; - for(auto id : initializer_list{MatroskaIds::FileReferral, MatroskaIds::FileUsedStartTime, MatroskaIds::FileUsedEndTime}) { + for(auto id : initializer_list{MatroskaIds::FileReferral, MatroskaIds::FileUsedStartTime, MatroskaIds::FileUsedEndTime}) { if((child = attachment.attachedFileElement()->childById(id))) { m_attachedFileElementSize += child->totalSize(); } @@ -156,7 +156,7 @@ void MatroskaAttachmentMaker::make(ostream &stream) const EbmlElement::makeSimpleElement(stream, MatroskaIds::FileUID, attachment().id()); if(attachment().attachedFileElement()) { EbmlElement *child; - for(auto id : initializer_list{MatroskaIds::FileReferral, MatroskaIds::FileUsedStartTime, MatroskaIds::FileUsedEndTime}) { + for(auto id : initializer_list{MatroskaIds::FileReferral, MatroskaIds::FileUsedStartTime, MatroskaIds::FileUsedEndTime}) { if((child = attachment().attachedFileElement()->childById(id))) { if(child->buffer()) { child->copyBuffer(stream); @@ -179,7 +179,7 @@ void MatroskaAttachmentMaker::bufferCurrentAttachments() { EbmlElement *child; if(attachment().attachedFileElement()) { - for(auto id : initializer_list{MatroskaIds::FileReferral, MatroskaIds::FileUsedStartTime, MatroskaIds::FileUsedEndTime}) { + for(auto id : initializer_list{MatroskaIds::FileReferral, MatroskaIds::FileUsedStartTime, MatroskaIds::FileUsedEndTime}) { if((child = attachment().attachedFileElement()->childById(id))) { child->makeBuffer(); } diff --git a/matroska/matroskacontainer.cpp b/matroska/matroskacontainer.cpp index 0fdff03..b22a45d 100644 --- a/matroska/matroskacontainer.cpp +++ b/matroska/matroskacontainer.cpp @@ -93,7 +93,7 @@ void MatroskaContainer::validateIndex() static const string context("validating Matroska file index (cues)"); bool cuesElementsFound = false; if(m_firstElement) { - unordered_set ids; + unordered_set ids; bool cueTimeFound = false, cueTrackPositionsFound = false; unique_ptr clusterElement; uint64 pos, prevClusterSize = 0, currentOffset = 0; diff --git a/matroska/matroskaseekinfo.cpp b/matroska/matroskaseekinfo.cpp index 0810fee..d7468f7 100644 --- a/matroska/matroskaseekinfo.cpp +++ b/matroska/matroskaseekinfo.cpp @@ -180,7 +180,7 @@ uint64 MatroskaSeekInfo::actualSize() const * * \returns Returns an indication whether the actualSize() has changed. */ -bool MatroskaSeekInfo::push(unsigned int index, EbmlElement::identifierType id, uint64 offset) +bool MatroskaSeekInfo::push(unsigned int index, EbmlElement::IdentifierType id, uint64 offset) { unsigned int currentIndex = 0; for(auto &entry : info()) { @@ -209,7 +209,7 @@ void MatroskaSeekInfo::clear() /*! * \brief Returns a pointer to the first pair with the specified \a offset or nullptr if no such pair could be found. */ -std::pair *MatroskaSeekInfo::findSeekInfo(std::vector &seekInfos, uint64 offset) +std::pair *MatroskaSeekInfo::findSeekInfo(std::vector &seekInfos, uint64 offset) { for(auto &seekInfo : seekInfos) { for(auto &entry : seekInfo.info()) { diff --git a/matroska/matroskaseekinfo.h b/matroska/matroskaseekinfo.h index 229443a..0031e2e 100644 --- a/matroska/matroskaseekinfo.h +++ b/matroska/matroskaseekinfo.h @@ -15,25 +15,25 @@ public: MatroskaSeekInfo(); EbmlElement *seekHeadElement() const; - const std::vector > &info() const; - std::vector > &info(); + const std::vector > &info() const; + std::vector > &info(); void shift(uint64 start, int64 amount); void parse(EbmlElement *seekHeadElement); void make(std::ostream &stream); uint64 minSize() const; uint64 maxSize() const; uint64 actualSize() const; - bool push(unsigned int index, EbmlElement::identifierType id, uint64 offset); + bool push(unsigned int index, EbmlElement::IdentifierType id, uint64 offset); void clear(); // these methods seem to be not needed anymore - static std::pair *findSeekInfo(std::vector &seekInfos, uint64 offset); + static std::pair *findSeekInfo(std::vector &seekInfos, uint64 offset); static bool updateSeekInfo(const std::vector &oldSeekInfos, std::vector &newSeekInfos, uint64 oldOffset, uint64 newOffset); static bool updateSeekInfo(std::vector &newSeekInfos, uint64 oldOffset, uint64 newOffset); private: EbmlElement *m_seekHeadElement; - std::vector > m_info; + std::vector > m_info; }; /*! @@ -55,7 +55,7 @@ inline EbmlElement *MatroskaSeekInfo::seekHeadElement() const * \brief Returns the seek information gathered when the parse() method was called. * \returns Returns the seek information as pairs of element IDs and the associated offsets (relative to the beginning of the file). */ -inline const std::vector > &MatroskaSeekInfo::info() const +inline const std::vector > &MatroskaSeekInfo::info() const { return m_info; } @@ -64,7 +64,7 @@ inline const std::vector > &Matro * \brief Returns a mutable version of the seek information gathered when the parse() method was called. * \returns Returns the seek information as pairs of element IDs and the associated offsets (relative to the beginning of the file). */ -inline std::vector > &MatroskaSeekInfo::info() +inline std::vector > &MatroskaSeekInfo::info() { return m_info; } diff --git a/matroska/matroskatag.cpp b/matroska/matroskatag.cpp index 68e10f1..afe1e72 100644 --- a/matroska/matroskatag.cpp +++ b/matroska/matroskatag.cpp @@ -15,7 +15,7 @@ namespace Media { * \brief Implementation of Media::Tag for the Matroska container. */ -MatroskaTag::identifierType MatroskaTag::internallyGetFieldId(KnownField field) const +MatroskaTag::IdentifierType MatroskaTag::internallyGetFieldId(KnownField field) const { using namespace MatroskaTagIds; switch(field) { @@ -45,7 +45,7 @@ MatroskaTag::identifierType MatroskaTag::internallyGetFieldId(KnownField field) } } -KnownField MatroskaTag::internallyGetKnownField(const identifierType &id) const +KnownField MatroskaTag::internallyGetKnownField(const IdentifierType &id) const { using namespace MatroskaTagIds; static const map map({ diff --git a/matroska/matroskatag.h b/matroska/matroskatag.h index 9d58e17..effd37c 100644 --- a/matroska/matroskatag.h +++ b/matroska/matroskatag.h @@ -54,9 +54,8 @@ template <> class TAG_PARSER_EXPORT FieldMapBasedTagTraits { public: - typedef MatroskaTag implementationType; - typedef MatroskaTagField fieldType; - typedef std::less compare; + typedef MatroskaTagField FieldType; + typedef std::less Compare; }; class TAG_PARSER_EXPORT MatroskaTag : public FieldMapBasedTag @@ -78,8 +77,8 @@ public: void make(std::ostream &stream); protected: - identifierType internallyGetFieldId(KnownField field) const; - KnownField internallyGetKnownField(const identifierType &id) const; + IdentifierType internallyGetFieldId(KnownField field) const; + KnownField internallyGetKnownField(const IdentifierType &id) const; private: void parseTargets(EbmlElement &targetsElement); diff --git a/matroska/matroskatagfield.h b/matroska/matroskatagfield.h index 5ceaf83..f74acda 100644 --- a/matroska/matroskatagfield.h +++ b/matroska/matroskatagfield.h @@ -16,21 +16,8 @@ template <> class TAG_PARSER_EXPORT TagFieldTraits { public: - /*! - * \brief Fields in a Matroska tag are identified by strings. - */ - typedef std::string identifierType; - - /*! - * \brief The type info is stored using strings. - */ - typedef std::string typeInfoType; - - /*! - * \brief The implementation type is EbmlElement. - */ - typedef MatroskaTagField implementationType; - + typedef std::string IdentifierType; + typedef std::string TypeInfoType; static bool supportsNestedFields(); }; diff --git a/mp4/mp4atom.cpp b/mp4/mp4atom.cpp index 91c285c..ca7dd71 100644 --- a/mp4/mp4atom.cpp +++ b/mp4/mp4atom.cpp @@ -27,21 +27,21 @@ namespace Media { /*! * \brief Constructs a new top level atom with the specified \a container at the specified \a startOffset. */ -Mp4Atom::Mp4Atom(GenericFileElement::containerType &container, uint64 startOffset) : +Mp4Atom::Mp4Atom(GenericFileElement::ContainerType &container, uint64 startOffset) : GenericFileElement(container, startOffset) {} /*! * \brief Constructs a new top level atom with the specified \a container at the specified \a startOffset. */ -Mp4Atom::Mp4Atom(GenericFileElement::containerType &container, uint64 startOffset, uint64 maxSize) : +Mp4Atom::Mp4Atom(GenericFileElement::ContainerType &container, uint64 startOffset, uint64 maxSize) : GenericFileElement(container, startOffset, maxSize) {} /*! * \brief Constructs a new sub level atom with the specified \a parent at the specified \a startOffset. */ -Mp4Atom::Mp4Atom(GenericFileElement::implementationType &parent, uint64 startOffset) : +Mp4Atom::Mp4Atom(Mp4Atom &parent, uint64 startOffset) : GenericFileElement(parent, startOffset) {} diff --git a/mp4/mp4atom.h b/mp4/mp4atom.h index 6d22a44..c2fdc6a 100644 --- a/mp4/mp4atom.h +++ b/mp4/mp4atom.h @@ -25,25 +25,9 @@ template <> class TAG_PARSER_EXPORT FileElementTraits { public: - /*! - * \brief The container type used to store such elements is Mp4Container. - */ - typedef Mp4Container containerType; - - /*! - * \brief The type used to store atom IDs is an unsigned 32-bit integer. - */ - typedef uint32 identifierType; - - /*! - * \brief The type used to store element sizes is an unsigned 64-bit integer. - */ - typedef uint64 dataSizeType; - - /*! - * \brief The implementation type is Mp4Atom. - */ - typedef Mp4Atom implementationType; + typedef Mp4Container ContainerType; + typedef uint32 IdentifierType; + typedef uint64 DataSizeType; /*! * \brief Returns the minimal atom size which is 8 byte. @@ -59,7 +43,7 @@ class TAG_PARSER_EXPORT Mp4Atom : public GenericFileElement friend class GenericFileElement; public: - Mp4Atom(containerType& container, uint64 startOffset); + Mp4Atom(ContainerType &container, uint64 startOffset); std::string idToString() const; bool isParent() const; @@ -72,8 +56,8 @@ public: static void makeHeader(uint64 size, uint32 id, IoUtilities::BinaryWriter &writer); protected: - Mp4Atom(containerType& container, uint64 startOffset, uint64 maxSize); - Mp4Atom(implementationType &parent, uint64 startOffset); + Mp4Atom(ContainerType &container, uint64 startOffset, uint64 maxSize); + Mp4Atom(Mp4Atom &parent, uint64 startOffset); void internalParse(); @@ -86,7 +70,7 @@ private: */ inline std::string Mp4Atom::idToString() const { - auto idString = ConversionUtilities::interpretIntegerAsString(id()); + auto idString = ConversionUtilities::interpretIntegerAsString(id()); for(char &c : idString) { if(c < ' ') { c = '?'; diff --git a/mp4/mp4tag.cpp b/mp4/mp4tag.cpp index 689bfb2..44cc458 100644 --- a/mp4/mp4tag.cpp +++ b/mp4/mp4tag.cpp @@ -119,7 +119,7 @@ const TagValue &Mp4Tag::value(const string mean, const string name) const return (this->*static_cast(&Mp4Tag::value))(mean, name); } -Mp4Tag::identifierType Mp4Tag::internallyGetFieldId(KnownField field) const +Mp4Tag::IdentifierType Mp4Tag::internallyGetFieldId(KnownField field) const { using namespace Mp4TagAtomIds; switch(field) { @@ -146,7 +146,7 @@ Mp4Tag::identifierType Mp4Tag::internallyGetFieldId(KnownField field) const } } -KnownField Mp4Tag::internallyGetKnownField(const identifierType &id) const +KnownField Mp4Tag::internallyGetKnownField(const IdentifierType &id) const { using namespace Mp4TagAtomIds; switch(id) { @@ -244,7 +244,7 @@ bool Mp4Tag::setValue(const char *mean, const char *name, const TagValue &value) return true; } } - fields().insert(make_pair(Mp4TagAtomIds::Extended, fieldType(mean, name, value))); + fields().insert(make_pair(Mp4TagAtomIds::Extended, FieldType(mean, name, value))); return true; } @@ -320,7 +320,7 @@ void Mp4Tag::parse(Mp4Atom &metaAtom) child->parse(); tagField.invalidateNotifications(); tagField.reparse(*child); - fields().insert(pair(child->id(), tagField)); + fields().emplace(child->id(), tagField); } catch(const Failure &) { } addNotifications(context, *child); diff --git a/mp4/mp4tag.h b/mp4/mp4tag.h index 0208318..3213a60 100644 --- a/mp4/mp4tag.h +++ b/mp4/mp4tag.h @@ -94,9 +94,8 @@ template <> class TAG_PARSER_EXPORT FieldMapBasedTagTraits { public: - typedef Mp4Tag implementationType; - typedef Mp4TagField fieldType; - typedef std::less compare; + typedef Mp4TagField FieldType; + typedef std::less Compare; }; class TAG_PARSER_EXPORT Mp4Tag : public FieldMapBasedTag @@ -138,8 +137,8 @@ public: void make(std::ostream &stream); protected: - identifierType internallyGetFieldId(KnownField field) const; - KnownField internallyGetKnownField(const identifierType &id) const; + IdentifierType internallyGetFieldId(KnownField field) const; + KnownField internallyGetKnownField(const IdentifierType &id) const; }; diff --git a/mp4/mp4tagfield.cpp b/mp4/mp4tagfield.cpp index 46a1d46..44ebf75 100644 --- a/mp4/mp4tagfield.cpp +++ b/mp4/mp4tagfield.cpp @@ -36,7 +36,7 @@ Mp4TagField::Mp4TagField() : /*! * \brief Constructs a new Mp4TagField with the specified \a id and \a value. */ -Mp4TagField::Mp4TagField(identifierType id, const TagValue &value) : +Mp4TagField::Mp4TagField(IdentifierType id, const TagValue &value) : TagField(id, value), m_parsedRawDataType(RawDataType::Reserved), m_countryIndicator(0), diff --git a/mp4/mp4tagfield.h b/mp4/mp4tagfield.h index 63a0f90..fc82cbf 100644 --- a/mp4/mp4tagfield.h +++ b/mp4/mp4tagfield.h @@ -57,20 +57,8 @@ template <> class TAG_PARSER_EXPORT TagFieldTraits { public: - /*! - * \brief Fields in a iTunes-style MP4 tag are identified by 32-bit unsigned integers. - */ - typedef uint32 identifierType; - - /*! - * \brief The type info is stored using 32-bit unsigned integers. - */ - typedef uint32 typeInfoType; - - /*! - * \brief The implementation type is Mp4TagField. - */ - typedef Mp4TagField implementationType; + typedef uint32 IdentifierType; + typedef uint32 TypeInfoType; }; class Mp4Atom; @@ -117,7 +105,7 @@ class TAG_PARSER_EXPORT Mp4TagField : public TagField, public Statu public: Mp4TagField(); - Mp4TagField(identifierType id, const TagValue &value); + Mp4TagField(IdentifierType id, const TagValue &value); Mp4TagField(const std::string &mean, const std::string &name, const TagValue &value); void reparse(Mp4Atom &ilstChild); @@ -136,8 +124,8 @@ public: std::vector expectedRawDataTypes() const; uint32 appropriateRawDataType() const; - static identifierType fieldIdFromString(const char *idString, std::size_t idStringSize = std::string::npos); - static std::string fieldIdToString(identifierType id); + static IdentifierType fieldIdFromString(const char *idString, std::size_t idStringSize = std::string::npos); + static std::string fieldIdToString(IdentifierType id); protected: void cleared(); @@ -227,7 +215,7 @@ inline bool Mp4TagField::supportsNestedFields() const * \remarks The specified \a idString is assumed to be UTF-8 encoded. In order to get the ©-sign * correctly, it is converted to Latin-1. */ -inline Mp4TagField::identifierType Mp4TagField::fieldIdFromString(const char *idString, std::size_t idStringSize) +inline Mp4TagField::IdentifierType Mp4TagField::fieldIdFromString(const char *idString, std::size_t idStringSize) { const auto latin1 = ConversionUtilities::convertUtf8ToLatin1(idString, idStringSize != std::string::npos ? idStringSize : std::strlen(idString)); switch(latin1.second) { @@ -243,7 +231,7 @@ inline Mp4TagField::identifierType Mp4TagField::fieldIdFromString(const char *id * \remarks The specified \a id is considered Latin-1 encoded. In order to get the ©-sign * correctly, it is converted to UTF-8. */ -inline std::string Mp4TagField::fieldIdToString(Mp4TagField::identifierType id) +inline std::string Mp4TagField::fieldIdToString(Mp4TagField::IdentifierType id) { const auto utf8 = ConversionUtilities::convertLatin1ToUtf8(ConversionUtilities::interpretIntegerAsString(id).data(), 4); return std::string(utf8.first.get(), utf8.second); diff --git a/mp4/mpeg4descriptor.cpp b/mp4/mpeg4descriptor.cpp index ee4e16d..860690a 100644 --- a/mp4/mpeg4descriptor.cpp +++ b/mp4/mpeg4descriptor.cpp @@ -20,14 +20,14 @@ namespace Media { * \brief Constructs a new top level descriptor with the specified \a container at the specified \a startOffset * and with the specified \a maxSize. */ -Mpeg4Descriptor::Mpeg4Descriptor(containerType &container, uint64 startOffset, uint64 maxSize) : +Mpeg4Descriptor::Mpeg4Descriptor(ContainerType &container, uint64 startOffset, uint64 maxSize) : GenericFileElement(container, startOffset, maxSize) {} /*! * \brief Constructs a new sub level descriptor with the specified \a parent at the specified \a startOffset. */ -Mpeg4Descriptor::Mpeg4Descriptor(implementationType &parent, uint64 startOffset) : +Mpeg4Descriptor::Mpeg4Descriptor(Mpeg4Descriptor &parent, uint64 startOffset) : GenericFileElement(parent, startOffset) {} @@ -75,12 +75,12 @@ void Mpeg4Descriptor::internalParse() m_dataSize = maxTotalSize(); // using max size instead } m_firstChild.reset(); - implementationType *sibling = nullptr; + Mpeg4Descriptor *sibling = nullptr; if(totalSize() < maxTotalSize()) { if(parent()) { - sibling = new implementationType(*(parent()), startOffset() + totalSize()); + sibling = new Mpeg4Descriptor(*(parent()), startOffset() + totalSize()); } else { - sibling = new implementationType(container(), startOffset() + totalSize(), maxTotalSize() - totalSize()); + sibling = new Mpeg4Descriptor(container(), startOffset() + totalSize(), maxTotalSize() - totalSize()); } } m_nextSibling.reset(sibling); diff --git a/mp4/mpeg4descriptor.h b/mp4/mpeg4descriptor.h index 68f1c7b..bc2be07 100644 --- a/mp4/mpeg4descriptor.h +++ b/mp4/mpeg4descriptor.h @@ -17,25 +17,9 @@ template <> class TAG_PARSER_EXPORT FileElementTraits { public: - /*! - * \brief The container type used to store such elements is Mp4Container. - */ - typedef Mp4Container containerType; - - /*! - * \brief The type used to store atom IDs is an unsigned 32-bit integer. - */ - typedef byte identifierType; - - /*! - * \brief The type used to store element sizes is an unsigned 32-bit integer. - */ - typedef uint32 dataSizeType; - - /*! - * \brief The implementation type is Mp4Atom. - */ - typedef Mpeg4Descriptor implementationType; + typedef Mp4Container ContainerType; + typedef byte IdentifierType; + typedef uint32 DataSizeType; /*! * \brief Returns the minimal descriptor size which is 2 byte. @@ -51,7 +35,7 @@ class TAG_PARSER_EXPORT Mpeg4Descriptor : public GenericFileElement; public: - Mpeg4Descriptor(containerType& container, uint64 startOffset, uint64 maxSize); + Mpeg4Descriptor(ContainerType &container, uint64 startOffset, uint64 maxSize); std::string idToString() const; bool isParent() const; @@ -59,7 +43,7 @@ public: uint64 firstChildOffset() const; protected: - Mpeg4Descriptor(implementationType &parent, uint64 startOffset); + Mpeg4Descriptor(Mpeg4Descriptor &parent, uint64 startOffset); void internalParse(); diff --git a/vorbis/vorbiscomment.cpp b/vorbis/vorbiscomment.cpp index e493e04..9a271b1 100644 --- a/vorbis/vorbiscomment.cpp +++ b/vorbis/vorbiscomment.cpp @@ -44,7 +44,7 @@ bool VorbisComment::setValue(KnownField field, const TagValue &value) } } -VorbisComment::identifierType VorbisComment::internallyGetFieldId(KnownField field) const +VorbisComment::IdentifierType VorbisComment::internallyGetFieldId(KnownField field) const { using namespace VorbisCommentIds; switch(field) { @@ -70,7 +70,7 @@ VorbisComment::identifierType VorbisComment::internallyGetFieldId(KnownField fie } } -KnownField VorbisComment::internallyGetKnownField(const identifierType &id) const +KnownField VorbisComment::internallyGetKnownField(const IdentifierType &id) const { using namespace VorbisCommentIds; static const map fieldMap({ @@ -145,7 +145,7 @@ void VorbisComment::internalParse(StreamType &stream, uint64 maxSize, VorbisComm // read fields try { field.parse(stream, maxSize); - fields().insert(pair(fieldId, field)); + fields().emplace(fieldId, field); } catch(const TruncatedDataException &) { addNotifications(field); throw; diff --git a/vorbis/vorbiscomment.h b/vorbis/vorbiscomment.h index 388901d..b8f95f6 100644 --- a/vorbis/vorbiscomment.h +++ b/vorbis/vorbiscomment.h @@ -19,9 +19,8 @@ template <> class TAG_PARSER_EXPORT FieldMapBasedTagTraits { public: - typedef VorbisComment implementationType; - typedef VorbisCommentField fieldType; - typedef CaseInsensitiveStringComparer compare; + typedef VorbisCommentField FieldType; + typedef CaseInsensitiveStringComparer Compare; }; class TAG_PARSER_EXPORT VorbisComment : public FieldMapBasedTag @@ -49,8 +48,8 @@ public: void setVendor(const TagValue &vendor); protected: - identifierType internallyGetFieldId(KnownField field) const; - KnownField internallyGetKnownField(const identifierType &id) const; + IdentifierType internallyGetFieldId(KnownField field) const; + KnownField internallyGetKnownField(const IdentifierType &id) const; private: template diff --git a/vorbis/vorbiscommentfield.cpp b/vorbis/vorbiscommentfield.cpp index 0f2181f..098c3f4 100644 --- a/vorbis/vorbiscommentfield.cpp +++ b/vorbis/vorbiscommentfield.cpp @@ -38,7 +38,7 @@ VorbisCommentField::VorbisCommentField() /*! * \brief Constructs a new Vorbis comment with the specified \a id and \a value. */ -VorbisCommentField::VorbisCommentField(const identifierType &id, const TagValue &value) : +VorbisCommentField::VorbisCommentField(const IdentifierType &id, const TagValue &value) : TagField(id, value) {} diff --git a/vorbis/vorbiscommentfield.h b/vorbis/vorbiscommentfield.h index 113351a..c3b4e91 100644 --- a/vorbis/vorbiscommentfield.h +++ b/vorbis/vorbiscommentfield.h @@ -41,18 +41,8 @@ template <> class TAG_PARSER_EXPORT TagFieldTraits { public: - /*! - * \brief Fields in a Vorbis comment are identified by 32-bit unsigned integers. - */ - typedef std::string identifierType; - /*! - * \brief The type info is stored using 32-bit unsigned integers. - */ - typedef uint32 typeInfoType; - /*! - * \brief The implementation type is VorbisCommentField. - */ - typedef VorbisCommentField implementationType; + typedef std::string IdentifierType; + typedef uint32 TypeInfoType; }; class OggIterator; @@ -63,7 +53,7 @@ class TAG_PARSER_EXPORT VorbisCommentField : public TagField public: VorbisCommentField(); - VorbisCommentField(const identifierType &id, const TagValue &value); + VorbisCommentField(const IdentifierType &id, const TagValue &value); void parse(OggIterator &iterator); void parse(OggIterator &iterator, uint64 &maxSize);