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;
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;
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);
105 std::uint16_t
flag()
const;
117 std::uint8_t
group()
const;
124 std::tuple<const char *, std::size_t, const char *>
parseSubstring(
138 static void makePicture(std::unique_ptr<
char[]> &buffer, std::uint32_t &bufferSize,
const TagValue &picture, std::uint8_t
typeInfo,
141 std::unique_ptr<
char[]> &buffer, std::uint32_t &bufferSize,
const TagValue &comment, std::uint8_t version,
Diagnostics &diag);
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.
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.
void make(CppUtilities::BinaryWriter &writer)
Saves the frame (specified when constructing the object) using the specified writer.
The Id3v2Frame class is used by Id3v2Tag to store the fields.
bool isEncrypted() const
Returns whether the frame is encrypted.
static std::size_t makeBom(char *buffer, TagTextEncoding encoding)
Writes the BOM for the specified encoding to the specified buffer.
std::uint32_t dataSize() const
Returns the size of the data stored in the frame in bytes.
static std::uint8_t makeTextEncodingByte(TagTextEncoding textEncoding)
Returns a text encoding byte for the specified textEncoding.
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.
std::string parseString(const char *buffer, std::size_t maxSize, TagTextEncoding &encoding, bool addWarnings, Diagnostics &diag)
Parses a substring from the specified buffer.
void parseBom(const char *buffer, std::size_t maxSize, TagTextEncoding &encoding, Diagnostics &diag)
Parses a byte order mark from the specified buffer.
static void makeComment(std::unique_ptr< char[]> &buffer, std::uint32_t &bufferSize, const TagValue &comment, std::uint8_t version, Diagnostics &diag)
Writes the specified comment to the specified buffer.
static IdentifierType fieldIdFromString(std::string_view idString)
Converts the specified ID string representation to an actual ID.
void parseLegacyPicture(const char *buffer, std::size_t maxSize, TagValue &tagValue, std::uint8_t &typeInfo, Diagnostics &diag)
Parses the ID3v2.2 picture from the specified buffer.
void parsePicture(const char *buffer, std::size_t maxSize, TagValue &tagValue, std::uint8_t &typeInfo, Diagnostics &diag)
Parses the ID3v2.3 picture from the specified buffer.
void parse(CppUtilities::BinaryReader &reader, std::uint32_t version, std::uint32_t maximalSize, Diagnostics &diag)
Parses a frame from the stream read using the specified reader.
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...
std::tuple< const char *, std::size_t, const char * > parseSubstring(const char *buffer, std::size_t maxSize, TagTextEncoding &encoding, bool addWarnings, Diagnostics &diag)
Parses a substring from the specified buffer.
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.
Id3v2Frame()
Constructs a new Id3v2Frame.
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 void makePicture(std::unique_ptr< char[]> &buffer, std::uint32_t &bufferSize, const TagValue &picture, std::uint8_t typeInfo, std::uint8_t version, Diagnostics &diag)
Writes the specified picture to the specified buffer.
static std::string fieldIdToString(IdentifierType id)
Returns the string representation for the specified id.
TagTextEncoding parseTextEncodingByte(std::uint8_t textEncodingByte, Diagnostics &diag)
Returns the text encoding for the specified textEncodingByte.
Id3v2FrameMaker prepareMaking(std::uint8_t version, Diagnostics &diag)
Prepares making.
void parseComment(const char *buffer, std::size_t maxSize, TagValue &tagValue, Diagnostics &diag)
Parses the comment/unsynchronized lyrics from the specified buffer.
static void makeLegacyPicture(std::unique_ptr< char[]> &buffer, std::uint32_t &bufferSize, const TagValue &picture, std::uint8_t typeInfo, Diagnostics &diag)
Writes the specified picture to the specified buffer (ID3v2.2 compatible).
std::u16string parseWideString(const char *buffer, std::size_t dataSize, TagTextEncoding &encoding, bool addWarnings, Diagnostics &diag)
Parses a substring from the specified buffer.
bool hasPaddingReached() const
Returns whether the padding has reached.
void setFlag(std::uint16_t value)
Sets the flags.
void make(CppUtilities::BinaryWriter &writer, std::uint8_t version, Diagnostics &diag)
Writes the frame to a stream using the specified writer and the specified ID3v2 version.
friend class Id3v2FrameMaker
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.
typename TagFieldTraits< Id3v2Frame >::IdentifierType IdentifierType
const TypeInfoType & typeInfo() const
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.