Tag Parser 12.3.1
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
Loading...
Searching...
No Matches
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.
 
TagType type () const override
 Returns the type of the tag as TagParser::TagType.
 
std::string_view typeName () const override
 Returns the type name of the tag as C-style string.
 
bool canEncodingBeUsed (TagTextEncoding encoding) const override
 Returns only true for TagTextEncoding::Latin1.
 
const TagValuevalue (KnownField value) const override
 Returns the value of the specified field.
 
bool setValue (KnownField field, const TagValue &value) override
 Assigns the given value to the specified field.
 
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.
 
void removeAllFields () override
 Removes all fields from the tag.
 
std::size_t fieldCount () const override
 Returns the number of present fields.
 
bool supportsField (KnownField field) const override
 Returns an indication whether the specified field is supported by the tag.
 
void ensureTextValuesAreProperlyEncoded () override
 Ensures the encoding of all assigned text values is supported by the tag by converting the character set if necessary.
 
void parse (std::istream &sourceStream, Diagnostics &diag)
 Parses tag information from the specified stream.
 
void make (std::ostream &targetStream, Diagnostics &diag)
 Writes tag information to the specified stream.
 
- Public Member Functions inherited from TagParser::Tag
virtual ~Tag ()
 Destroys the Tag.
 
std::string toString () const
 Returns a string representation of the tag.
 
virtual TagTextEncoding proposedTextEncoding () const
 Returns the proposed text encoding.
 
virtual std::vector< const TagValue * > values (KnownField field) const
 Returns the values of the specified field.
 
virtual bool setValues (KnownField field, const std::vector< TagValue > &values)
 Assigns the given values to the specified field.
 
const std::string & version () const
 Returns the version of the tag as std::string.
 
std::uint64_t size () const
 Returns the size the tag within the file it is parsed from in bytes.
 
virtual bool supportsTarget () const
 Returns an indication whether a target is supported by the tag.
 
const TagTargettarget () const
 
TagTargettarget ()
 Returns the target of tag.
 
void setTarget (const TagTarget &target)
 Sets the target of tag.
 
virtual TagTargetLevel targetLevel () const
 Returns the name of the current tag target level.
 
std::string_view targetLevelName () const
 Returns the name of the current target level.
 
bool isTargetingLevel (TagTargetLevel tagTargetLevel) const
 Returns whether the tag is targeting the specified tagTargetLevel.
 
std::string targetString () const
 Returns the string representation for the assigned tag target.
 
virtual TagDataType proposedDataType (KnownField field) const
 Returns the proposed data type for the specified field as TagDataType.
 
virtual bool supportsDescription (KnownField field) const
 Returns an indications whether the specified field supports descriptions.
 
virtual bool supportsMimeType (KnownField field) const
 Returns an indications whether the specified field supports mime types.
 
virtual bool supportsMultipleValues (KnownField field) const
 Returns an indications whether the specified field supports multiple values.
 
virtual std::size_t insertValues (const Tag &from, bool overwrite)
 Inserts all compatible values from another Tag.
 

Static Public Attributes

static constexpr TagType tagType = TagType::Id3v1Tag
 
static constexpr std::string_view tagName = "ID3v1 tag"
 

Additional Inherited Members

- Protected Member Functions inherited from TagParser::Tag
 Tag ()
 Constructs a new Tag.
 
- Protected Attributes inherited from TagParser::Tag
std::string m_version
 
std::uint64_t m_size
 
std::unique_ptr< TagPrivatem_p
 
TagTarget m_target
 

Detailed Description

Implementation of TagParser::Tag for ID3v1 tags.

Constructor & Destructor Documentation

◆ Id3v1Tag()

TagParser::Id3v1Tag::Id3v1Tag ( )

Constructs a new tag.

Definition at line 25 of file id3v1tag.cpp.

Member Function Documentation

◆ canEncodingBeUsed()

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

Returns only true for TagTextEncoding::Latin1.

Remarks
The encoding to be used within ID3v1 tags is not standardized but it seems that Latin-1 is the most commonly used character set and hence safest to use. Hence that is the only encoding which can be safely recommended here. Despite that, the Id3v1Tag class is actually able to deal with UTF-8 as well. It will use the BOM to detect and serialize UTF-8.

Reimplemented from TagParser::Tag.

Definition at line 47 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 necessary.

Implements TagParser::Tag.

Definition at line 260 of file id3v1tag.cpp.

◆ fieldCount()

std::size_t TagParser::Id3v1Tag::fieldCount ( ) const
overridevirtual

Returns the number of present fields.

Implements TagParser::Tag.

Definition at line 233 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 201 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 93 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 58 of file id3v1tag.cpp.

◆ removeAllFields()

void TagParser::Id3v1Tag::removeAllFields ( )
overridevirtual

Removes all fields from the tag.

Implements TagParser::Tag.

Definition at line 222 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 166 of file id3v1tag.cpp.

◆ setValueConsideringTypeInfo()

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

Definition at line 196 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 244 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 29 of file id3v1tag.cpp.

◆ typeName()

std::string_view 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 34 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 144 of file id3v1tag.cpp.

Member Data Documentation

◆ tagName

std::string_view TagParser::Id3v1Tag::tagName = "ID3v1 tag"
staticconstexpr

Definition at line 15 of file id3v1tag.h.

◆ tagType

TagType TagParser::Id3v1Tag::tagType = TagType::Id3v1Tag
staticconstexpr

Definition at line 14 of file id3v1tag.h.


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