1 #ifndef TAG_PARSER_TAGVALUE_H 2 #define TAG_PARSER_TAGVALUE_H 6 #include <c++utilities/chrono/datetime.h> 7 #include <c++utilities/chrono/timespan.h> 8 #include <c++utilities/conversion/binaryconversion.h> 9 #include <c++utilities/misc/traits.h> 93 void clearDataAndMetadata();
99 int32 toInteger()
const;
100 int toStandardGenreIndex()
const;
104 std::size_t dataSize()
const;
106 const char *dataPointer()
const;
109 const std::string &mimeType()
const;
110 void setMimeType(
const std::string &mimeType);
111 const std::string &
language()
const;
112 void setLanguage(
const std::string &
language);
113 bool isLabeledAsReadonly()
const;
114 void setReadonly(
bool readOnly);
117 void convertDataEncodingForTag(
const Tag *tag);
125 void assignInteger(
int value);
126 void assignStandardGenreIndex(
int index);
134 static void stripBom(
const char *&text, std::size_t &length,
TagTextEncoding encoding);
135 static void ensureHostByteOrder(std::u16string &u16str,
TagTextEncoding currentEncoding);
136 template <
typename ContainerType,
137 Traits::EnableIf<Traits::IsIteratable<ContainerType>,
138 std::is_same<typename std::add_const<typename std::remove_pointer<typename ContainerType::value_type>::type>::type,
const TagValue>>
143 std::unique_ptr<char[]> m_ptr;
146 std::string m_mimeType;
147 std::string m_language;
151 bool m_labeledAsReadonly;
162 , m_labeledAsReadonly(false)
185 , m_labeledAsReadonly(false)
187 assignText(text, textSize, textEncoding, convertTo);
201 assignText(text, std::strlen(text), textEncoding, convertTo);
215 , m_labeledAsReadonly(false)
241 , m_encoding(encoding)
243 , m_labeledAsReadonly(false)
249 m_ptr = std::make_unique<char[]>(m_size);
250 std::copy(data, data + m_size, m_ptr.get());
269 , m_encoding(encoding)
271 , m_labeledAsReadonly(false)
293 return !(*
this == other);
307 assignText(text.data(), text.size(), textEncoding, convertTo);
391 return m_ptr ==
nullptr || m_size == 0;
464 m_descEncoding = encoding;
517 return m_labeledAsReadonly;
530 m_labeledAsReadonly = readOnly;
550 return m_descEncoding;
558 template <
typename ContainerType,
559 Traits::EnableIf<Traits::IsIteratable<ContainerType>,
560 std::is_same<typename std::add_const<typename std::remove_pointer<typename ContainerType::value_type>::type>::type,
const TagValue>> *>
563 std::vector<std::string> res;
564 res.reserve(values.size());
565 for (
const auto &value : values) {
566 res.emplace_back(Traits::dereferenceMaybe(value).
toString(encoding));
573 #endif // TAG_PARSER_TAGVALUE_H TagTextEncoding dataEncoding() const
Returns the data encoding.
static void stripBom(const char *&text, std::size_t &length, TagTextEncoding encoding)
Strips the byte order mask from the specified text.
The Tag class is used to store, read and write tag information.
TagTextEncoding descriptionEncoding() const
Returns the description encoding.
const std::string & description() const
Returns the description.
void setMimeType(const std::string &mimeType)
Sets the MIME type.
void setReadonly(bool readOnly)
Sets whether the TagValue is labeled as read-only.
std::u16string toWString(TagTextEncoding encoding=TagTextEncoding::Unspecified) const
Converts the value of the current TagValue object to its equivalent std::wstring representation.
bool operator!=(const TagValue &other) const
Returns whether both instances are not equal.
The PositionInSet class describes the position of an element in a set which consists of a certain num...
TagDataType
Specifies the data type.
void clearDataAndMetadata()
Wipes assigned data including meta data.
constexpr bool operator==(byte lhs, FlacMetaDataBlockType type)
constexpr TAG_PARSER_EXPORT const char * language()
bool isEmpty() const
Returns an indication whether an value is assigned.
const std::string & mimeType() const
Returns the MIME type.
std::size_t dataSize() const
Returns the size of the assigned value in bytes.
constexpr bool operator!=(byte lhs, FlacMetaDataBlockType type)
void assignDateTime(ChronoUtilities::DateTime value)
Assigns the given DateTime value.
void clearMetadata()
Wipes assigned meta data.
const std::string & language() const
Returns the language.
void assignPosition(PositionInSet value)
Assigns the given PositionInSet value.
void assignStandardGenreIndex(int index)
Assigns the given standard genre index to be assigned.
~TagValue()
Destroys the TagValue.
TagValue()
Constructs an empty TagValue.
void setLanguage(const std::string &language)
Sets the language.
char * dataPointer()
Returns a pointer to the raw data assigned to the current instance.
constexpr bool isNull() const
Returns an indication whether both the element position and total element count is 0...
TagDataType type() const
Returns the type of the assigned value.
void assignInteger(int value)
Assigns the given integer value.
void assignText(const char *text, std::size_t textSize, TagTextEncoding textEncoding=TagTextEncoding::Latin1, TagTextEncoding convertTo=TagTextEncoding::Unspecified)
Assigns a copy of the given text.
void clearData()
Clears the assigned data.
bool isLabeledAsReadonly() const
Returns an indication whether the value is labeled as read-only.
void setDescription(const std::string &value, TagTextEncoding encoding=TagTextEncoding::Latin1)
Sets the description.
void assignData(const char *data, std::size_t length, TagDataType type=TagDataType::Binary, TagTextEncoding encoding=TagTextEncoding::Latin1)
static std::vector< std::string > toStrings(const ContainerType &values, TagTextEncoding encoding=TagTextEncoding::Utf8)
Converts the specified values to string using the specified encoding.
std::string toString(TagTextEncoding encoding=TagTextEncoding::Unspecified) const
Converts the value of the current TagValue object to its equivalent std::string representation.
void assignTimeSpan(ChronoUtilities::TimeSpan value)
Assigns the given TimeSpan value.
constexpr int characterSize(TagTextEncoding encoding)
Returns the size of one character for the specified encoding in bytes.
The TagValue class wraps values of different types.
constexpr TAG_PARSER_EXPORT const char * description()
TagTextEncoding
Specifies the text encoding.
Contains all classes and functions of the TagInfo library.
#define TAG_PARSER_EXPORT
Marks the symbol to be exported by the tagparser library.