Tag Parser  6.5.0
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::Id3v1Tag Class Reference

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

#include <id3v1tag.h>

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

Public Member Functions

 Id3v1Tag ()
 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...
 
bool canEncodingBeUsed (TagTextEncoding encoding) const
 Returns an indication whether the specified encoding can be used to provide string values for the tag. More...
 
const TagValuevalue (KnownField value) const
 Returns the value of the specified field. More...
 
bool setValue (KnownField field, const TagValue &value)
 Assigns the given value to the specified field. More...
 
bool setValueConsideringTypeInfo (KnownField field, const TagValue &value, const std::string &typeInfo)
 
bool hasField (KnownField field) const
 Returns an indication whether the specified field is present. More...
 
void removeAllFields ()
 Removes all fields from the tag. More...
 
unsigned int fieldCount () const
 Returns the number of present fields. More...
 
bool supportsField (KnownField field) const
 Returns an indication whether the specified field is supported by the 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...
 
void parse (std::istream &sourceStream, bool autoSeek)
 Parses tag information from the specified stream. More...
 
void parse (std::iostream &sourceStream)
 Parses tag information from the specified stream. More...
 
void make (std::ostream &targetStream)
 Writes tag information to the specified stream. 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...
 
virtual TagTextEncoding proposedTextEncoding () const
 Returns the proposed text encoding. More...
 
virtual std::vector< const TagValue * > values (KnownField field) const
 Returns the values of the specified field. More...
 
virtual bool setValues (KnownField field, const std::vector< TagValue > &values)
 Assigns the given values to the specified field. 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...
 
virtual unsigned int insertValues (const Tag &from, bool overwrite)
 Inserts all compatible values from another Tag. 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::Id3v1Tag
 

Additional Inherited Members

- 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 ID3v1 tags.

Definition at line 9 of file id3v1tag.h.

Constructor & Destructor Documentation

◆ Id3v1Tag()

Media::Id3v1Tag::Id3v1Tag ( )

Constructs a new tag.

Definition at line 23 of file id3v1tag.cpp.

Member Function Documentation

◆ canEncodingBeUsed()

bool Media::Id3v1Tag::canEncodingBeUsed ( TagTextEncoding  encoding) const
virtual

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 36 of file id3v1tag.cpp.

◆ ensureTextValuesAreProperlyEncoded()

void Media::Id3v1Tag::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 257 of file id3v1tag.cpp.

◆ fieldCount()

unsigned int Media::Id3v1Tag::fieldCount ( ) const
virtual

Returns the number of present fields.

Implements Media::Tag.

Definition at line 229 of file id3v1tag.cpp.

◆ hasField()

bool Media::Id3v1Tag::hasField ( KnownField  field) const
virtual

Returns an indication whether the specified field is present.

See also
value(), setValue()

Implements Media::Tag.

Definition at line 196 of file id3v1tag.cpp.

◆ make()

void Media::Id3v1Tag::make ( std::ostream &  targetStream)

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 103 of file id3v1tag.cpp.

◆ parse() [1/2]

void Media::Id3v1Tag::parse ( std::istream &  stream,
bool  autoSeek 
)

Parses tag information from the specified stream.

Parameters
streamSpecifies the stream to read from.
autoSeekSpecifies whether the parser should automatically seek at the end of 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 49 of file id3v1tag.cpp.

◆ parse() [2/2]

void Media::Id3v1Tag::parse ( std::iostream &  stream)

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 91 of file id3v1tag.cpp.

◆ removeAllFields()

void Media::Id3v1Tag::removeAllFields ( )
virtual

Removes all fields from the tag.

Implements Media::Tag.

Definition at line 218 of file id3v1tag.cpp.

◆ setValue()

bool Media::Id3v1Tag::setValue ( KnownField  field,
const TagValue value 
)
virtual

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 161 of file id3v1tag.cpp.

◆ setValueConsideringTypeInfo()

bool Media::Id3v1Tag::setValueConsideringTypeInfo ( KnownField  field,
const TagValue value,
const std::string &  typeInfo 
)

Definition at line 191 of file id3v1tag.cpp.

◆ supportsField()

bool Media::Id3v1Tag::supportsField ( KnownField  field) const
virtual

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

Implements Media::Tag.

Definition at line 241 of file id3v1tag.cpp.

◆ type()

TagType Media::Id3v1Tag::type ( ) const
virtual

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 26 of file id3v1tag.cpp.

◆ typeName()

const char * Media::Id3v1Tag::typeName ( ) const
virtual

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 31 of file id3v1tag.cpp.

◆ value()

const TagValue & Media::Id3v1Tag::value ( KnownField  field) const
virtual

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 139 of file id3v1tag.cpp.

Member Data Documentation

◆ tagType

constexpr TagType Media::Id3v1Tag::tagType = TagType::Id3v1Tag
static

Definition at line 14 of file id3v1tag.h.


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