Tag Parser  6.3.0
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
Public Types | Public Member Functions | List of all members
Media::FieldMapBasedTag< FieldType, Compare > Class Template Referenceabstract

The FieldMapBasedTag provides a generic implementation of Tag which stores the tag fields using std::multimap. More...

#include <fieldbasedtag.h>

Inheritance diagram for Media::FieldMapBasedTag< FieldType, Compare >:
[legend]
Collaboration diagram for Media::FieldMapBasedTag< FieldType, Compare >:
[legend]

Public Types

typedef FieldType fieldType
 
- Public Types inherited from Media::StatusProvider
typedef std::function< void(StatusProvider &sender)> CallbackFunction
 
typedef std::vector< CallbackFunctionCallbackVector
 
typedef std::pair< int, CallbackFunctionCallbackPair
 

Public Member Functions

 FieldMapBasedTag ()
 Constructs a new FieldMapBasedTag. More...
 
virtual const TagValuevalue (const typename FieldType::identifierType &id) const
 Returns the value of the field with the specified id. More...
 
const TagValuevalue (KnownField field) const
 Returns the value of the specified field. More...
 
std::vector< const TagValue * > values (const typename FieldType::identifierType &id) const
 Returns the values of the field with the specified id. More...
 
std::vector< const TagValue * > values (KnownField field) const
 Returns the values of the specified field. More...
 
virtual bool setValue (const typename FieldType::identifierType &id, const TagValue &value)
 Assigns the given value to the field with the specified id. More...
 
bool setValue (KnownField field, const TagValue &value)
 Assigns the given value to the specified field. More...
 
bool setValues (const typename FieldType::identifierType &id, const std::vector< TagValue > &values)
 Assigns the given values to the field with the specified id. More...
 
bool setValues (KnownField field, const std::vector< TagValue > &values)
 Assigns the given values to the field with the specified id. More...
 
bool hasField (KnownField field) const
 Returns an indication whether the specified field is present. More...
 
virtual bool hasField (const typename FieldType::identifierType &id) const
 Returns an indication whether the field with the specified id is present. More...
 
void removeAllFields ()
 Removes all fields from the tag. More...
 
const std::multimap< typename FieldType::identifierType, FieldType, Compare > & fields () const
 Returns the fields of the tag by providing direct access to the field map of the tag. More...
 
std::multimap< typename FieldType::identifierType, FieldType, Compare > & fields ()
 Returns the fields of the tag by providing direct access to the field map of the tag. More...
 
unsigned int fieldCount () const
 Returns the number of present fields. More...
 
virtual FieldType::identifierType fieldId (KnownField value) const =0
 Returns the ID for the specified field. More...
 
virtual KnownField knownField (const typename FieldType::identifierType &id) const =0
 Returns the field for the specified ID. More...
 
bool supportsField (KnownField field) const
 Returns an indication whether the specified field is supported by the tag. More...
 
virtual TagDataType proposedDataType (const typename FieldType::identifierType &id) const
 Returns the proposed data type for the field with the specified id. More...
 
int insertFields (const FieldMapBasedTag< FieldType, Compare > &from, bool overwrite)
 Inserts all fields from another tag of the same field type and compare function. More...
 
unsigned int insertValues (const Tag &from, bool overwrite)
 Inserts all compatible values from another Tag. More...
 
void ensureTextValuesAreProperlyEncoded ()
 Ensures the encoding of all assigned text values is supported by the tag by converting the character set if neccessary. More...
 
- Public Member Functions inherited from Media::Tag
virtual ~Tag ()
 Destroys the Tag. More...
 
virtual TagType type () const
 Returns the type of the tag as Media::TagType. More...
 
virtual const char * typeName () const
 Returns the type name of the tag as C-style string. More...
 
std::string toString () const
 Returns a string representation of the tag. More...
 
virtual TagTextEncoding proposedTextEncoding () const
 Returns the proposed text encoding. More...
 
virtual bool canEncodingBeUsed (TagTextEncoding encoding) const
 Returns an indication whether the specified encoding can be used to provide string values for the tag. More...
 
const std::string & version () const
 Returns the version of the tag as std::string. More...
 
uint32 size () const
 Returns the size of the tag in bytes. More...
 
virtual bool supportsTarget () const
 Returns an indication whether a target is supported by the tag. More...
 
const TagTargettarget () const
 Returns the target of tag. More...
 
void setTarget (const TagTarget &target)
 Sets the target of tag. More...
 
virtual TagTargetLevel targetLevel () const
 Returns the name of the current tag target level. More...
 
const char * targetLevelName () const
 Returns the name of the current target level. More...
 
bool isTargetingLevel (TagTargetLevel tagTargetLevel) const
 Returns whether the tag is targeting the specified tagTargetLevel. More...
 
std::string targetString () const
 Returns the string representation for the assigned tag target. More...
 
virtual TagDataType proposedDataType (KnownField field) const
 Returns the proposed data type for the specified field as TagDataType. More...
 
virtual bool supportsDescription (KnownField field) const
 Returns an indications whether the specified field supports descriptions. More...
 
virtual bool supportsMimeType (KnownField field) const
 Returns an indications whether the specified field supports mime types. More...
 
- Public Member Functions inherited from Media::StatusProvider
const NotificationListnotifications () const
 Returns notifications for the current object. More...
 
bool hasNotifications () const
 Returns an indication whether there are notifications for the current object. More...
 
bool hasCriticalNotifications () const
 Returns an indication whether there are critical notifications for the current object. More...
 
NotificationType worstNotificationType () const
 Returns the worst notification type. More...
 
const std::string & currentStatus () const
 Returns a status information for the current object. More...
 
double currentPercentage () const
 Returns the progress percentage of the current object. More...
 
size_t registerCallback (CallbackFunction callback)
 Registers a callback function. More...
 
void unregisterCallback (size_t id)
 Unregisters a previously registered callback function whith the specified id. More...
 
void unregisterAllCallbacks ()
 Unregisters all callback functions. More...
 
void forwardStatusUpdateCalls (StatusProvider *other=nullptr)
 Forwards all status updates calls to the specified statusProvider. More...
 
StatusProviderusedProvider ()
 Returns the provider which callback functions will be called when the status or the percentage is updated. More...
 
void tryToAbort ()
 Commands the object to abort the current operation. More...
 
bool isAborted () const
 Returns an indication whether the current operation should be aborted. More...
 
void invalidateStatus ()
 Invalidates the current status. More...
 
void invalidateNotifications ()
 Invalidates the object's notifications. More...
 
void updateStatus (const std::string &status)
 This method is meant to be called by the derived class to report updated status information. More...
 
void updateStatus (const std::string &status, double percentage)
 This method is meant to be called by the derived class to report updated status information. More...
 
void updatePercentage (double percentage)
 This method is meant to be called by the derived class to report updated progress percentage only. More...
 
void addNotification (const Notification &notification)
 This protected method is meant to be called by the derived class to add a notification. More...
 
void addNotification (NotificationType type, const std::string &message, const std::string &context)
 This protected method is meant to be called by the derived class to add a notification of the specified type, message and context. More...
 
void addNotifications (const StatusProvider &from)
 This protected method is meant to be called by the derived class to add all notifications from another StatusProvider instance. More...
 
void addNotifications (const std::string &higherContext, const StatusProvider &from)
 This protected method is meant to be called by the derived class to add all notifications from another StatusProvider instance. More...
 
void addNotifications (const NotificationList &notifications)
 This protected method is meant to be called by the derived class to add the specified notifications. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Media::Tag
 Tag ()
 Constructs a new Tag. More...
 
- Protected Member Functions inherited from Media::StatusProvider
 StatusProvider ()
 Constructs a new StatusProvider. More...
 
- Protected Attributes inherited from Media::Tag
std::string m_version
 
uint32 m_size
 
TagTarget m_target
 

Detailed Description

template<class FieldType, class Compare = std::less<typename FieldType::identifierType>>
class Media::FieldMapBasedTag< FieldType, Compare >

The FieldMapBasedTag provides a generic implementation of Tag which stores the tag fields using std::multimap.

The FieldMapBasedTag class only provides the interface and common functionality. It is meant to be subclassed.

Template Parameters
FieldTypeSpecifies the class used to store the fields. Should be a subclass of TagField.
CompareSpecifies the key comparsion function. Default is std::less.

Definition at line 25 of file fieldbasedtag.h.

Member Typedef Documentation

◆ fieldType

template<class FieldType, class Compare = std::less<typename FieldType::identifierType>>
typedef FieldType Media::FieldMapBasedTag< FieldType, Compare >::fieldType

Definition at line 52 of file fieldbasedtag.h.

Constructor & Destructor Documentation

◆ FieldMapBasedTag()

template<class FieldType , class Compare >
Media::FieldMapBasedTag< FieldType, Compare >::FieldMapBasedTag ( )

Constructs a new FieldMapBasedTag.

Definition at line 76 of file fieldbasedtag.h.

Member Function Documentation

◆ ensureTextValuesAreProperlyEncoded()

template<class FieldType , class Compare >
void Media::FieldMapBasedTag< FieldType, Compare >::ensureTextValuesAreProperlyEncoded ( )
virtual

Ensures the encoding of all assigned text values is supported by the tag by converting the character set if neccessary.

Implements Media::Tag.

Definition at line 302 of file fieldbasedtag.h.

◆ fieldCount()

template<class FieldType , class Compare >
unsigned int Media::FieldMapBasedTag< FieldType, Compare >::fieldCount ( ) const
virtual

Returns the number of present fields.

Implements Media::Tag.

Definition at line 226 of file fieldbasedtag.h.

◆ fieldId()

template<class FieldType, class Compare = std::less<typename FieldType::identifierType>>
Media::FieldMapBasedTag< FieldType, Compare >::fieldId ( KnownField  value) const
pure virtual

Returns the ID for the specified field.

Needs to be implemented when subclassing.

Implemented in Media::Mp4Tag, Media::Id3v2Tag, Media::MatroskaTag, and Media::VorbisComment.

◆ fields() [1/2]

template<class FieldType , class Compare >
const std::multimap< typename FieldType::identifierType, FieldType, Compare > & Media::FieldMapBasedTag< FieldType, Compare >::fields ( ) const
inline

Returns the fields of the tag by providing direct access to the field map of the tag.

Definition at line 211 of file fieldbasedtag.h.

◆ fields() [2/2]

template<class FieldType , class Compare >
std::multimap< typename FieldType::identifierType, FieldType, Compare > & Media::FieldMapBasedTag< FieldType, Compare >::fields ( )
inline

Returns the fields of the tag by providing direct access to the field map of the tag.

Definition at line 220 of file fieldbasedtag.h.

◆ hasField() [1/2]

template<class FieldType , class Compare >
bool Media::FieldMapBasedTag< FieldType, Compare >::hasField ( KnownField  field) const
inlinevirtual

Returns an indication whether the specified field is present.

See also
value(), setValue()

Implements Media::Tag.

Definition at line 182 of file fieldbasedtag.h.

◆ hasField() [2/2]

template<class FieldType, class Compare >
bool Media::FieldMapBasedTag< FieldType, Compare >::hasField ( const typename FieldType::identifierType &  id) const
inlinevirtual

Returns an indication whether the field with the specified id is present.

Definition at line 191 of file fieldbasedtag.h.

◆ insertFields()

template<class FieldType, class Compare>
int Media::FieldMapBasedTag< FieldType, Compare >::insertFields ( const FieldMapBasedTag< FieldType, Compare > &  from,
bool  overwrite 
)

Inserts all fields from another tag of the same field type and compare function.

Parameters
fromSpecifies the tag the fields should be inserted from.
overwriteIndicates whether existing fields should be overwritten.
Returns
Returns the number of fields that have been inserted.

Definition at line 260 of file fieldbasedtag.h.

◆ insertValues()

template<class FieldType , class Compare >
unsigned int Media::FieldMapBasedTag< FieldType, Compare >::insertValues ( const Tag from,
bool  overwrite 
)
virtual

Inserts all compatible values from another Tag.

Parameters
fromSpecifies the Tag the values should be inserted from.
overwriteIndicates whether existing values should be overwritten.
Returns
Returns the number of values that have been inserted.
Remarks
The encoding of the inserted text values might not be supported by the tag. To fix this, call ensureTextValuesAreProperlyEncoded() after insertion.

Reimplemented from Media::Tag.

Definition at line 291 of file fieldbasedtag.h.

◆ knownField()

template<class FieldType, class Compare = std::less<typename FieldType::identifierType>>
Media::FieldMapBasedTag< FieldType, Compare >::knownField ( const typename FieldType::identifierType &  id) const
pure virtual

Returns the field for the specified ID.

Needs to be implemented when subclassing.

◆ proposedDataType()

template<class FieldType, class Compare >
TagDataType Media::FieldMapBasedTag< FieldType, Compare >::proposedDataType ( const typename FieldType::identifierType &  id) const
inlinevirtual

Returns the proposed data type for the field with the specified id.

Definition at line 248 of file fieldbasedtag.h.

◆ removeAllFields()

template<class FieldType , class Compare >
void Media::FieldMapBasedTag< FieldType, Compare >::removeAllFields ( )
inlinevirtual

Removes all fields from the tag.

Implements Media::Tag.

Definition at line 202 of file fieldbasedtag.h.

◆ setValue() [1/2]

template<class FieldType, class Compare >
bool Media::FieldMapBasedTag< FieldType, Compare >::setValue ( const typename FieldType::identifierType &  id,
const TagValue value 
)
virtual

Assigns the given value to the field with the specified id.

See also
Tag::setValue()

Definition at line 130 of file fieldbasedtag.h.

◆ setValue() [2/2]

template<class FieldType, class Compare >
bool Media::FieldMapBasedTag< FieldType, Compare >::setValue ( KnownField  field,
const TagValue value 
)
inlinevirtual

Assigns the given value to the specified field.

Remarks
  • If an empty value is given, the field will be be removed.
  • Some tags support more than just one value per field. This method will only alter the first value.
See also
value(), hasField()

Implements Media::Tag.

Definition at line 120 of file fieldbasedtag.h.

◆ setValues() [1/2]

template<class FieldType, class Compare >
bool Media::FieldMapBasedTag< FieldType, Compare >::setValues ( const typename FieldType::identifierType &  id,
const std::vector< TagValue > &  values 
)

Assigns the given values to the field with the specified id.

Remarks
There might me more than one value assigned to an id. Whereas setValue() only alters the first value, this method will replace all currently assigned values with the specified values.
See also
Tag::setValues()

Definition at line 150 of file fieldbasedtag.h.

◆ setValues() [2/2]

template<class FieldType, class Compare >
bool Media::FieldMapBasedTag< FieldType, Compare >::setValues ( KnownField  field,
const std::vector< TagValue > &  values 
)
virtual

Assigns the given values to the field with the specified id.

Remarks
There might me more than one value assigned to a field. Whereas setValue() only alters the first value, this method will replace all currently assigned values with the specified values.
See also
Tag::setValues()

Reimplemented from Media::Tag.

Definition at line 176 of file fieldbasedtag.h.

◆ supportsField()

template<class FieldType , class Compare >
bool Media::FieldMapBasedTag< FieldType, Compare >::supportsField ( KnownField  field) const
inlinevirtual

Returns an indication whether the specified field is supported by the tag.

Implements Media::Tag.

Definition at line 238 of file fieldbasedtag.h.

◆ value() [1/2]

template<class FieldType, class Compare >
const TagValue & Media::FieldMapBasedTag< FieldType, Compare >::value ( const typename FieldType::identifierType &  id) const
inlinevirtual

Returns the value of the field with the specified id.

See also
Tag::value()

Definition at line 84 of file fieldbasedtag.h.

◆ value() [2/2]

template<class FieldType, class Compare >
const TagValue & Media::FieldMapBasedTag< FieldType, Compare >::value ( KnownField  field) const
inlinevirtual

Returns the value of the specified field.

Remarks
  • If the specified field is not present an empty TagValue will be returned.
  • Some tags support more than just one value per field. If there are multiple values this method just returns the first one.
See also
setValue(), hasField()

Implements Media::Tag.

Definition at line 91 of file fieldbasedtag.h.

◆ values() [1/2]

template<class FieldType, class Compare >
std::vector< const TagValue * > Media::FieldMapBasedTag< FieldType, Compare >::values ( const typename FieldType::identifierType &  id) const
inline

Returns the values of the field with the specified id.

See also
Tag::values()

Definition at line 101 of file fieldbasedtag.h.

◆ values() [2/2]

template<class FieldType, class Compare >
std::vector< const TagValue * > Media::FieldMapBasedTag< FieldType, Compare >::values ( KnownField  field) const
inlinevirtual

Returns the values of the specified field.

Remarks
  • There might me more than one value assigned to a field. Whereas value() returns only the first value, this method returns all values.
  • However, the default implementation just returns the first value assuming multiple values per field are not supported by the tag.

Reimplemented from Media::Tag.

Definition at line 114 of file fieldbasedtag.h.


The documentation for this class was generated from the following file: