Tag Parser  6.5.1
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
Public Member Functions | Static Public Attributes | List of all members
Media::Id3v2Tag Class Reference

Implementation of Media::Tag for ID3v2 tags. More...

#include <id3v2tag.h>

Inheritance diagram for Media::Id3v2Tag:
[legend]
Collaboration diagram for Media::Id3v2Tag:
[legend]

Public Member Functions

 Id3v2Tag ()
 Constructs a new tag. More...
 
TagType type () const
 Returns the type of the tag as Media::TagType. More...
 
const char * typeName () const
 Returns the type name of the tag as C-style string. More...
 
TagTextEncoding proposedTextEncoding () const
 Returns the proposed text encoding. More...
 
bool canEncodingBeUsed (TagTextEncoding encoding) const
 Returns an indication whether the specified encoding can be used to provide string values for the tag. More...
 
uint32 fieldId (KnownField value) const
 Returns the ID for the specified field. More...
 
KnownField knownField (const uint32 &id) const
 
TagDataType proposedDataType (const uint32 &id) const
 
const TagValuevalue (const typename Id3v2Frame::identifierType &id) const
 
bool setValue (const typename Id3v2Frame::identifierType &id, const TagValue &value)
 
bool supportsDescription (KnownField field) const
 Returns an indications whether the specified field supports descriptions. More...
 
bool supportsMimeType (KnownField field) const
 Returns an indications whether the specified field supports mime types. More...
 
void parse (std::istream &sourceStream, const uint64 maximalSize=0)
 Parses tag information from the specified stream. More...
 
Id3v2TagMaker prepareMaking ()
 Prepares making. More...
 
void make (std::ostream &targetStream, uint32 padding)
 Writes tag information to the specified stream. More...
 
byte majorVersion () const
 Returns the major version if known; otherwise returns 0. More...
 
byte revisionVersion () const
 Returns the revision version if known; otherwise returns 0. More...
 
void setVersion (byte majorVersion, byte revisionVersion)
 Sets the version to the specified majorVersion and the specified revisionVersion. More...
 
bool isVersionSupported () const
 Returns an indication whether the version is supported by the Id3v2Tag class. More...
 
byte flags () const
 Returns the flags read from the ID3v2 header. More...
 
bool isUnsynchronisationUsed () const
 Returns an indication whether unsynchronisation is used. More...
 
bool hasExtendedHeader () const
 Returns an indication whether an extended header is used. More...
 
bool isExperimental () const
 Returns an indication whether the tag is labeled as experimental. More...
 
bool hasFooter () const
 Returns an indication whether a footer is present. More...
 
uint32 extendedHeaderSize () const
 Returns the size of the extended header if one is present; otherwise returns 0. More...
 
uint32 paddingSize () const
 Returns the size of the padding between the tag and the first MPEG frame if one is present; otherwise returns 0. More...
 
- Public Member Functions inherited from Media::FieldMapBasedTag< Id3v2Frame, FrameComparer >
 FieldMapBasedTag ()
 Constructs a new FieldMapBasedTag. More...
 
virtual const TagValuevalue (const typename Id3v2Frame ::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 Id3v2Frame ::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 Id3v2Frame ::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 Id3v2Frame ::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 Id3v2Frame ::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 Id3v2Frame ::identifierType, Id3v2Frame, FrameComparer > & fields () const
 Returns the fields of the tag by providing direct access to the field map of the tag. More...
 
std::multimap< typename Id3v2Frame ::identifierType, Id3v2Frame, FrameComparer > & 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 KnownField knownField (const typename Id3v2Frame ::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 Id3v2Frame ::identifierType &id) const
 Returns the proposed data type for the field with the specified id. More...
 
virtual TagDataType proposedDataType (KnownField field) const
 Returns the proposed data type for the specified field as TagDataType. More...
 
int insertFields (const FieldMapBasedTag< Id3v2Frame, FrameComparer > &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...
 
std::string toString () const
 Returns a string representation of 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...
 
- 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 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 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 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 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 method is meant to be called by the derived class to add the specified notifications. More...
 

Static Public Attributes

static constexpr TagType tagType = TagType::Id3v2Tag
 

Additional Inherited Members

- Public Types inherited from Media::FieldMapBasedTag< Id3v2Frame, FrameComparer >
typedef Id3v2Frame fieldType
 
- Public Types inherited from Media::StatusProvider
typedef std::function< void(StatusProvider &sender)> CallbackFunction
 
typedef std::vector< CallbackFunctionCallbackVector
 
typedef std::pair< int, CallbackFunctionCallbackPair
 
- 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

Implementation of Media::Tag for ID3v2 tags.

Definition at line 55 of file id3v2tag.h.

Constructor & Destructor Documentation

◆ Id3v2Tag()

Media::Id3v2Tag::Id3v2Tag ( )
inline

Constructs a new tag.

Definition at line 103 of file id3v2tag.h.

Member Function Documentation

◆ canEncodingBeUsed()

bool Media::Id3v2Tag::canEncodingBeUsed ( TagTextEncoding  encoding) const
inlinevirtual

Returns an indication whether the specified encoding can be used to provide string values for the tag.

Only the proposedTextEncoding() is accepted by default. This might be overwritten when subclassing.

The tag class and its subclasses do not perform any conversions. You have to provide all string values using an encoding which is appropriate for the specific tag type. This method is meant to determine if a particular encoding can be used.

See also
canEncodingBeUsed()

Reimplemented from Media::Tag.

Definition at line 127 of file id3v2tag.h.

◆ extendedHeaderSize()

uint32 Media::Id3v2Tag::extendedHeaderSize ( ) const
inline

Returns the size of the extended header if one is present; otherwise returns 0.

Definition at line 212 of file id3v2tag.h.

◆ fieldId()

uint32 Media::Id3v2Tag::fieldId ( KnownField  value) const
virtual

Returns the ID for the specified field.

Needs to be implemented when subclassing.

Implements Media::FieldMapBasedTag< Id3v2Frame, FrameComparer >.

Definition at line 20 of file id3v2tag.cpp.

◆ flags()

byte Media::Id3v2Tag::flags ( ) const
inline

Returns the flags read from the ID3v2 header.

Definition at line 172 of file id3v2tag.h.

◆ hasExtendedHeader()

bool Media::Id3v2Tag::hasExtendedHeader ( ) const
inline

Returns an indication whether an extended header is used.

Definition at line 188 of file id3v2tag.h.

◆ hasFooter()

bool Media::Id3v2Tag::hasFooter ( ) const
inline

Returns an indication whether a footer is present.

Definition at line 204 of file id3v2tag.h.

◆ isExperimental()

bool Media::Id3v2Tag::isExperimental ( ) const
inline

Returns an indication whether the tag is labeled as experimental.

Definition at line 196 of file id3v2tag.h.

◆ isUnsynchronisationUsed()

bool Media::Id3v2Tag::isUnsynchronisationUsed ( ) const
inline

Returns an indication whether unsynchronisation is used.

Definition at line 180 of file id3v2tag.h.

◆ isVersionSupported()

bool Media::Id3v2Tag::isVersionSupported ( ) const
inline

Returns an indication whether the version is supported by the Id3v2Tag class.

Major versions 2, 3 and 4 are currently supported.

Definition at line 164 of file id3v2tag.h.

◆ knownField()

KnownField Media::Id3v2Tag::knownField ( const uint32 &  id) const

Definition at line 81 of file id3v2tag.cpp.

◆ majorVersion()

byte Media::Id3v2Tag::majorVersion ( ) const
inline

Returns the major version if known; otherwise returns 0.

Definition at line 145 of file id3v2tag.h.

◆ make()

void Media::Id3v2Tag::make ( std::ostream &  targetStream,
uint32  padding 
)

Writes tag information to the specified stream.

Exceptions
Throwsstd::ios_base::failure when an IO error occurs.
ThrowsMedia::Failure or a derived exception when a making error occurs.

Definition at line 303 of file id3v2tag.cpp.

◆ paddingSize()

uint32 Media::Id3v2Tag::paddingSize ( ) const
inline

Returns the size of the padding between the tag and the first MPEG frame if one is present; otherwise returns 0.

Definition at line 221 of file id3v2tag.h.

◆ parse()

void Media::Id3v2Tag::parse ( std::istream &  sourceStream,
const uint64  maximalSize = 0 
)

Parses tag information from the specified stream.

Exceptions
Throwsstd::ios_base::failure when an IO error occurs.
ThrowsMedia::Failure or a derived exception when a parsing error occurs.

Definition at line 167 of file id3v2tag.cpp.

◆ prepareMaking()

Id3v2TagMaker Media::Id3v2Tag::prepareMaking ( )

Prepares making.

Returns
Returns a Id3v2TagMaker object which can be used to actually make the tag.
Remarks
The tag must NOT be mutated after making is prepared when it is intended to actually make the tag using the make method of the returned object.
Exceptions
ThrowsMedia::Failure or a derived exception when a making error occurs.

This method might be useful when it is necessary to know the size of the tag before making it.

See also
make()

Definition at line 291 of file id3v2tag.cpp.

◆ proposedDataType()

TagDataType Media::Id3v2Tag::proposedDataType ( const uint32 &  id) const

Definition at line 128 of file id3v2tag.cpp.

◆ proposedTextEncoding()

TagTextEncoding Media::Id3v2Tag::proposedTextEncoding ( ) const
inlinevirtual

Returns the proposed text encoding.

This is TagTextEncoding::Latin1 by default an might be overwritten when subclassing.

The tag class and its subclasses do not perform any conversions. You have to provide all string values using an encoding which is appropriate for the specific tag type. This method returns such an encoding.

See also
canEncodingBeUsed()

Reimplemented from Media::Tag.

Definition at line 122 of file id3v2tag.h.

◆ revisionVersion()

byte Media::Id3v2Tag::revisionVersion ( ) const
inline

Returns the revision version if known; otherwise returns 0.

Definition at line 153 of file id3v2tag.h.

◆ setValue()

bool Media::Id3v2Tag::setValue ( const typename Id3v2Frame::identifierType id,
const TagValue value 
)

Definition at line 155 of file id3v2tag.cpp.

◆ setVersion()

void Media::Id3v2Tag::setVersion ( byte  majorVersion,
byte  revisionVersion 
)

Sets the version to the specified majorVersion and the specified revisionVersion.

Definition at line 312 of file id3v2tag.cpp.

◆ supportsDescription()

bool Media::Id3v2Tag::supportsDescription ( KnownField  field) const
inlinevirtual

Returns an indications whether the specified field supports descriptions.

If you assign a description to a field value and the field does not support descriptions the description is ignored when saving the tag.

The default implementation returns false for all fields. This might be overwritten when subclassing.

Reimplemented from Media::Tag.

Definition at line 132 of file id3v2tag.h.

◆ supportsMimeType()

bool Media::Id3v2Tag::supportsMimeType ( KnownField  field) const
inlinevirtual

Returns an indications whether the specified field supports mime types.

If you assign a mime types to a field value and the field does not support mime types the mime type is ignored when saving the tag.

The default implementation returns false for all fields. This might be overwritten when subclassing.

Reimplemented from Media::Tag.

Definition at line 137 of file id3v2tag.h.

◆ type()

TagType Media::Id3v2Tag::type ( ) const
inlinevirtual

Returns the type of the tag as Media::TagType.

This is TagType::Unspecified by default and might be overwritten when subclassing.

Reimplemented from Media::Tag.

Definition at line 112 of file id3v2tag.h.

◆ typeName()

const char * Media::Id3v2Tag::typeName ( ) const
inlinevirtual

Returns the type name of the tag as C-style string.

This is "unspecified" by default and might be overwritten when subclassing.

Reimplemented from Media::Tag.

Definition at line 117 of file id3v2tag.h.

◆ value()

const TagValue & Media::Id3v2Tag::value ( const typename Id3v2Frame::identifierType id) const

Definition at line 150 of file id3v2tag.cpp.

Member Data Documentation

◆ tagType

constexpr TagType Media::Id3v2Tag::tagType = TagType::Id3v2Tag
static

Definition at line 60 of file id3v2tag.h.


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