1 #ifndef TAG_PARSER_ID3V2FRAME_H 2 #define TAG_PARSER_ID3V2FRAME_H 6 #include "../generictagfield.h" 7 #include "../tagvalue.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(IoUtilities::BinaryWriter &writer);
28 const std::unique_ptr<char[]> &data()
const;
29 uint32 dataSize()
const;
30 uint32 requiredSize()
const;
37 std::unique_ptr<char[]> m_data;
39 uint32 m_decompressedSize;
40 uint32 m_requiredSize;
72 return m_requiredSize;
89 Id3v2Frame(
const IdentifierType &
id,
const TagValue &value, byte group = 0, uint16 flag = 0);
92 void parse(IoUtilities::BinaryReader &reader, uint32
version, uint32 maximalSize,
Diagnostics &diag);
97 bool isAdditionalTypeInfoUsed()
const;
99 bool hasPaddingReached()
const;
100 std::string frameIdString()
const;
102 void setFlag(uint16 value);
103 uint32 totalSize()
const;
104 uint32 dataSize()
const;
105 bool toDiscardWhenUnknownAndTagIsAltered()
const;
106 bool toDiscardWhenUnknownAndFileIsAltered()
const;
107 bool isReadOnly()
const;
108 bool isCompressed()
const;
109 bool isEncrypted()
const;
110 bool hasGroupInformation()
const;
111 bool isUnsynchronized()
const;
112 bool hasDataLengthIndicator()
const;
114 void setGroup(byte value);
115 uint32 parsedVersion()
const;
116 bool supportsNestedFields()
const;
120 std::tuple<const char *, size_t, const char *> parseSubstring(
122 std::string parseString(
const char *buffer, std::size_t maxSize,
TagTextEncoding &encoding,
bool addWarnings,
Diagnostics &diag);
123 std::u16string parseWideString(
const char *buffer, std::size_t dataSize,
TagTextEncoding &encoding,
bool addWarnings,
Diagnostics &diag);
124 void parseLegacyPicture(
const char *buffer, std::size_t maxSize,
TagValue &tagValue, byte &typeInfo,
Diagnostics &diag);
125 void parsePicture(
const char *buffer, std::size_t maxSize,
TagValue &tagValue, byte &typeInfo,
Diagnostics &diag);
126 void parseComment(
const char *buffer, std::size_t maxSize,
TagValue &tagValue,
Diagnostics &diag);
132 void makeString(std::unique_ptr<
char[]> &buffer, uint32 &bufferSize,
const std::string &value,
TagTextEncoding encoding);
133 void makeEncodingAndData(std::unique_ptr<
char[]> &buffer, uint32 &bufferSize,
TagTextEncoding encoding,
const char *data, std::size_t m_dataSize);
134 void makeLegacyPicture(std::unique_ptr<
char[]> &buffer, uint32 &bufferSize,
const TagValue &picture, byte typeInfo);
135 void makePicture(std::unique_ptr<
char[]> &buffer, uint32 &bufferSize,
const TagValue &picture, byte typeInfo, byte
version);
138 static IdentifierType fieldIdFromString(
const char *idString, std::size_t idStringSize = std::string::npos);
139 static std::string fieldIdToString(IdentifierType
id);
143 uint32 m_parsedVersion;
221 return m_flag & 0x8000;
229 return m_flag & 0x4000;
237 return m_flag & 0x2000;
245 return m_parsedVersion >= 4 ? m_flag & 0x8 : m_flag & 0x80;
254 return m_parsedVersion >= 4 ? m_flag & 0x4 : m_flag & 0x40;
262 return m_parsedVersion >= 4 ? m_flag & 0x40 : m_flag & 0x20;
270 return m_parsedVersion >= 4 ? m_flag & 0x2 :
false;
278 return m_parsedVersion >= 4 ? m_flag & 0x1 :
isCompressed();
303 return m_parsedVersion;
319 switch (idStringSize != std::string::npos ? idStringSize : std::strlen(idString)) {
321 return ConversionUtilities::BE::toUInt24(idString);
323 return ConversionUtilities::BE::toUInt32(idString);
325 throw ConversionUtilities::ConversionException(
"ID3v2 ID must be 3 or 4 chars");
339 #endif // TAG_PARSER_ID3V2FRAME_H uint16 flag() const
Returns the flags.
void setGroup(byte value)
Sets the group information.
bool hasPaddingReached() const
Returns whether the padding has reached.
bool hasGroupInformation() const
Returns whether the frame contains group information.
byte group() const
Returns the group.
bool isReadOnly() const
Returns whether the frame is flagged as read-only.
bool isAdditionalTypeInfoUsed() const
Returns whether the instance uses the additional type info.
const std::unique_ptr< char[]> & data() const
Returns the frame data.
TagFieldTraits< Id3v2Frame >::IdentifierType IdentifierType
uint32 parsedVersion() const
Returns the version of the frame (read when parsing the frame).
static std::string fieldIdToString(IdentifierType id)
Returns the string representation for the specified id.
TAG_PARSER_EXPORT const char * comment()
bool isCompressed() const
Returns whether the frame is compressed.
bool hasDataLengthIndicator() const
Returns whether the frame has a data length indicator.
bool isValid() const
Returns whether the frame is valid.
bool isEmpty() const
Returns an indication whether an value is assigned.
bool supportsNestedFields() const
Returns whether nested fields are supported.
std::string idToString() const
bool isLongId(uint32 id)
Returns an indication whether the specified id is a long frame id.
bool toDiscardWhenUnknownAndTagIsAltered() const
Returns whether the frame is flaged to be discarded when it is unknown and the tag is altered...
bool isEncrypted() const
Returns whether the frame is encrypted.
std::string frameIdString() const
Returns the frame ID as string.
static IdentifierType fieldIdFromString(const char *idString, std::size_t idStringSize=std::string::npos)
Converts the specified ID string representation to an actual ID.
The TagField class is used by FieldMapBasedTag to store the fields.
const Id3v2Frame & field() const
Returns the associated frame.
void setFlag(uint16 value)
Sets the flags.
const IdentifierType & id() const
Returns the id of the current TagField.
uint32 dataSize() const
Returns the size of the array returned by data().
bool isUnsynchronized() const
Returns whether the frame is unsynchronized.
uint32 dataSize() const
Returns the size of the data stored in the frame in bytes.
TagTextEncoding
Specifies the text encoding.
uint32 requiredSize() const
Returns number of bytes which will be written when making the frame.
#define TAG_PARSER_EXPORT
Marks the symbol to be exported by the tagparser library.
TagValue & value()
Returns the value of the current TagField.
uint32 totalSize() const
Returns the total size of the frame in bytes.
bool toDiscardWhenUnknownAndFileIsAltered() const
Returns whether the frame is flaged to be discarded when it is unknown and the file (but NOT the tag)...