Tag Parser  8.2.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
TagParser::Id3v1Tag Class Reference

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

#include <id3v1tag.h>

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

Public Member Functions

 Id3v1Tag ()
 Constructs a new tag. More...
 
TagType type () const override
 Returns the type of the tag as TagParser::TagType. More...
 
const char * typeName () const override
 Returns the type name of the tag as C-style string. 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...
 
const TagValuevalue (KnownField value) const override
 Returns the value of the specified field. More...
 
bool setValue (KnownField field, const TagValue &value) override
 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 override
 Returns an indication whether the specified field is present. More...
 
void removeAllFields () override
 Removes all fields from the tag. More...
 
unsigned int fieldCount () const override
 Returns the number of present fields. More...
 
bool supportsField (KnownField field) const override
 Returns an indication whether the specified field is supported by the tag. More...
 
void ensureTextValuesAreProperlyEncoded () override
 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, Diagnostics &diag)
 Parses tag information from the specified stream. More...
 
void make (std::ostream &targetStream, Diagnostics &diag)
 Writes tag information to the specified stream. More...
 
- Public Member Functions inherited from TagParser::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 bool supportsMultipleValues (KnownField field) const
 Returns an indications whether the specified field supports multiple values. More...
 
virtual unsigned int insertValues (const Tag &from, bool overwrite)
 Inserts all compatible values from another Tag. More...
 

Static Public Attributes

static constexpr TagType tagType = TagType::Id3v1Tag
 
static constexpr const char * tagName = "ID3v1 tag"
 

Additional Inherited Members

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

Detailed Description

Implementation of TagParser::Tag for ID3v1 tags.

Definition at line 10 of file id3v1tag.h.

Constructor & Destructor Documentation

◆ Id3v1Tag()

TagParser::Id3v1Tag::Id3v1Tag ( )

Constructs a new tag.

Definition at line 24 of file id3v1tag.cpp.

Member Function Documentation

◆ canEncodingBeUsed()

bool TagParser::Id3v1Tag::canEncodingBeUsed ( TagTextEncoding  encoding) const
overridevirtual

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 TagParser::Tag.

Definition at line 38 of file id3v1tag.cpp.

◆ ensureTextValuesAreProperlyEncoded()

void TagParser::Id3v1Tag::ensureTextValuesAreProperlyEncoded ( )
overridevirtual

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

Implements TagParser::Tag.

Definition at line 251 of file id3v1tag.cpp.

◆ fieldCount()

unsigned int TagParser::Id3v1Tag::fieldCount ( ) const
overridevirtual

Returns the number of present fields.

Implements TagParser::Tag.

Definition at line 224 of file id3v1tag.cpp.

◆ hasField()

bool TagParser::Id3v1Tag::hasField ( KnownField  field) const
overridevirtual

Returns an indication whether the specified field is present.

See also
value(), setValue()

Implements TagParser::Tag.

Definition at line 191 of file id3v1tag.cpp.

◆ make()

void TagParser::Id3v1Tag::make ( std::ostream &  targetStream,
Diagnostics diag 
)

Writes tag information to the specified stream.

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

Definition at line 83 of file id3v1tag.cpp.

◆ parse()

void TagParser::Id3v1Tag::parse ( std::istream &  stream,
Diagnostics diag 
)

Parses tag information from the specified stream.

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

Definition at line 49 of file id3v1tag.cpp.

◆ removeAllFields()

void TagParser::Id3v1Tag::removeAllFields ( )
overridevirtual

Removes all fields from the tag.

Implements TagParser::Tag.

Definition at line 213 of file id3v1tag.cpp.

◆ setValue()

bool TagParser::Id3v1Tag::setValue ( KnownField  field,
const TagValue value 
)
overridevirtual

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 TagParser::Tag.

Definition at line 156 of file id3v1tag.cpp.

◆ setValueConsideringTypeInfo()

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

Definition at line 186 of file id3v1tag.cpp.

◆ supportsField()

bool TagParser::Id3v1Tag::supportsField ( KnownField  field) const
overridevirtual

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

Implements TagParser::Tag.

Definition at line 235 of file id3v1tag.cpp.

◆ type()

TagType TagParser::Id3v1Tag::type ( ) const
overridevirtual

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

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

Reimplemented from TagParser::Tag.

Definition at line 28 of file id3v1tag.cpp.

◆ typeName()

const char * TagParser::Id3v1Tag::typeName ( ) const
overridevirtual

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

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

Reimplemented from TagParser::Tag.

Definition at line 33 of file id3v1tag.cpp.

◆ value()

const TagValue & TagParser::Id3v1Tag::value ( KnownField  field) const
overridevirtual

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 TagParser::Tag.

Definition at line 134 of file id3v1tag.cpp.

Member Data Documentation

◆ tagName

constexpr const char* TagParser::Id3v1Tag::tagName = "ID3v1 tag"
static

Definition at line 15 of file id3v1tag.h.

◆ tagType

constexpr TagType TagParser::Id3v1Tag::tagType = TagType::Id3v1Tag
static

Definition at line 14 of file id3v1tag.h.


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