Tag Parser
7.0.3
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
|
#include <tagvalue.h>
Public Member Functions | |
TagValue () | |
Constructs an empty TagValue. More... | |
TagValue (const char *text, std::size_t textSize, TagTextEncoding textEncoding=TagTextEncoding::Latin1, TagTextEncoding convertTo=TagTextEncoding::Unspecified) | |
Constructs a new TagValue holding a copy of the given text. More... | |
TagValue (const std::string &text, TagTextEncoding textEncoding=TagTextEncoding::Latin1, TagTextEncoding convertTo=TagTextEncoding::Unspecified) | |
Constructs a new TagValue holding a copy of the given text. More... | |
TagValue (int value) | |
Constructs a new TagValue holding the given integer value. More... | |
TagValue (const char *data, size_t length, TagDataType type=TagDataType::Undefined, TagTextEncoding encoding=TagTextEncoding::Latin1) | |
TagValue (std::unique_ptr< char[]> &&data, size_t length, TagDataType type=TagDataType::Binary, TagTextEncoding encoding=TagTextEncoding::Latin1) | |
TagValue (const PositionInSet &value) | |
Constructs a new TagValue holding a copy of the given PositionInSet value. More... | |
TagValue (const TagValue &other) | |
Constructs a new TagValue holding a copy of the given TagValue instance. More... | |
TagValue (TagValue &&other)=default | |
~TagValue () | |
Destroys the TagValue. More... | |
TagValue & | operator= (const TagValue &other) |
Assigns the value of another TagValue to the current instance. More... | |
TagValue & | operator= (TagValue &&other)=default |
bool | operator== (const TagValue &other) const |
Returns whether both instances are equal. More... | |
bool | operator!= (const TagValue &other) const |
Returns whether both instances are not equal. More... | |
bool | isEmpty () const |
Returns an indication whether an value is assigned. More... | |
void | clearData () |
Clears the assigned data. More... | |
void | clearMetadata () |
Wipes assigned meta data. More... | |
void | clearDataAndMetadata () |
Wipes assigned data including meta data. More... | |
TagDataType | type () const |
Returns the type of the assigned value. More... | |
std::string | toString (TagTextEncoding encoding=TagTextEncoding::Unspecified) const |
Converts the value of the current TagValue object to its equivalent std::string representation. More... | |
void | toString (std::string &result, TagTextEncoding encoding=TagTextEncoding::Unspecified) const |
Converts the value of the current TagValue object to its equivalent std::string representation. More... | |
std::u16string | toWString (TagTextEncoding encoding=TagTextEncoding::Unspecified) const |
Converts the value of the current TagValue object to its equivalent std::wstring representation. More... | |
void | toWString (std::u16string &result, TagTextEncoding encoding=TagTextEncoding::Unspecified) const |
Converts the value of the current TagValue object to its equivalent std::u16string representation. More... | |
int32 | toInteger () const |
Converts the value of the current TagValue object to its equivalent integer representation. More... | |
int | toStandardGenreIndex () const |
Converts the value of the current TagValue object to its equivalent standard genre index. More... | |
PositionInSet | toPositionInSet () const |
Converts the value of the current TagValue object to its equivalent PositionInSet representation. More... | |
ChronoUtilities::TimeSpan | toTimeSpan () const |
Converts the value of the current TagValue object to its equivalent TimeSpan representation. More... | |
ChronoUtilities::DateTime | toDateTime () const |
Converts the value of the current TagValue object to its equivalent DateTime representation. More... | |
std::size_t | dataSize () const |
Returns the size of the assigned value in bytes. More... | |
char * | dataPointer () |
Returns a pointer to the raw data assigned to the current instance. More... | |
const char * | dataPointer () const |
const std::string & | description () const |
Returns the description. More... | |
void | setDescription (const std::string &value, TagTextEncoding encoding=TagTextEncoding::Latin1) |
Sets the description. More... | |
const std::string & | mimeType () const |
Returns the MIME type. More... | |
void | setMimeType (const std::string &mimeType) |
Sets the MIME type. More... | |
const std::string & | language () const |
Returns the language. More... | |
void | setLanguage (const std::string &language) |
Sets the language. More... | |
bool | isLabeledAsReadonly () const |
Returns an indication whether the value is labeled as read-only. More... | |
void | setReadonly (bool readOnly) |
Sets whether the TagValue is labeled as read-only. More... | |
TagTextEncoding | dataEncoding () const |
Returns the data encoding. More... | |
void | convertDataEncoding (TagTextEncoding encoding) |
Converts the currently assigned text value to the specified encoding. More... | |
void | convertDataEncodingForTag (const Tag *tag) |
Ensures the encoding of the currently assigned text value is supported by the specified tag. More... | |
TagTextEncoding | descriptionEncoding () const |
Returns the description encoding. More... | |
void | assignText (const char *text, std::size_t textSize, TagTextEncoding textEncoding=TagTextEncoding::Latin1, TagTextEncoding convertTo=TagTextEncoding::Unspecified) |
Assigns a copy of the given text. More... | |
void | assignText (const std::string &text, TagTextEncoding textEncoding=TagTextEncoding::Latin1, TagTextEncoding convertTo=TagTextEncoding::Unspecified) |
Assigns a copy of the given text. More... | |
void | assignInteger (int value) |
Assigns the given integer value. More... | |
void | assignStandardGenreIndex (int index) |
Assigns the given standard genre index to be assigned. More... | |
void | assignData (const char *data, size_t length, TagDataType type=TagDataType::Binary, TagTextEncoding encoding=TagTextEncoding::Latin1) |
Assigns a copy of the given data. More... | |
void | assignData (std::unique_ptr< char[]> &&data, size_t length, TagDataType type=TagDataType::Binary, TagTextEncoding encoding=TagTextEncoding::Latin1) |
Assigns the given data. More... | |
void | assignPosition (PositionInSet value) |
Assigns the given PositionInSet value. More... | |
void | assignTimeSpan (ChronoUtilities::TimeSpan value) |
Assigns the given TimeSpan value. More... | |
void | assignDateTime (ChronoUtilities::DateTime value) |
Assigns the given DateTime value. More... | |
Static Public Member Functions | |
static const TagValue & | empty () |
Returns an empty TagValue. More... | |
static void | stripBom (const char *&text, size_t &length, TagTextEncoding encoding) |
Strips the byte order mask from the specified text. More... | |
static void | ensureHostByteOrder (std::u16string &u16str, TagTextEncoding currentEncoding) |
Ensures the byte-order of the specified UTF-16 string matches the byte-order of the machine. More... | |
Definition at line 63 of file tagvalue.h.
|
inline |
Constructs an empty TagValue.
Definition at line 149 of file tagvalue.h.
|
inline |
Constructs a new TagValue holding a copy of the given text.
text | Specifies the text to be assigned. |
textSize | Specifies the size of text. (The actual number of bytes, not the number of characters.) |
textEncoding | Specifies the encoding of the given text. |
convertTo | Specifies the encoding to convert text to; set to TagTextEncoding::Unspecified to use textEncoding without any character set conversions. |
Throws | a ConversionException if the conversion the specified character set fails. |
Definition at line 175 of file tagvalue.h.
|
inline |
Constructs a new TagValue holding a copy of the given text.
text | Specifies the text to be assigned. |
textEncoding | Specifies the encoding of the given text. |
convertTo | Specifies the encoding to convert text to; set to TagTextEncoding::Unspecified to use textEncoding without any character set conversions. |
Throws | a ConversionException if the conversion the specified character set fails. |
Definition at line 191 of file tagvalue.h.
|
inline |
Constructs a new TagValue holding the given integer value.
Definition at line 201 of file tagvalue.h.
TagParser::TagValue::TagValue | ( | const char * | data, |
size_t | length, | ||
TagDataType | type = TagDataType::Undefined , |
||
TagTextEncoding | encoding = TagTextEncoding::Latin1 |
||
) |
TagParser::TagValue::TagValue | ( | std::unique_ptr< char[]> && | data, |
size_t | length, | ||
TagDataType | type = TagDataType::Binary , |
||
TagTextEncoding | encoding = TagTextEncoding::Latin1 |
||
) |
|
inline |
Constructs a new TagValue holding a copy of the given PositionInSet value.
value | Specifies the PositionInSet. |
Definition at line 260 of file tagvalue.h.
TagParser::TagValue::TagValue | ( | const TagValue & | other | ) |
Constructs a new TagValue holding a copy of the given TagValue instance.
other | Specifies another TagValue instance. |
Definition at line 31 of file tagvalue.cpp.
|
default |
|
inline |
Destroys the TagValue.
Definition at line 161 of file tagvalue.h.
void TagParser::TagValue::assignData | ( | const char * | data, |
size_t | length, | ||
TagDataType | type = TagDataType::Binary , |
||
TagTextEncoding | encoding = TagTextEncoding::Latin1 |
||
) |
Assigns a copy of the given data.
data | Specifies the data to be assigned. |
length | Specifies the length of the data. |
type | Specifies the type of the data as TagDataType. |
encoding | Specifies the encoding of the data as TagTextEncoding. The encoding will only be considered if a text is assigned. |
Definition at line 620 of file tagvalue.cpp.
void TagParser::TagValue::assignData | ( | std::unique_ptr< char[]> && | data, |
size_t | length, | ||
TagDataType | type = TagDataType::Binary , |
||
TagTextEncoding | encoding = TagTextEncoding::Latin1 |
||
) |
Assigns the given data.
Takes ownership.
The specified data is not copied. It is moved.
data | Specifies the data to be assigned. |
length | Specifies the length of the data. |
type | Specifies the type of the data as TagDataType. |
encoding | Specifies the encoding of the data as TagTextEncoding. The encoding will only be considered if a text is assigned. |
Definition at line 650 of file tagvalue.cpp.
|
inline |
Assigns the given DateTime value.
Definition at line 312 of file tagvalue.h.
void TagParser::TagValue::assignInteger | ( | int | value | ) |
Assigns the given integer value.
value | Specifies the integer to be assigned. |
Definition at line 603 of file tagvalue.cpp.
|
inline |
Assigns the given PositionInSet value.
Definition at line 291 of file tagvalue.h.
|
inline |
Assigns the given standard genre index to be assigned.
index | Specifies the index to be assigned. |
Definition at line 322 of file tagvalue.h.
void TagParser::TagValue::assignText | ( | const char * | text, |
std::size_t | textSize, | ||
TagTextEncoding | textEncoding = TagTextEncoding::Latin1 , |
||
TagTextEncoding | convertTo = TagTextEncoding::Unspecified |
||
) |
Assigns a copy of the given text.
text | Specifies the text to be assigned. |
textSize | Specifies the size of text. (The actual number of bytes, not the number of characters.) |
textEncoding | Specifies the encoding of the given text. |
convertTo | Specifies the encoding to convert text to; set to TagTextEncoding::Unspecified to use textEncoding without any character set conversions. |
Throws | a ConversionException if the conversion the specified character set fails. |
Definition at line 552 of file tagvalue.cpp.
|
inline |
Assigns a copy of the given text.
text | Specifies the text to be assigned. |
textEncoding | Specifies the encoding of the given text. |
convertTo | Specifies the encoding to convert text to; set to TagTextEncoding::Unspecified to use textEncoding without any character set conversions. |
Throws | a ConversionException if the conversion the specified character set fails. |
Definition at line 283 of file tagvalue.h.
|
inline |
Assigns the given TimeSpan value.
Definition at line 304 of file tagvalue.h.
|
inline |
Clears the assigned data.
Definition at line 378 of file tagvalue.h.
|
inline |
Wipes assigned data including meta data.
Definition at line 389 of file tagvalue.h.
void TagParser::TagValue::clearMetadata | ( | ) |
Wipes assigned meta data.
Definition at line 132 of file tagvalue.cpp.
void TagParser::TagValue::convertDataEncoding | ( | TagTextEncoding | encoding | ) |
Converts the currently assigned text value to the specified encoding.
Throws | ConversionUtilities::ConversionException() if the conversion fails. |
Definition at line 341 of file tagvalue.cpp.
void TagParser::TagValue::convertDataEncodingForTag | ( | const Tag * | tag | ) |
Ensures the encoding of the currently assigned text value is supported by the specified tag.
Definition at line 383 of file tagvalue.cpp.
|
inline |
Returns the data encoding.
Definition at line 518 of file tagvalue.h.
|
inline |
Returns a pointer to the raw data assigned to the current instance.
Definition at line 410 of file tagvalue.h.
|
inline |
Definition at line 415 of file tagvalue.h.
|
inline |
Returns the size of the assigned value in bytes.
Definition at line 399 of file tagvalue.h.
|
inline |
Returns the description.
Definition at line 426 of file tagvalue.h.
|
inline |
Returns the description encoding.
Definition at line 528 of file tagvalue.h.
|
static |
Returns an empty TagValue.
Definition at line 710 of file tagvalue.cpp.
|
static |
Ensures the byte-order of the specified UTF-16 string matches the byte-order of the machine.
Definition at line 690 of file tagvalue.cpp.
|
inline |
Returns an indication whether an value is assigned.
Definition at line 367 of file tagvalue.h.
|
inline |
Returns an indication whether the value is labeled as read-only.
Definition at line 495 of file tagvalue.h.
|
inline |
Returns the language.
Definition at line 471 of file tagvalue.h.
|
inline |
Returns the MIME type.
Definition at line 450 of file tagvalue.h.
|
inline |
Returns whether both instances are not equal.
Definition at line 269 of file tagvalue.h.
Assigns the value of another TagValue to the current instance.
Definition at line 50 of file tagvalue.cpp.
bool TagParser::TagValue::operator== | ( | const TagValue & | other | ) | const |
Returns whether both instances are equal.
If the data types are not equal, two instances are still considered equal if the string representation is identical. The encoding and meta data must be equal as well if relevant for the data type.
Definition at line 79 of file tagvalue.cpp.
|
inline |
Sets the description.
value | Specifies the description. |
encoding | Specifies the encoding used to provide the description. |
Definition at line 439 of file tagvalue.h.
|
inline |
Sets the language.
value | Specifies the language. |
Definition at line 482 of file tagvalue.h.
|
inline |
Sets the MIME type.
value | Specifies the mime type. |
Definition at line 461 of file tagvalue.h.
|
inline |
Sets whether the TagValue is labeled as read-only.
Definition at line 508 of file tagvalue.h.
|
static |
Strips the byte order mask from the specified text.
Definition at line 661 of file tagvalue.cpp.
DateTime TagParser::TagValue::toDateTime | ( | ) | const |
Converts the value of the current TagValue object to its equivalent DateTime representation.
Throws | ConversionException on failure. |
Definition at line 291 of file tagvalue.cpp.
int32 TagParser::TagValue::toInteger | ( | ) | const |
Converts the value of the current TagValue object to its equivalent integer representation.
Throws | ConversionException on failure. |
Definition at line 148 of file tagvalue.cpp.
PositionInSet TagParser::TagValue::toPositionInSet | ( | ) | const |
Converts the value of the current TagValue object to its equivalent PositionInSet representation.
Throws | ConversionException on failure. |
Definition at line 225 of file tagvalue.cpp.
int TagParser::TagValue::toStandardGenreIndex | ( | ) | const |
Converts the value of the current TagValue object to its equivalent standard genre index.
Throws | ConversionException on failure. |
Definition at line 183 of file tagvalue.cpp.
|
inline |
Converts the value of the current TagValue object to its equivalent std::string representation.
encoding | Specifies the encoding to to be used; set to TagTextEncoding::Unspecified to use the present encoding without any character set conversion. |
Throws | ConversionException on failure. |
Definition at line 343 of file tagvalue.h.
void TagParser::TagValue::toString | ( | std::string & | result, |
TagTextEncoding | encoding = TagTextEncoding::Unspecified |
||
) | const |
Converts the value of the current TagValue object to its equivalent std::string representation.
result | Specifies the string to store the result. |
encoding | Specifies the encoding to to be used; set to TagTextEncoding::Unspecified to use the present encoding without any character set conversion. |
Throws | ConversionException on failure. |
Definition at line 399 of file tagvalue.cpp.
TimeSpan TagParser::TagValue::toTimeSpan | ( | ) | const |
Converts the value of the current TagValue object to its equivalent TimeSpan representation.
Throws | ConversionException on failure. |
Definition at line 263 of file tagvalue.cpp.
|
inline |
Converts the value of the current TagValue object to its equivalent std::wstring representation.
Throws | ConversionException on failure. |
Definition at line 356 of file tagvalue.h.
void TagParser::TagValue::toWString | ( | std::u16string & | result, |
TagTextEncoding | encoding = TagTextEncoding::Unspecified |
||
) | const |
Converts the value of the current TagValue object to its equivalent std::u16string representation.
Throws | ConversionException on failure. |
Definition at line 475 of file tagvalue.cpp.
|
inline |
Returns the type of the assigned value.
Definition at line 331 of file tagvalue.h.