1#ifndef TAG_PARSER_ID3V2TAG_H
2#define TAG_PARSER_ID3V2TAG_H
8#include <c++utilities/misc/flagenumclass.h>
32 bool operator()(std::uint32_t lhs, std::uint32_t rhs)
const;
39 void make(std::ostream &stream, std::uint32_t padding,
Diagnostics &diag);
41 std::uint64_t requiredSize()
const;
47 std::uint32_t m_framesSize;
48 std::uint32_t m_requiredSize;
49 std::vector<Id3v2FrameMaker> m_maker;
66 return m_requiredSize;
85 static constexpr TagType tagType = TagType::Id3v2Tag;
86 static constexpr std::string_view tagName =
"ID3v2 tag";
87 static constexpr TagTextEncoding defaultTextEncoding = TagTextEncoding::Utf16LittleEndian;
90 bool supportsDescription(
KnownField field)
const override;
91 bool supportsMimeType(
KnownField field)
const override;
92 bool supportsMultipleValues(
KnownField field)
const override;
93 void ensureTextValuesAreProperlyEncoded()
override;
95 void parse(std::istream &sourceStream,
const std::uint64_t maximalSize,
Diagnostics &diag);
97 void make(std::ostream &targetStream, std::uint32_t padding,
Diagnostics &diag);
101 std::uint8_t majorVersion()
const;
102 std::uint8_t revisionVersion()
const;
103 void setVersion(std::uint8_t majorVersion, std::uint8_t revisionVersion);
104 bool isVersionSupported()
const;
105 std::uint8_t flags()
const;
106 bool isUnsynchronisationUsed()
const;
107 bool hasExtendedHeader()
const;
108 bool isExperimental()
const;
109 bool hasFooter()
const;
110 std::uint32_t extendedHeaderSize()
const;
111 std::uint64_t paddingSize()
const;
114 IdentifierType internallyGetFieldId(
KnownField field)
const;
115 KnownField internallyGetKnownField(
const IdentifierType &
id)
const;
116 TagDataType internallyGetProposedDataType(
const std::uint32_t &
id)
const;
117 void internallyGetValuesFromField(
const FieldType &field, std::vector<const TagValue *> &values)
const;
118 bool internallySetValues(
const IdentifierType &
id,
const std::vector<TagValue> &values);
121 void convertOldRecordDateFields(
const std::string &diagContext,
Diagnostics &diag);
122 void removeOldRecordDateRelatedFields();
123 void prepareRecordDataForMaking(
const std::string &diagContext,
Diagnostics &diag);
126 std::uint8_t m_majorVersion;
127 std::uint8_t m_revisionVersion;
128 std::uint8_t m_flags;
129 std::uint32_t m_sizeExcludingHeader;
130 std::uint32_t m_extendedHeaderSize;
131 std::uint64_t m_paddingSize;
140 , m_revisionVersion(0)
142 , m_sizeExcludingHeader(0)
143 , m_extendedHeaderSize(0)
182 return m_handlingFlags;
190 m_handlingFlags =
flags;
198 return m_majorVersion;
206 return m_revisionVersion;
217 return m_majorVersion == 2 || m_majorVersion == 3 || m_majorVersion == 4;
233 return m_flags & 0x80;
241 return (m_majorVersion >= 3) && (m_flags & 0x40);
249 return (m_majorVersion >= 3) && (m_flags & 0x20);
257 return (m_majorVersion >= 3) && (m_flags & 0x10);
265 return m_extendedHeaderSize;
274 return m_paddingSize;
The Diagnostics class is a container for DiagMessage.
Defines traits for the specified ImplementationType.
The FieldMapBasedTag provides a generic implementation of Tag which stores the tag fields using std::...
The Id3v2Frame class is used by Id3v2Tag to store the fields.
The Id3v2TagMaker class helps writing ID3v2 tags.
std::uint64_t requiredSize() const
Returns the number of bytes which will be written when making the tag.
const Id3v2Tag & tag() const
Returns the associated tag.
Implementation of TagParser::Tag for ID3v2 tags.
std::uint8_t revisionVersion() const
Returns the revision version if known; otherwise returns 0.
bool hasExtendedHeader() const
Returns an indication whether an extended header is used.
bool isVersionSupported() const
Returns an indication whether the version is supported by the Id3v2Tag class.
void setHandlingFlags(Id3v2HandlingFlags flags)
Sets flags influencing the behavior when parsing/making the ID3v2 tag.
Id3v2HandlingFlags handlingFlags() const
Returns flags influencing the behavior when parsing/making the ID3v2 tag.
bool canEncodingBeUsed(TagTextEncoding encoding) const override
Returns an indication whether the specified encoding can be used to provide string values for the tag...
std::uint8_t flags() const
Returns the flags read from the ID3v2 header.
bool isUnsynchronisationUsed() const
Returns an indication whether unsynchronisation is used.
std::uint32_t extendedHeaderSize() const
Returns the size of the extended header if one is present; otherwise returns 0.
std::uint8_t majorVersion() const
Returns the major version if known; otherwise returns 0.
bool hasFooter() const
Returns an indication whether a footer is present.
bool supportsMimeType(KnownField field) const override
Returns an indications whether the specified field supports mime types.
Id3v2Tag()
Constructs a new tag.
TagTextEncoding proposedTextEncoding() const override
Returns the proposed text encoding.
std::uint64_t paddingSize() const
Returns the size of the padding between the tag and the first MPEG frame if one is present; otherwise...
bool supportsDescription(KnownField field) const override
Returns an indications whether the specified field supports descriptions.
bool isExperimental() const
Returns an indication whether the tag is labeled as experimental.
#define TAG_PARSER_EXPORT
Marks the symbol to be exported by the tagparser library.
Contains all classes and functions of the TagInfo library.
KnownField
Specifies the field.
TagTextEncoding
Specifies the text encoding.
TagType
Specifies the tag type.
Id3v2HandlingFlags
The Id3v2Flags enum specifies flags which controls parsing and making of ID3v2 tags.
@ ConvertRecordDateFields
TagDataType
Specifies the data type.
CPP_UTILITIES_MARK_FLAG_ENUM_CLASS(TagParser, TagParser::TagCreationFlags)
Defines the order which is used to store ID3v2 frames.