Uniform/simplify typedefs in templates
* Begin type names with capital letter * Remove typedefs for implementation type * Remove useless/obsolete comments * Simplify relevant code
This commit is contained in:
parent
86d51f1e96
commit
0f12cf346c
|
@ -35,49 +35,48 @@ class FieldMapBasedTag : public Tag
|
|||
friend class FieldMapBasedTagTraits<ImplementationType>;
|
||||
|
||||
public:
|
||||
typedef typename FieldMapBasedTagTraits<ImplementationType>::implementationType implementationType;
|
||||
typedef typename FieldMapBasedTagTraits<ImplementationType>::fieldType fieldType;
|
||||
typedef typename FieldMapBasedTagTraits<ImplementationType>::fieldType::identifierType identifierType;
|
||||
typedef typename FieldMapBasedTagTraits<ImplementationType>::compare compare;
|
||||
typedef typename FieldMapBasedTagTraits<ImplementationType>::FieldType FieldType;
|
||||
typedef typename FieldMapBasedTagTraits<ImplementationType>::FieldType::IdentifierType IdentifierType;
|
||||
typedef typename FieldMapBasedTagTraits<ImplementationType>::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<const TagValue *> values(const identifierType &id) const;
|
||||
std::vector<const TagValue *> values(const IdentifierType &id) const;
|
||||
std::vector<const TagValue *> 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<TagValue> &values);
|
||||
bool setValues(const IdentifierType &id, const std::vector<TagValue> &values);
|
||||
bool setValues(KnownField field, const std::vector<TagValue> &values);
|
||||
bool hasField(KnownField field) const;
|
||||
bool hasField(const identifierType &id) const;
|
||||
bool hasField(const IdentifierType &id) const;
|
||||
void removeAllFields();
|
||||
const std::multimap<identifierType, fieldType, compare> &fields() const;
|
||||
std::multimap<identifierType, fieldType, compare> &fields();
|
||||
const std::multimap<IdentifierType, FieldType, Compare> &fields() const;
|
||||
std::multimap<IdentifierType, FieldType, Compare> &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<ImplementationType> &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<identifierType, fieldType, compare> m_fields;
|
||||
std::multimap<IdentifierType, FieldType, Compare> m_fields;
|
||||
};
|
||||
|
||||
/*!
|
||||
|
@ -124,7 +123,7 @@ TagTextEncoding FieldMapBasedTag<ImplementationType>::proposedTextEncoding() con
|
|||
* \remarks Shadow in subclass to provide custom implementation.
|
||||
*/
|
||||
template<class ImplementationType>
|
||||
const TagValue &FieldMapBasedTag<ImplementationType>::internallyGetValue(const identifierType &id) const
|
||||
const TagValue &FieldMapBasedTag<ImplementationType>::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<ImplementationType>::internallyGetValue(const i
|
|||
* \sa Tag::value()
|
||||
*/
|
||||
template <class ImplementationType>
|
||||
inline const TagValue &FieldMapBasedTag<ImplementationType>::value(const identifierType &id) const
|
||||
inline const TagValue &FieldMapBasedTag<ImplementationType>::value(const IdentifierType &id) const
|
||||
{
|
||||
return static_cast<const ImplementationType *>(this)->internallyGetValue(id);
|
||||
}
|
||||
|
@ -151,7 +150,7 @@ inline const TagValue &FieldMapBasedTag<ImplementationType>::value(KnownField fi
|
|||
* \sa Tag::values()
|
||||
*/
|
||||
template <class ImplementationType>
|
||||
inline std::vector<const TagValue *> FieldMapBasedTag<ImplementationType>::values(const identifierType &id) const
|
||||
inline std::vector<const TagValue *> FieldMapBasedTag<ImplementationType>::values(const IdentifierType &id) const
|
||||
{
|
||||
auto range = m_fields.equal_range(id);
|
||||
std::vector<const TagValue *> values;
|
||||
|
@ -180,13 +179,13 @@ inline bool FieldMapBasedTag<ImplementationType>::setValue(KnownField field, con
|
|||
* \remarks Shadow in subclass to provide custom implementation.
|
||||
*/
|
||||
template<class ImplementationType>
|
||||
bool FieldMapBasedTag<ImplementationType>::internallySetValue(const identifierType &id, const TagValue &value)
|
||||
bool FieldMapBasedTag<ImplementationType>::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<ImplementationType>::internallySetValue(const identifierTy
|
|||
* \sa Tag::setValue()
|
||||
*/
|
||||
template <class ImplementationType>
|
||||
bool FieldMapBasedTag<ImplementationType>::setValue(const identifierType &id, const Media::TagValue &value)
|
||||
bool FieldMapBasedTag<ImplementationType>::setValue(const IdentifierType &id, const Media::TagValue &value)
|
||||
{
|
||||
return static_cast<ImplementationType *>(this)->internallySetValue(id, value);
|
||||
}
|
||||
|
@ -210,7 +209,7 @@ bool FieldMapBasedTag<ImplementationType>::setValue(const identifierType &id, co
|
|||
* \sa Tag::setValues()
|
||||
*/
|
||||
template <class ImplementationType>
|
||||
bool FieldMapBasedTag<ImplementationType>::setValues(const identifierType &id, const std::vector<TagValue> &values)
|
||||
bool FieldMapBasedTag<ImplementationType>::setValues(const IdentifierType &id, const std::vector<TagValue> &values)
|
||||
{
|
||||
auto valuesIterator = values.cbegin();
|
||||
auto range = m_fields.equal_range(id);
|
||||
|
@ -224,7 +223,7 @@ bool FieldMapBasedTag<ImplementationType>::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<ImplementationType>::hasField(KnownField field) con
|
|||
* \remarks Shadow in subclass to provide custom implementation.
|
||||
*/
|
||||
template<class ImplementationType>
|
||||
bool FieldMapBasedTag<ImplementationType>::internallyHasField(const identifierType &id) const
|
||||
bool FieldMapBasedTag<ImplementationType>::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<ImplementationType>::internallyHasField(const identifierTy
|
|||
* \brief Returns an indication whether the field with the specified \a id is present.
|
||||
*/
|
||||
template <class ImplementationType>
|
||||
inline bool FieldMapBasedTag<ImplementationType>::hasField(const identifierType &id) const
|
||||
inline bool FieldMapBasedTag<ImplementationType>::hasField(const IdentifierType &id) const
|
||||
{
|
||||
return static_cast<const ImplementationType *>(this)->internallyHasField(id);
|
||||
}
|
||||
|
@ -285,7 +284,7 @@ inline void FieldMapBasedTag<ImplementationType>::removeAllFields()
|
|||
* \brief Returns the fields of the tag by providing direct access to the field map of the tag.
|
||||
*/
|
||||
template <class ImplementationType>
|
||||
inline auto FieldMapBasedTag<ImplementationType>::fields() const -> const std::multimap<identifierType, fieldType, compare> &
|
||||
inline auto FieldMapBasedTag<ImplementationType>::fields() const -> const std::multimap<IdentifierType, FieldType, Compare> &
|
||||
{
|
||||
return m_fields;
|
||||
}
|
||||
|
@ -294,7 +293,7 @@ inline auto FieldMapBasedTag<ImplementationType>::fields() const -> const std::m
|
|||
* \brief Returns the fields of the tag by providing direct access to the field map of the tag.
|
||||
*/
|
||||
template <class ImplementationType>
|
||||
inline auto FieldMapBasedTag<ImplementationType>::fields() -> std::multimap<identifierType, fieldType, compare> &
|
||||
inline auto FieldMapBasedTag<ImplementationType>::fields() -> std::multimap<IdentifierType, FieldType, Compare> &
|
||||
{
|
||||
return m_fields;
|
||||
}
|
||||
|
@ -316,7 +315,7 @@ unsigned int FieldMapBasedTag<ImplementationType>::fieldCount() const
|
|||
* \remarks Must be implemented in internallyGetFieldId() when creating subclass.
|
||||
*/
|
||||
template<class ImplementationType>
|
||||
inline typename FieldMapBasedTag<ImplementationType>::identifierType FieldMapBasedTag<ImplementationType>::fieldId(KnownField value) const
|
||||
inline typename FieldMapBasedTag<ImplementationType>::IdentifierType FieldMapBasedTag<ImplementationType>::fieldId(KnownField value) const
|
||||
{
|
||||
return static_cast<const ImplementationType *>(this)->internallyGetFieldId(value);
|
||||
}
|
||||
|
@ -326,7 +325,7 @@ inline typename FieldMapBasedTag<ImplementationType>::identifierType FieldMapBas
|
|||
* \remarks Must be implemented in internallyGetKnownField() when creating subclass.
|
||||
*/
|
||||
template<class ImplementationType>
|
||||
inline KnownField FieldMapBasedTag<ImplementationType>::knownField(const identifierType &id) const
|
||||
inline KnownField FieldMapBasedTag<ImplementationType>::knownField(const IdentifierType &id) const
|
||||
{
|
||||
return static_cast<FieldMapBasedTag<ImplementationType> *>(this)->internallyGetKnownField(id);
|
||||
}
|
||||
|
@ -334,7 +333,7 @@ inline KnownField FieldMapBasedTag<ImplementationType>::knownField(const identif
|
|||
template <class ImplementationType>
|
||||
inline bool FieldMapBasedTag<ImplementationType>::supportsField(KnownField field) const
|
||||
{
|
||||
static identifierType def;
|
||||
static IdentifierType def;
|
||||
return fieldId(field) != def;
|
||||
}
|
||||
|
||||
|
@ -343,7 +342,7 @@ inline bool FieldMapBasedTag<ImplementationType>::supportsField(KnownField field
|
|||
* \remarks Shadow in subclass to provide custom implementation.
|
||||
*/
|
||||
template<class ImplementationType>
|
||||
inline TagDataType FieldMapBasedTag<ImplementationType>::internallyGetProposedDataType(const identifierType &id) const
|
||||
inline TagDataType FieldMapBasedTag<ImplementationType>::internallyGetProposedDataType(const IdentifierType &id) const
|
||||
{
|
||||
return Tag::proposedDataType(knownField(id));
|
||||
}
|
||||
|
@ -352,7 +351,7 @@ inline TagDataType FieldMapBasedTag<ImplementationType>::internallyGetProposedDa
|
|||
* \brief Returns the proposed data type for the field with the specified \a id.
|
||||
*/
|
||||
template <class ImplementationType>
|
||||
inline TagDataType FieldMapBasedTag<ImplementationType>::proposedDataType(const identifierType &id) const
|
||||
inline TagDataType FieldMapBasedTag<ImplementationType>::proposedDataType(const IdentifierType &id) const
|
||||
{
|
||||
return static_cast<ImplementationType *>(this)->determineProposedDataType(id);
|
||||
}
|
||||
|
@ -368,13 +367,13 @@ int FieldMapBasedTag<ImplementationType>::insertFields(const FieldMapBasedTag<Im
|
|||
{
|
||||
int fieldsInserted = 0;
|
||||
for(const auto &pair : from.fields()) {
|
||||
const fieldType &fromField = pair.second;
|
||||
const FieldType &fromField = pair.second;
|
||||
if(fromField.value().isEmpty())
|
||||
continue;
|
||||
bool fieldInserted = false;
|
||||
auto range = fields().equal_range(fromField.id());
|
||||
for(auto i = range.first; i != range.second; ++i) {
|
||||
fieldType &ownField = i->second;
|
||||
FieldType &ownField = i->second;
|
||||
if((fromField.isTypeInfoAssigned() && ownField.isTypeInfoAssigned()
|
||||
&& fromField.typeInfo() == ownField.typeInfo())
|
||||
|| (!fromField.isTypeInfoAssigned() && ! ownField.isTypeInfoAssigned())) {
|
||||
|
|
|
@ -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<ElementType> m_firstElement;
|
||||
|
|
|
@ -121,61 +121,56 @@ public:
|
|||
/*!
|
||||
* \brief Specifies the type of the corresponding container.
|
||||
*/
|
||||
typedef typename FileElementTraits<ImplementationType>::containerType containerType;
|
||||
typedef typename FileElementTraits<ImplementationType>::ContainerType ContainerType;
|
||||
|
||||
/*!
|
||||
* \brief Specifies the type used to store identifiers.
|
||||
*/
|
||||
typedef typename FileElementTraits<ImplementationType>::identifierType identifierType;
|
||||
typedef typename FileElementTraits<ImplementationType>::IdentifierType IdentifierType;
|
||||
|
||||
/*!
|
||||
* \brief Specifies the type used to store data sizes.
|
||||
*/
|
||||
typedef typename FileElementTraits<ImplementationType>::dataSizeType dataSizeType;
|
||||
typedef typename FileElementTraits<ImplementationType>::DataSizeType DataSizeType;
|
||||
|
||||
/*!
|
||||
* \brief Specifies the type of the actual implementation.
|
||||
*/
|
||||
typedef typename FileElementTraits<ImplementationType>::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<identifierType> &path);
|
||||
implementationType* subelementByPath(std::list<identifierType> &path);
|
||||
implementationType* childById(const identifierType &id);
|
||||
implementationType* siblingById(const identifierType &id, bool includeThis = false);
|
||||
FileElementIterator<implementationType> begin();
|
||||
FileElementIterator<implementationType> end();
|
||||
const FileElementIterator<implementationType> begin() const;
|
||||
const FileElementIterator<implementationType> 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<IdentifierType> &path);
|
||||
ImplementationType* subelementByPath(std::list<IdentifierType> &path);
|
||||
ImplementationType* childById(const IdentifierType &id);
|
||||
ImplementationType* siblingById(const IdentifierType &id, bool includeThis = false);
|
||||
FileElementIterator<ImplementationType> begin();
|
||||
FileElementIterator<ImplementationType> end();
|
||||
const FileElementIterator<ImplementationType> begin() const;
|
||||
const FileElementIterator<ImplementationType> 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<char[]> &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<implementationType> m_nextSibling;
|
||||
std::unique_ptr<implementationType> m_firstChild;
|
||||
ImplementationType* m_parent;
|
||||
std::unique_ptr<ImplementationType> m_nextSibling;
|
||||
std::unique_ptr<ImplementationType> m_firstChild;
|
||||
std::unique_ptr<char[]> 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 <class ImplementationType>
|
||||
GenericFileElement<ImplementationType>::GenericFileElement(GenericFileElement<ImplementationType>::containerType &container, uint64 startOffset) :
|
||||
m_id(identifierType()),
|
||||
GenericFileElement<ImplementationType>::GenericFileElement(GenericFileElement<ImplementationType>::ContainerType &container, uint64 startOffset) :
|
||||
m_id(IdentifierType()),
|
||||
m_startOffset(startOffset),
|
||||
m_idLength(0),
|
||||
m_dataSize(0),
|
||||
|
@ -244,8 +239,8 @@ GenericFileElement<ImplementationType>::GenericFileElement(GenericFileElement<Im
|
|||
* \brief Constructs a new sub level file element with the specified \a parent at the specified \a startOffset.
|
||||
*/
|
||||
template <class ImplementationType>
|
||||
GenericFileElement<ImplementationType>::GenericFileElement(GenericFileElement<ImplementationType>::implementationType &parent, uint64 startOffset) :
|
||||
m_id(identifierType()),
|
||||
GenericFileElement<ImplementationType>::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<ImplementationType>::GenericFileElement(GenericFileElement<Im
|
|||
* \brief Constructs a new sub level file element with the specified \a container, \a startOffset and \a maxSize.
|
||||
*/
|
||||
template <class ImplementationType>
|
||||
GenericFileElement<ImplementationType>::GenericFileElement(GenericFileElement<ImplementationType>::containerType &container, uint64 startOffset, uint64 maxSize) :
|
||||
m_id(identifierType()),
|
||||
GenericFileElement<ImplementationType>::GenericFileElement(GenericFileElement<ImplementationType>::ContainerType &container, uint64 startOffset, uint64 maxSize) :
|
||||
m_id(IdentifierType()),
|
||||
m_startOffset(startOffset),
|
||||
m_maxSize(maxSize),
|
||||
m_idLength(0),
|
||||
|
@ -276,7 +271,7 @@ GenericFileElement<ImplementationType>::GenericFileElement(GenericFileElement<Im
|
|||
* \brief Returns the related container.
|
||||
*/
|
||||
template <class ImplementationType>
|
||||
inline typename GenericFileElement<ImplementationType>::containerType& GenericFileElement<ImplementationType>::container()
|
||||
inline typename GenericFileElement<ImplementationType>::ContainerType& GenericFileElement<ImplementationType>::container()
|
||||
{
|
||||
return *m_container;
|
||||
}
|
||||
|
@ -285,7 +280,7 @@ inline typename GenericFileElement<ImplementationType>::containerType& GenericFi
|
|||
* \brief Returns the related container.
|
||||
*/
|
||||
template <class ImplementationType>
|
||||
inline const typename GenericFileElement<ImplementationType>::containerType &GenericFileElement<ImplementationType>::container() const
|
||||
inline const typename GenericFileElement<ImplementationType>::ContainerType &GenericFileElement<ImplementationType>::container() const
|
||||
{
|
||||
return *m_container;
|
||||
}
|
||||
|
@ -339,7 +334,7 @@ inline uint64 GenericFileElement<ImplementationType>::relativeStartOffset() cons
|
|||
* \brief Returns the element ID.
|
||||
*/
|
||||
template <class ImplementationType>
|
||||
inline const typename GenericFileElement<ImplementationType>::identifierType &GenericFileElement<ImplementationType>::id() const
|
||||
inline const typename GenericFileElement<ImplementationType>::IdentifierType &GenericFileElement<ImplementationType>::id() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
@ -379,7 +374,7 @@ inline uint32 GenericFileElement<ImplementationType>::headerSize() const
|
|||
* This is the size of the element excluding the header.
|
||||
*/
|
||||
template <class ImplementationType>
|
||||
inline typename GenericFileElement<ImplementationType>::dataSizeType GenericFileElement<ImplementationType>::dataSize() const
|
||||
inline typename GenericFileElement<ImplementationType>::DataSizeType GenericFileElement<ImplementationType>::dataSize() const
|
||||
{
|
||||
return m_dataSize;
|
||||
}
|
||||
|
@ -443,7 +438,7 @@ inline uint64 GenericFileElement<ImplementationType>::maxTotalSize() const
|
|||
* If the current element is a top level element nullptr is returned.
|
||||
*/
|
||||
template <class ImplementationType>
|
||||
inline typename GenericFileElement<ImplementationType>::implementationType *GenericFileElement<ImplementationType>::parent()
|
||||
inline ImplementationType *GenericFileElement<ImplementationType>::parent()
|
||||
{
|
||||
return m_parent;
|
||||
}
|
||||
|
@ -455,7 +450,7 @@ inline typename GenericFileElement<ImplementationType>::implementationType *Gene
|
|||
* If the current element is a top level element nullptr is returned.
|
||||
*/
|
||||
template <class ImplementationType>
|
||||
inline const typename GenericFileElement<ImplementationType>::implementationType *GenericFileElement<ImplementationType>::parent() const
|
||||
inline const ImplementationType *GenericFileElement<ImplementationType>::parent() const
|
||||
{
|
||||
return m_parent;
|
||||
}
|
||||
|
@ -469,7 +464,7 @@ inline const typename GenericFileElement<ImplementationType>::implementationType
|
|||
* \remarks parse() needs to be called before.
|
||||
*/
|
||||
template <class ImplementationType>
|
||||
inline typename GenericFileElement<ImplementationType>::implementationType *GenericFileElement<ImplementationType>::nextSibling()
|
||||
inline ImplementationType *GenericFileElement<ImplementationType>::nextSibling()
|
||||
{
|
||||
return m_nextSibling.get();
|
||||
}
|
||||
|
@ -483,7 +478,7 @@ inline typename GenericFileElement<ImplementationType>::implementationType *Gene
|
|||
* \remarks parse() needs to be called before.
|
||||
*/
|
||||
template <class ImplementationType>
|
||||
inline const typename GenericFileElement<ImplementationType>::implementationType *GenericFileElement<ImplementationType>::nextSibling() const
|
||||
inline const ImplementationType *GenericFileElement<ImplementationType>::nextSibling() const
|
||||
{
|
||||
return m_nextSibling.get();
|
||||
}
|
||||
|
@ -497,7 +492,7 @@ inline const typename GenericFileElement<ImplementationType>::implementationType
|
|||
* \remarks parse() needs to be called before.
|
||||
*/
|
||||
template <class ImplementationType>
|
||||
inline typename GenericFileElement<ImplementationType>::implementationType *GenericFileElement<ImplementationType>::firstChild()
|
||||
inline ImplementationType *GenericFileElement<ImplementationType>::firstChild()
|
||||
{
|
||||
return m_firstChild.get();
|
||||
}
|
||||
|
@ -511,7 +506,7 @@ inline typename GenericFileElement<ImplementationType>::implementationType *Gene
|
|||
* \remarks parse() needs to be called before.
|
||||
*/
|
||||
template <class ImplementationType>
|
||||
inline const typename GenericFileElement<ImplementationType>::implementationType *GenericFileElement<ImplementationType>::firstChild() const
|
||||
inline const ImplementationType *GenericFileElement<ImplementationType>::firstChild() const
|
||||
{
|
||||
return m_firstChild.get();
|
||||
}
|
||||
|
@ -526,9 +521,9 @@ inline const typename GenericFileElement<ImplementationType>::implementationType
|
|||
* \throws Throws std::ios_base::failure when an IO error occurs.
|
||||
*/
|
||||
template <class ImplementationType>
|
||||
inline typename GenericFileElement<ImplementationType>::implementationType *GenericFileElement<ImplementationType>::subelementByPath(const std::initializer_list<identifierType> &path)
|
||||
inline ImplementationType *GenericFileElement<ImplementationType>::subelementByPath(const std::initializer_list<IdentifierType> &path)
|
||||
{
|
||||
std::list<GenericFileElement<ImplementationType>::identifierType> list(path);
|
||||
std::list<GenericFileElement<ImplementationType>::IdentifierType> list(path);
|
||||
return subelementByPath(list);
|
||||
}
|
||||
|
||||
|
@ -543,13 +538,13 @@ inline typename GenericFileElement<ImplementationType>::implementationType *Gene
|
|||
* \throws Throws std::ios_base::failure when an IO error occurs.
|
||||
*/
|
||||
template <class ImplementationType>
|
||||
typename GenericFileElement<ImplementationType>::implementationType *GenericFileElement<ImplementationType>::subelementByPath(std::list<GenericFileElement<ImplementationType>::identifierType> &path)
|
||||
ImplementationType *GenericFileElement<ImplementationType>::subelementByPath(std::list<IdentifierType> &path)
|
||||
{
|
||||
parse(); // ensure element is parsed
|
||||
if(path.size()) {
|
||||
if(path.front() == id()) {
|
||||
if(path.size() == 1) {
|
||||
return static_cast<implementationType*>(this);
|
||||
return static_cast<ImplementationType *>(this);
|
||||
} else {
|
||||
if(firstChild()) {
|
||||
path.pop_front();
|
||||
|
@ -575,10 +570,10 @@ typename GenericFileElement<ImplementationType>::implementationType *GenericFile
|
|||
* \throws Throws std::ios_base::failure when an IO error occurs.
|
||||
*/
|
||||
template <class ImplementationType>
|
||||
typename GenericFileElement<ImplementationType>::implementationType *GenericFileElement<ImplementationType>::childById(const GenericFileElement<ImplementationType>::identifierType &id)
|
||||
ImplementationType *GenericFileElement<ImplementationType>::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>::implementationType *GenericFile
|
|||
* \throws Throws std::ios_base::failure when an IO error occurs.
|
||||
*/
|
||||
template <class ImplementationType>
|
||||
typename GenericFileElement<ImplementationType>::implementationType *GenericFileElement<ImplementationType>::siblingById(const GenericFileElement<ImplementationType>::identifierType &id, bool includeThis)
|
||||
ImplementationType *GenericFileElement<ImplementationType>::siblingById(const IdentifierType &id, bool includeThis)
|
||||
{
|
||||
parse(); // ensure element is parsed
|
||||
for(implementationType *sibling = includeThis ? static_cast<implementationType*>(this) : nextSibling(); sibling; sibling = sibling->nextSibling()) {
|
||||
for(ImplementationType *sibling = includeThis ? static_cast<ImplementationType *>(this) : nextSibling(); sibling; sibling = sibling->nextSibling()) {
|
||||
sibling->parse();
|
||||
if(sibling->id() == id) {
|
||||
return sibling;
|
||||
|
@ -618,25 +613,25 @@ typename GenericFileElement<ImplementationType>::implementationType *GenericFile
|
|||
* \brief Returns an iterator for iterating over the element's childs.
|
||||
*/
|
||||
template <class ImplementationType>
|
||||
FileElementIterator<typename GenericFileElement<ImplementationType>::implementationType> GenericFileElement<ImplementationType>::begin()
|
||||
FileElementIterator<ImplementationType> GenericFileElement<ImplementationType>::begin()
|
||||
{
|
||||
return FileElementIterator<implementationType>(firstChild());
|
||||
return FileElementIterator<ImplementationType>(firstChild());
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Returns an iterator for iterating over the element's childs (constant).
|
||||
*/
|
||||
template <class ImplementationType>
|
||||
const FileElementIterator<typename GenericFileElement<ImplementationType>::implementationType> GenericFileElement<ImplementationType>::begin() const
|
||||
const FileElementIterator<ImplementationType> GenericFileElement<ImplementationType>::begin() const
|
||||
{
|
||||
return FileElementIterator<implementationType>(firstChild());
|
||||
return FileElementIterator<ImplementationType>(firstChild());
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Returns an invalid iterator.
|
||||
*/
|
||||
template <class ImplementationType>
|
||||
FileElementIterator<typename GenericFileElement<ImplementationType>::implementationType> GenericFileElement<ImplementationType>::end()
|
||||
FileElementIterator<ImplementationType> GenericFileElement<ImplementationType>::end()
|
||||
{
|
||||
return FileElementIterator<ImplementationType>();
|
||||
}
|
||||
|
@ -645,7 +640,7 @@ FileElementIterator<typename GenericFileElement<ImplementationType>::implementat
|
|||
* \brief Returns an invalid iterator.
|
||||
*/
|
||||
template <class ImplementationType>
|
||||
const FileElementIterator<typename GenericFileElement<ImplementationType>::implementationType> GenericFileElement<ImplementationType>::end() const
|
||||
const FileElementIterator<ImplementationType> GenericFileElement<ImplementationType>::end() const
|
||||
{
|
||||
return FileElementIterator<ImplementationType>();
|
||||
}
|
||||
|
@ -695,7 +690,7 @@ inline bool GenericFileElement<ImplementationType>::isParsed() const
|
|||
template <class ImplementationType>
|
||||
void GenericFileElement<ImplementationType>::clear()
|
||||
{
|
||||
m_id = identifierType();
|
||||
m_id = IdentifierType();
|
||||
//m_startOffset = 0;
|
||||
m_idLength = 0;
|
||||
m_dataSize = 0;
|
||||
|
@ -906,10 +901,10 @@ void GenericFileElement<ImplementationType>::copyInternal(std::ostream &targetSt
|
|||
* \remarks A new first child is constructed. A possibly existing subtree is invalidated.
|
||||
*/
|
||||
template <class ImplementationType>
|
||||
typename GenericFileElement<ImplementationType>::implementationType *GenericFileElement<ImplementationType>::denoteFirstChild(uint32 relativeFirstChildOffset)
|
||||
ImplementationType *GenericFileElement<ImplementationType>::denoteFirstChild(uint32 relativeFirstChildOffset)
|
||||
{
|
||||
if(relativeFirstChildOffset + minimumElementSize() <= totalSize()) {
|
||||
m_firstChild.reset(new implementationType(static_cast<implementationType &>(*this), startOffset() + relativeFirstChildOffset));
|
||||
m_firstChild.reset(new ImplementationType(static_cast<ImplementationType &>(*this), startOffset() + relativeFirstChildOffset));
|
||||
} else {
|
||||
m_firstChild.reset();
|
||||
}
|
||||
|
@ -922,7 +917,7 @@ typename GenericFileElement<ImplementationType>::implementationType *GenericFile
|
|||
template <class ImplementationType>
|
||||
constexpr uint32 GenericFileElement<ImplementationType>::maximumIdLengthSupported()
|
||||
{
|
||||
return sizeof(identifierType);
|
||||
return sizeof(IdentifierType);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -931,7 +926,7 @@ constexpr uint32 GenericFileElement<ImplementationType>::maximumIdLengthSupporte
|
|||
template <class ImplementationType>
|
||||
constexpr uint32 GenericFileElement<ImplementationType>::maximumSizeLengthSupported()
|
||||
{
|
||||
return sizeof(dataSizeType);
|
||||
return sizeof(DataSizeType);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
@ -32,19 +32,19 @@ class TagFieldTraits
|
|||
template <class ImplementationType>
|
||||
class TAG_PARSER_EXPORT TagField
|
||||
{
|
||||
public:
|
||||
friend class TagFieldTraits<ImplementationType>;
|
||||
typedef typename TagFieldTraits<ImplementationType>::implementationType implementationType;
|
||||
typedef typename TagFieldTraits<ImplementationType>::identifierType identifierType;
|
||||
typedef typename TagFieldTraits<ImplementationType>::typeInfoType typeInfoType;
|
||||
|
||||
public:
|
||||
typedef typename TagFieldTraits<ImplementationType>::IdentifierType IdentifierType;
|
||||
typedef typename TagFieldTraits<ImplementationType>::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<ImplementationType> m_nestedFields;
|
||||
|
@ -85,9 +85,9 @@ private:
|
|||
*/
|
||||
template <class ImplementationType>
|
||||
TagField<ImplementationType>::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<ImplementationType>::TagField() :
|
|||
* \brief Constructs a new TagField with the specified \a id and \a value.
|
||||
*/
|
||||
template <class ImplementationType>
|
||||
TagField<ImplementationType>::TagField(const identifierType &id, const TagValue &value) :
|
||||
TagField<ImplementationType>::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<ImplementationType>::~TagField()
|
|||
* \brief Returns the id of the current TagField.
|
||||
*/
|
||||
template <class ImplementationType>
|
||||
inline const typename TagField<ImplementationType>::identifierType &TagField<ImplementationType>::id() const
|
||||
inline const typename TagField<ImplementationType>::IdentifierType &TagField<ImplementationType>::id() const
|
||||
{
|
||||
return m_id;
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ inline std::string TagField<ImplementationType>::idToString() const
|
|||
* \brief Sets the id of the current Tag Field.
|
||||
*/
|
||||
template <class ImplementationType>
|
||||
inline void TagField<ImplementationType>::setId(const identifierType &id)
|
||||
inline void TagField<ImplementationType>::setId(const IdentifierType &id)
|
||||
{
|
||||
m_id = id;
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ inline void TagField<ImplementationType>::setId(const identifierType &id)
|
|||
template <class ImplementationType>
|
||||
inline void TagField<ImplementationType>::clearId()
|
||||
{
|
||||
m_id = identifierType();
|
||||
m_id = IdentifierType();
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -184,7 +184,7 @@ inline void TagField<ImplementationType>::clearValue()
|
|||
* \brief Returns the type info of the current TagField.
|
||||
*/
|
||||
template <class ImplementationType>
|
||||
inline const typename TagField<ImplementationType>::typeInfoType &TagField<ImplementationType>::typeInfo() const
|
||||
inline const typename TagField<ImplementationType>::TypeInfoType &TagField<ImplementationType>::typeInfo() const
|
||||
{
|
||||
return m_typeInfo;
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ inline const typename TagField<ImplementationType>::typeInfoType &TagField<Imple
|
|||
* \brief Sets the type info of the current TagField.
|
||||
*/
|
||||
template <class ImplementationType>
|
||||
inline void TagField<ImplementationType>::setTypeInfo(const typeInfoType &typeInfo)
|
||||
inline void TagField<ImplementationType>::setTypeInfo(const TypeInfoType &typeInfo)
|
||||
{
|
||||
m_typeInfo = typeInfo;
|
||||
m_typeInfoAssigned = true;
|
||||
|
@ -205,7 +205,7 @@ inline void TagField<ImplementationType>::setTypeInfo(const typeInfoType &typeIn
|
|||
template <class ImplementationType>
|
||||
inline void TagField<ImplementationType>::removeTypeInfo()
|
||||
{
|
||||
m_typeInfo = typeInfoType();
|
||||
m_typeInfo = TypeInfoType();
|
||||
m_typeInfoAssigned = false;
|
||||
}
|
||||
|
||||
|
@ -244,7 +244,7 @@ void TagField<ImplementationType>::clear()
|
|||
{
|
||||
clearId();
|
||||
clearValue();
|
||||
m_typeInfo = typeInfoType();
|
||||
m_typeInfo = TypeInfoType();
|
||||
m_typeInfoAssigned = false;
|
||||
m_default = true;
|
||||
static_cast<ImplementationType *>(this)->cleared();
|
||||
|
|
|
@ -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<Id3v2Frame>(id, value),
|
||||
m_flag(flag),
|
||||
m_group(group),
|
||||
|
|
|
@ -81,20 +81,8 @@ template <>
|
|||
class TAG_PARSER_EXPORT TagFieldTraits<Id3v2Frame>
|
||||
{
|
||||
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<Id3v2Frame>, public StatusProvider
|
||||
|
@ -103,7 +91,7 @@ class TAG_PARSER_EXPORT Id3v2Frame : public TagField<Id3v2Frame>, 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<char[]> &buffer, uint32 &bufferSize, const TagValue &comment, byte version);
|
||||
void makeComment(std::unique_ptr<char[]> &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<uint32>(id, Id3v2FrameIds::isLongId(id) ? 0 : 1);
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -59,9 +59,8 @@ template <>
|
|||
class TAG_PARSER_EXPORT FieldMapBasedTagTraits<Id3v2Tag>
|
||||
{
|
||||
public:
|
||||
typedef Id3v2Tag implementationType;
|
||||
typedef Id3v2Frame fieldType;
|
||||
typedef FrameComparer compare;
|
||||
typedef Id3v2Frame FieldType;
|
||||
typedef FrameComparer Compare;
|
||||
};
|
||||
|
||||
class TAG_PARSER_EXPORT Id3v2Tag : public FieldMapBasedTag<Id3v2Tag>
|
||||
|
@ -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:
|
||||
|
|
|
@ -81,11 +81,11 @@ void EbmlElement::internalParse()
|
|||
char buf[maximumIdLengthSupported() > maximumSizeLengthSupported() ? maximumIdLengthSupported() : maximumSizeLengthSupported()] = {0};
|
||||
byte beg = static_cast<byte>(stream().peek()), mask = 0x80;
|
||||
m_idLength = 1;
|
||||
while(m_idLength <= GenericFileElement<implementationType>::maximumIdLengthSupported() && (beg & mask) == 0) {
|
||||
while(m_idLength <= maximumIdLengthSupported() && (beg & mask) == 0) {
|
||||
++m_idLength;
|
||||
mask >>= 1;
|
||||
}
|
||||
if(m_idLength > GenericFileElement<implementationType>::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<implementationType>::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<implementationType>::maximumSizeLengthSupported() && (beg & mask) == 0) {
|
||||
while(m_sizeLength <= maximumSizeLengthSupported() && (beg & mask) == 0) {
|
||||
++m_sizeLength;
|
||||
mask >>= 1;
|
||||
}
|
||||
if(m_sizeLength > GenericFileElement<implementationType>::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<implementationType>::maximumSizeLengthSupported() - m_sizeLength), m_sizeLength);
|
||||
*(buf + (GenericFileElement<implementationType>::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<byte>(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);
|
||||
|
|
|
@ -26,25 +26,9 @@ template <>
|
|||
class TAG_PARSER_EXPORT FileElementTraits<EbmlElement>
|
||||
{
|
||||
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<EbmlElement>
|
||||
|
@ -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:
|
||||
|
|
|
@ -124,7 +124,7 @@ MatroskaAttachmentMaker::MatroskaAttachmentMaker(MatroskaAttachment &attachment)
|
|||
}
|
||||
if(attachment.attachedFileElement()) {
|
||||
EbmlElement *child;
|
||||
for(auto id : initializer_list<EbmlElement::identifierType>{MatroskaIds::FileReferral, MatroskaIds::FileUsedStartTime, MatroskaIds::FileUsedEndTime}) {
|
||||
for(auto id : initializer_list<EbmlElement::IdentifierType>{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<EbmlElement::identifierType>{MatroskaIds::FileReferral, MatroskaIds::FileUsedStartTime, MatroskaIds::FileUsedEndTime}) {
|
||||
for(auto id : initializer_list<EbmlElement::IdentifierType>{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<EbmlElement::identifierType>{MatroskaIds::FileReferral, MatroskaIds::FileUsedStartTime, MatroskaIds::FileUsedEndTime}) {
|
||||
for(auto id : initializer_list<EbmlElement::IdentifierType>{MatroskaIds::FileReferral, MatroskaIds::FileUsedStartTime, MatroskaIds::FileUsedEndTime}) {
|
||||
if((child = attachment().attachedFileElement()->childById(id))) {
|
||||
child->makeBuffer();
|
||||
}
|
||||
|
|
|
@ -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<EbmlElement::identifierType, uint64> *MatroskaSeekInfo::findSeekInfo(std::vector<MatroskaSeekInfo> &seekInfos, uint64 offset)
|
||||
std::pair<EbmlElement::IdentifierType, uint64> *MatroskaSeekInfo::findSeekInfo(std::vector<MatroskaSeekInfo> &seekInfos, uint64 offset)
|
||||
{
|
||||
for(auto &seekInfo : seekInfos) {
|
||||
for(auto &entry : seekInfo.info()) {
|
||||
|
|
|
@ -15,25 +15,25 @@ public:
|
|||
MatroskaSeekInfo();
|
||||
|
||||
EbmlElement *seekHeadElement() const;
|
||||
const std::vector<std::pair<EbmlElement::identifierType, uint64> > &info() const;
|
||||
std::vector<std::pair<EbmlElement::identifierType, uint64> > &info();
|
||||
const std::vector<std::pair<EbmlElement::IdentifierType, uint64> > &info() const;
|
||||
std::vector<std::pair<EbmlElement::IdentifierType, uint64> > &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<EbmlElement::identifierType, uint64> *findSeekInfo(std::vector<MatroskaSeekInfo> &seekInfos, uint64 offset);
|
||||
static std::pair<EbmlElement::IdentifierType, uint64> *findSeekInfo(std::vector<MatroskaSeekInfo> &seekInfos, uint64 offset);
|
||||
static bool updateSeekInfo(const std::vector<MatroskaSeekInfo> &oldSeekInfos, std::vector<MatroskaSeekInfo> &newSeekInfos, uint64 oldOffset, uint64 newOffset);
|
||||
static bool updateSeekInfo(std::vector<MatroskaSeekInfo> &newSeekInfos, uint64 oldOffset, uint64 newOffset);
|
||||
|
||||
private:
|
||||
EbmlElement *m_seekHeadElement;
|
||||
std::vector<std::pair<EbmlElement::identifierType, uint64> > m_info;
|
||||
std::vector<std::pair<EbmlElement::IdentifierType, uint64> > 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<std::pair<EbmlElement::identifierType, uint64> > &MatroskaSeekInfo::info() const
|
||||
inline const std::vector<std::pair<EbmlElement::IdentifierType, uint64> > &MatroskaSeekInfo::info() const
|
||||
{
|
||||
return m_info;
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ inline const std::vector<std::pair<EbmlElement::identifierType, uint64> > &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<std::pair<EbmlElement::identifierType, uint64> > &MatroskaSeekInfo::info()
|
||||
inline std::vector<std::pair<EbmlElement::IdentifierType, uint64> > &MatroskaSeekInfo::info()
|
||||
{
|
||||
return m_info;
|
||||
}
|
||||
|
|
|
@ -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<string, KnownField> map({
|
||||
|
|
|
@ -54,9 +54,8 @@ template <>
|
|||
class TAG_PARSER_EXPORT FieldMapBasedTagTraits<MatroskaTag>
|
||||
{
|
||||
public:
|
||||
typedef MatroskaTag implementationType;
|
||||
typedef MatroskaTagField fieldType;
|
||||
typedef std::less<typename fieldType::identifierType> compare;
|
||||
typedef MatroskaTagField FieldType;
|
||||
typedef std::less<typename FieldType::IdentifierType> Compare;
|
||||
};
|
||||
|
||||
class TAG_PARSER_EXPORT MatroskaTag : public FieldMapBasedTag<MatroskaTag>
|
||||
|
@ -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);
|
||||
|
|
|
@ -16,21 +16,8 @@ template <>
|
|||
class TAG_PARSER_EXPORT TagFieldTraits<MatroskaTagField>
|
||||
{
|
||||
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();
|
||||
};
|
||||
|
||||
|
|
|
@ -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<Mp4Atom>(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<Mp4Atom>(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<Mp4Atom>(parent, startOffset)
|
||||
{}
|
||||
|
||||
|
|
|
@ -25,25 +25,9 @@ template <>
|
|||
class TAG_PARSER_EXPORT FileElementTraits<Mp4Atom>
|
||||
{
|
||||
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<Mp4Atom>
|
|||
friend class GenericFileElement<Mp4Atom>;
|
||||
|
||||
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<identifierType>(id());
|
||||
auto idString = ConversionUtilities::interpretIntegerAsString<IdentifierType>(id());
|
||||
for(char &c : idString) {
|
||||
if(c < ' ') {
|
||||
c = '?';
|
||||
|
|
|
@ -119,7 +119,7 @@ const TagValue &Mp4Tag::value(const string mean, const string name) const
|
|||
return (this->*static_cast<const TagValue &(Mp4Tag::*)(const string &, const string &) const>(&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<fieldType::identifierType, fieldType>(child->id(), tagField));
|
||||
fields().emplace(child->id(), tagField);
|
||||
} catch(const Failure &) {
|
||||
}
|
||||
addNotifications(context, *child);
|
||||
|
|
|
@ -94,9 +94,8 @@ template <>
|
|||
class TAG_PARSER_EXPORT FieldMapBasedTagTraits<Mp4Tag>
|
||||
{
|
||||
public:
|
||||
typedef Mp4Tag implementationType;
|
||||
typedef Mp4TagField fieldType;
|
||||
typedef std::less<typename fieldType::identifierType> compare;
|
||||
typedef Mp4TagField FieldType;
|
||||
typedef std::less<typename FieldType::IdentifierType> Compare;
|
||||
};
|
||||
|
||||
class TAG_PARSER_EXPORT Mp4Tag : public FieldMapBasedTag<Mp4Tag>
|
||||
|
@ -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;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -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<Mp4TagField>(id, value),
|
||||
m_parsedRawDataType(RawDataType::Reserved),
|
||||
m_countryIndicator(0),
|
||||
|
|
|
@ -57,20 +57,8 @@ template <>
|
|||
class TAG_PARSER_EXPORT TagFieldTraits<Mp4TagField>
|
||||
{
|
||||
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<Mp4TagField>, 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<uint32> 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<uint32>(id).data(), 4);
|
||||
return std::string(utf8.first.get(), utf8.second);
|
||||
|
|
|
@ -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<Mpeg4Descriptor>(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<Mpeg4Descriptor>(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);
|
||||
|
|
|
@ -17,25 +17,9 @@ template <>
|
|||
class TAG_PARSER_EXPORT FileElementTraits<Mpeg4Descriptor>
|
||||
{
|
||||
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<Mpeg4Descrip
|
|||
friend class GenericFileElement<Mpeg4Descriptor>;
|
||||
|
||||
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();
|
||||
|
||||
|
|
|
@ -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<string, KnownField> fieldMap({
|
||||
|
@ -145,7 +145,7 @@ void VorbisComment::internalParse(StreamType &stream, uint64 maxSize, VorbisComm
|
|||
// read fields
|
||||
try {
|
||||
field.parse(stream, maxSize);
|
||||
fields().insert(pair<fieldType::identifierType, fieldType>(fieldId, field));
|
||||
fields().emplace(fieldId, field);
|
||||
} catch(const TruncatedDataException &) {
|
||||
addNotifications(field);
|
||||
throw;
|
||||
|
|
|
@ -19,9 +19,8 @@ template <>
|
|||
class TAG_PARSER_EXPORT FieldMapBasedTagTraits<VorbisComment>
|
||||
{
|
||||
public:
|
||||
typedef VorbisComment implementationType;
|
||||
typedef VorbisCommentField fieldType;
|
||||
typedef CaseInsensitiveStringComparer compare;
|
||||
typedef VorbisCommentField FieldType;
|
||||
typedef CaseInsensitiveStringComparer Compare;
|
||||
};
|
||||
|
||||
class TAG_PARSER_EXPORT VorbisComment : public FieldMapBasedTag<VorbisComment>
|
||||
|
@ -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<class StreamType>
|
||||
|
|
|
@ -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<VorbisCommentField>(id, value)
|
||||
{}
|
||||
|
||||
|
|
|
@ -41,18 +41,8 @@ template <>
|
|||
class TAG_PARSER_EXPORT TagFieldTraits<VorbisCommentField>
|
||||
{
|
||||
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<VorbisCommentField>
|
|||
|
||||
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);
|
||||
|
|
Loading…
Reference in New Issue