1#ifndef TAG_PARSER_ID3V2FRAME_H
2#define TAG_PARSER_ID3V2FRAME_H
9#include <c++utilities/conversion/stringconversion.h>
10#include <c++utilities/io/binaryreader.h>
11#include <c++utilities/io/binarywriter.h>
26 void make(CppUtilities::BinaryWriter &writer);
28 const std::unique_ptr<char[]> &data()
const;
29 std::uint32_t dataSize()
const;
30 std::uint32_t requiredSize()
const;
37 std::uint32_t m_frameId;
38 const std::uint8_t m_version;
39 std::unique_ptr<char[]> m_data;
40 std::uint32_t m_dataSize;
41 std::uint32_t m_decompressedSize;
42 std::uint32_t m_requiredSize;
74 return m_requiredSize;
92 Id3v2Frame(
const IdentifierType &
id,
const TagValue &value, std::uint8_t group = 0, std::uint16_t flag = 0);
95 void parse(CppUtilities::BinaryReader &reader, std::uint32_t version, std::uint32_t maximalSize,
Diagnostics &diag);
97 void make(CppUtilities::BinaryWriter &writer, std::uint8_t version,
Diagnostics &diag);
100 const std::vector<TagValue> &additionalValues()
const;
101 std::vector<TagValue> &additionalValues();
102 bool isAdditionalTypeInfoUsed()
const;
103 bool isValid()
const;
104 bool hasPaddingReached()
const;
105 std::uint16_t flag()
const;
106 void setFlag(std::uint16_t value);
107 std::uint32_t totalSize()
const;
108 std::uint32_t dataSize()
const;
109 bool toDiscardWhenUnknownAndTagIsAltered()
const;
110 bool toDiscardWhenUnknownAndFileIsAltered()
const;
111 bool isReadOnly()
const;
112 bool isCompressed()
const;
113 bool isEncrypted()
const;
114 bool hasGroupInformation()
const;
115 bool isUnsynchronized()
const;
116 bool hasDataLengthIndicator()
const;
117 std::uint8_t group()
const;
118 void setGroup(std::uint8_t value);
119 std::uint32_t parsedVersion()
const;
120 bool supportsNestedFields()
const;
124 std::tuple<const char *, std::size_t, const char *> parseSubstring(
126 std::string parseString(
const char *buffer, std::size_t maxSize,
TagTextEncoding &encoding,
bool addWarnings,
Diagnostics &diag);
127 std::u16string parseWideString(
const char *buffer, std::size_t dataSize,
TagTextEncoding &encoding,
bool addWarnings,
Diagnostics &diag);
128 void parseLegacyPicture(
const char *buffer, std::size_t maxSize,
TagValue &tagValue, std::uint8_t &typeInfo,
Diagnostics &diag);
129 void parsePicture(
const char *buffer, std::size_t maxSize,
TagValue &tagValue, std::uint8_t &typeInfo,
Diagnostics &diag);
130 void parseComment(
const char *buffer, std::size_t maxSize,
TagValue &tagValue,
Diagnostics &diag);
134 static std::uint8_t makeTextEncodingByte(
TagTextEncoding textEncoding);
136 static void makeLegacyPicture(
137 std::unique_ptr<
char[]> &buffer, std::uint32_t &bufferSize,
const TagValue &picture, std::uint8_t typeInfo,
Diagnostics &diag);
138 static void makePicture(std::unique_ptr<
char[]> &buffer, std::uint32_t &bufferSize,
const TagValue &picture, std::uint8_t typeInfo,
140 static void makeComment(
141 std::unique_ptr<
char[]> &buffer, std::uint32_t &bufferSize,
const TagValue &comment, std::uint8_t version,
Diagnostics &diag);
143 static IdentifierType fieldIdFromString(std::string_view idString);
144 static std::string fieldIdToString(IdentifierType
id);
147 void internallyClearValue();
148 void internallyClearFurtherData();
149 std::string ignoreAdditionalValuesDiagMsg()
const;
151 std::vector<TagValue> m_additionalValues;
152 std::uint32_t m_parsedVersion;
153 std::uint32_t m_dataSize;
154 std::uint32_t m_totalSize;
155 std::uint16_t m_flag;
156 std::uint8_t m_group;
166 return m_additionalValues;
175 return m_additionalValues;
239 return m_flag & 0x8000;
247 return m_flag & 0x4000;
255 return m_flag & 0x2000;
263 return m_parsedVersion >= 4 ? m_flag & 0x8 : m_flag & 0x80;
272 return m_parsedVersion >= 4 ? m_flag & 0x4 : m_flag & 0x40;
280 return m_parsedVersion >= 4 ? m_flag & 0x40 : m_flag & 0x20;
288 return m_parsedVersion >= 4 ? m_flag & 0x2 :
false;
296 return m_parsedVersion >= 4 ? m_flag & 0x1 :
isCompressed();
321 return m_parsedVersion;
337 switch (idString.size()) {
339 return CppUtilities::BE::toUInt24(idString.data());
341 return CppUtilities::BE::toInt<std::uint32_t>(idString.data());
343 throw CppUtilities::ConversionException(
"ID3v2 ID must be 3 or 4 chars");
The Diagnostics class is a container for DiagMessage.
The Id3v2FrameMaker class helps making ID3v2 frames.
std::uint32_t dataSize() const
Returns the size of the array returned by data().
const std::unique_ptr< char[]> & data() const
Returns the frame data.
std::uint32_t requiredSize() const
Returns number of bytes which will be written when making the frame.
const Id3v2Frame & field() const
Returns the associated frame.
The Id3v2Frame class is used by Id3v2Tag to store the fields.
bool isEncrypted() const
Returns whether the frame is encrypted.
std::uint32_t dataSize() const
Returns the size of the data stored in the frame in bytes.
std::uint32_t parsedVersion() const
Returns the version of the frame (read when parsing the frame).
bool isReadOnly() const
Returns whether the frame is flagged as read-only.
static IdentifierType fieldIdFromString(std::string_view idString)
Converts the specified ID string representation to an actual ID.
bool supportsNestedFields() const
Returns whether nested fields are supported.
bool hasDataLengthIndicator() const
Returns whether the frame has a data length indicator.
const std::vector< TagValue > & additionalValues() const
Returns additional values.
bool toDiscardWhenUnknownAndFileIsAltered() const
Returns whether the frame is flagged to be discarded when it is unknown and the file (but NOT the tag...
bool hasGroupInformation() const
Returns whether the frame contains group information.
bool isAdditionalTypeInfoUsed() const
Returns whether the instance uses the additional type info.
std::uint16_t flag() const
Returns the flags.
void setGroup(std::uint8_t value)
Sets the group information.
bool toDiscardWhenUnknownAndTagIsAltered() const
Returns whether the frame is flagged to be discarded when it is unknown and the tag is altered.
bool isUnsynchronized() const
Returns whether the frame is unsynchronized.
std::uint32_t totalSize() const
Returns the total size of the frame in bytes.
bool isCompressed() const
Returns whether the frame is compressed.
static std::string fieldIdToString(IdentifierType id)
Returns the string representation for the specified id.
bool hasPaddingReached() const
Returns whether the padding has reached.
void setFlag(std::uint16_t value)
Sets the flags.
bool isValid() const
Returns whether the frame is valid.
std::uint8_t group() const
Returns the group.
std::uint32_t IdentifierType
std::uint8_t TypeInfoType
Defines traits for the specified ImplementationType.
The TagField class is used by FieldMapBasedTag to store the fields.
typename TagFieldTraits< Id3v2Frame >::IdentifierType IdentifierType
The TagValue class wraps values of different types.
bool isEmpty() const
Returns whether no or an empty value is assigned.
#define TAG_PARSER_EXPORT
Marks the symbol to be exported by the tagparser library.
constexpr bool isLongId(std::uint32_t id)
Returns an indication whether the specified id is a long frame id.
Contains all classes and functions of the TagInfo library.
TagTextEncoding
Specifies the text encoding.