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;
39 std::unique_ptr<char[]> m_data;
41 uint32 m_decompressedSize;
42 uint32 m_requiredSize;
74 return m_requiredSize;
95 void parse(IoUtilities::BinaryReader &reader, uint32
version, uint32 maximalSize,
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;
106 void setFlag(uint16 value);
107 uint32 totalSize()
const;
108 uint32 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;
118 void setGroup(byte value);
119 uint32 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, byte &typeInfo,
Diagnostics &diag);
129 void parsePicture(
const char *buffer, std::size_t maxSize,
TagValue &tagValue, byte &typeInfo,
Diagnostics &diag);
130 void parseComment(
const char *buffer, std::size_t maxSize,
TagValue &tagValue,
Diagnostics &diag);
136 static void makeString(std::unique_ptr<
char[]> &buffer, uint32 &bufferSize,
const std::string &value,
TagTextEncoding encoding);
137 static void makeEncodingAndData(
138 std::unique_ptr<
char[]> &buffer, uint32 &bufferSize,
TagTextEncoding encoding,
const char *data, std::size_t m_dataSize);
139 static void makeLegacyPicture(std::unique_ptr<
char[]> &buffer, uint32 &bufferSize,
const TagValue &picture, byte typeInfo);
140 static void makePicture(std::unique_ptr<
char[]> &buffer, uint32 &bufferSize,
const TagValue &picture, byte typeInfo, byte
version);
143 static IdentifierType fieldIdFromString(
const char *idString, std::size_t idStringSize = std::string::npos);
148 std::string ignoreAdditionalValuesDiagMsg()
const;
150 std::vector<TagValue> m_additionalValues;
151 uint32 m_parsedVersion;
165 return m_additionalValues;
174 return m_additionalValues;
238 return m_flag & 0x8000;
246 return m_flag & 0x4000;
254 return m_flag & 0x2000;
262 return m_parsedVersion >= 4 ? m_flag & 0x8 : m_flag & 0x80;
271 return m_parsedVersion >= 4 ? m_flag & 0x4 : m_flag & 0x40;
279 return m_parsedVersion >= 4 ? m_flag & 0x40 : m_flag & 0x20;
287 return m_parsedVersion >= 4 ? m_flag & 0x2 :
false;
295 return m_parsedVersion >= 4 ? m_flag & 0x1 :
isCompressed();
320 return m_parsedVersion;
336 switch (idStringSize != std::string::npos ? idStringSize : std::strlen(idString)) {
338 return ConversionUtilities::BE::toUInt24(idString);
340 return ConversionUtilities::BE::toUInt32(idString);
342 throw ConversionUtilities::ConversionException(
"ID3v2 ID must be 3 or 4 chars");
356 #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.
Defines traits for the specified ImplementationType.
constexpr bool isLongId(uint32 id)
Returns an indication whether the specified id is a long frame id.
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.
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.
const std::vector< TagValue > & additionalValues() const
Returns additional values.
The Id3v2Frame class is used by Id3v2Tag to store the fields.
bool isEmpty() const
Returns an indication whether an value is assigned.
bool supportsNestedFields() const
Returns whether nested fields are supported.
constexpr TAG_PARSER_EXPORT const char * comment()
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.
static IdentifierType fieldIdFromString(const char *idString, std::size_t idStringSize=std::string::npos)
Converts the specified ID string representation to an actual ID.
The Id3v2FrameMaker class helps making ID3v2 frames.
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.
typename TagFieldTraits< ImplementationType >::IdentifierType IdentifierType
const IdentifierType & id() const
Returns the id of the current TagField.
uint32 dataSize() const
Returns the size of the array returned by data().
The TagValue class wraps values of different types.
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.
Contains all classes and functions of the TagInfo library.
#define TAG_PARSER_EXPORT
Marks the symbol to be exported by the tagparser library.
The Diagnostics class is a container for DiagMessage.
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)...