Tag Parser
7.0.1
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
|
#include <id3v2tag.h>
Public Member Functions | |
Id3v2Tag () | |
Constructs a new tag. More... | |
TagTextEncoding | proposedTextEncoding () const override |
Returns the proposed text encoding. More... | |
bool | canEncodingBeUsed (TagTextEncoding encoding) const override |
Returns an indication whether the specified encoding can be used to provide string values for the tag. More... | |
bool | supportsDescription (KnownField field) const override |
Returns an indications whether the specified field supports descriptions. More... | |
bool | supportsMimeType (KnownField field) const override |
Returns an indications whether the specified field supports mime types. More... | |
void | parse (std::istream &sourceStream, const uint64 maximalSize, Diagnostics &diag) |
Parses tag information from the specified stream. More... | |
Id3v2TagMaker | prepareMaking (Diagnostics &diag) |
Prepares making. More... | |
void | make (std::ostream &targetStream, uint32 padding, Diagnostics &diag) |
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... | |
![]() | |
FieldMapBasedTag () | |
Constructs a new FieldMapBasedTag. 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... | |
const TagValue & | value (const IdentifierType &id) const |
Returns the value of the field with the specified id. More... | |
const TagValue & | value (KnownField field) const |
Returns the value of the specified field. More... | |
std::vector< const TagValue *> | values (const 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... | |
bool | setValue (const 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 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... | |
bool | hasField (const 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< 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< 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... | |
IdentifierType | fieldId (KnownField value) const |
Returns the ID for the specified field. More... | |
KnownField | knownField (const IdentifierType &id) const |
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... | |
TagDataType | proposedDataType (const 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< Id3v2Tag > &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... | |
![]() | |
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 TagTarget & | target () 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... | |
Static Public Attributes | |
static constexpr TagType | tagType = TagType::Id3v2Tag |
static constexpr const char * | tagName = "ID3v2 tag" |
static constexpr TagTextEncoding | defaultTextEncoding = TagTextEncoding::Utf16LittleEndian |
Protected Member Functions | |
IdentifierType | internallyGetFieldId (KnownField field) const |
KnownField | internallyGetKnownField (const IdentifierType &id) const |
TagDataType | internallyGetProposedDataType (const uint32 &id) const |
![]() | |
const TagValue & | internallyGetValue (const IdentifierType &id) const |
Default implementation for value(). More... | |
bool | internallySetValue (const IdentifierType &id, const TagValue &value) |
Default implementation for setValue(). More... | |
bool | internallyHasField (const IdentifierType &id) const |
Default implementation for hasField(). More... | |
TagDataType | internallyGetProposedDataType (const IdentifierType &id) const |
Default implementation for proposedDataType(). More... | |
![]() | |
Tag () | |
Constructs a new Tag. More... | |
Friends | |
class | FieldMapBasedTag< Id3v2Tag > |
Additional Inherited Members | |
![]() | |
typedef FieldMapBasedTagTraits< Id3v2Tag >::FieldType | FieldType |
typedef FieldMapBasedTagTraits< Id3v2Tag >::FieldType::IdentifierType | IdentifierType |
typedef FieldMapBasedTagTraits< Id3v2Tag >::Compare | Compare |
![]() | |
std::string | m_version |
uint32 | m_size |
TagTarget | m_target |
Definition at line 61 of file id3v2tag.h.
|
inline |
Constructs a new tag.
Definition at line 108 of file id3v2tag.h.
|
inlineoverridevirtual |
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.
Reimplemented from TagParser::Tag.
Definition at line 123 of file id3v2tag.h.
|
inline |
Returns the size of the extended header if one is present; otherwise returns 0.
Definition at line 209 of file id3v2tag.h.
|
inline |
Returns the flags read from the ID3v2 header.
Definition at line 169 of file id3v2tag.h.
|
inline |
Returns an indication whether an extended header is used.
Definition at line 185 of file id3v2tag.h.
|
inline |
Returns an indication whether a footer is present.
Definition at line 201 of file id3v2tag.h.
|
protected |
Definition at line 21 of file id3v2tag.cpp.
|
protected |
Definition at line 124 of file id3v2tag.cpp.
|
protected |
Definition at line 211 of file id3v2tag.cpp.
|
inline |
Returns an indication whether the tag is labeled as experimental.
Definition at line 193 of file id3v2tag.h.
|
inline |
Returns an indication whether unsynchronisation is used.
Definition at line 177 of file id3v2tag.h.
|
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 161 of file id3v2tag.h.
|
inline |
Returns the major version if known; otherwise returns 0.
Definition at line 142 of file id3v2tag.h.
void TagParser::Id3v2Tag::make | ( | std::ostream & | targetStream, |
uint32 | padding, | ||
Diagnostics & | diag | ||
) |
Writes tag information to the specified stream.
Throws | std::ios_base::failure when an IO error occurs. |
Throws | Media::Failure or a derived exception when a making error occurs. |
Definition at line 372 of file id3v2tag.cpp.
|
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 218 of file id3v2tag.h.
void TagParser::Id3v2Tag::parse | ( | std::istream & | sourceStream, |
const uint64 | maximalSize, | ||
Diagnostics & | diag | ||
) |
Parses tag information from the specified stream.
Throws | std::ios_base::failure when an IO error occurs. |
Throws | Media::Failure or a derived exception when a parsing error occurs. |
Definition at line 244 of file id3v2tag.cpp.
Id3v2TagMaker TagParser::Id3v2Tag::prepareMaking | ( | Diagnostics & | diag | ) |
Prepares making.
Throws | Media::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.
Definition at line 360 of file id3v2tag.cpp.
|
inlineoverridevirtual |
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.
Reimplemented from TagParser::Tag.
Definition at line 118 of file id3v2tag.h.
|
inline |
Returns the revision version if known; otherwise returns 0.
Definition at line 150 of file id3v2tag.h.
void TagParser::Id3v2Tag::setVersion | ( | byte | majorVersion, |
byte | revisionVersion | ||
) |
Sets the version to the specified majorVersion and the specified revisionVersion.
Definition at line 381 of file id3v2tag.cpp.
|
inlineoverridevirtual |
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 TagParser::Tag.
Definition at line 129 of file id3v2tag.h.
|
inlineoverridevirtual |
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 TagParser::Tag.
Definition at line 134 of file id3v2tag.h.
|
friend |
Definition at line 62 of file id3v2tag.h.
|
static |
Definition at line 69 of file id3v2tag.h.
|
static |
Definition at line 68 of file id3v2tag.h.
|
static |
Definition at line 67 of file id3v2tag.h.