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 bool supportsMultipleValues(IdentifierType
id)
const;
94 void ensureTextValuesAreProperlyEncoded()
override;
96 void parse(std::istream &sourceStream,
const std::uint64_t maximalSize,
Diagnostics &diag);
98 void make(std::ostream &targetStream, std::uint32_t padding,
Diagnostics &diag);
102 std::uint8_t majorVersion()
const;
103 std::uint8_t revisionVersion()
const;
104 void setVersion(std::uint8_t majorVersion, std::uint8_t revisionVersion);
105 bool isVersionSupported()
const;
106 std::uint8_t flags()
const;
107 bool isUnsynchronisationUsed()
const;
108 bool hasExtendedHeader()
const;
109 bool isExperimental()
const;
110 bool hasFooter()
const;
111 std::uint32_t extendedHeaderSize()
const;
112 std::uint64_t paddingSize()
const;
115 IdentifierType internallyGetFieldId(
KnownField field)
const;
116 KnownField internallyGetKnownField(
const IdentifierType &
id)
const;
117 TagDataType internallyGetProposedDataType(
const std::uint32_t &
id)
const;
118 void internallyGetValuesFromField(
const FieldType &field, std::vector<const TagValue *> &values)
const;
119 bool internallySetValues(
const IdentifierType &
id,
const std::vector<TagValue> &values);
122 void convertOldRecordDateFields(
const std::string &diagContext,
Diagnostics &diag);
123 void removeOldRecordDateRelatedFields();
124 void prepareRecordDataForMaking(
const std::string &diagContext,
Diagnostics &diag);
127 std::uint8_t m_majorVersion;
128 std::uint8_t m_revisionVersion;
129 std::uint8_t m_flags;
130 std::uint32_t m_sizeExcludingHeader;
131 std::uint32_t m_extendedHeaderSize;
132 std::uint64_t m_paddingSize;
141 , m_revisionVersion(0)
143 , m_sizeExcludingHeader(0)
144 , m_extendedHeaderSize(0)
183 return m_handlingFlags;
191 m_handlingFlags =
flags;
199 return m_majorVersion;
207 return m_revisionVersion;
218 return m_majorVersion == 2 || m_majorVersion == 3 || m_majorVersion == 4;
234 return m_flags & 0x80;
242 return (m_majorVersion >= 3) && (m_flags & 0x40);
250 return (m_majorVersion >= 3) && (m_flags & 0x20);
258 return (m_majorVersion >= 3) && (m_flags & 0x10);
266 return m_extendedHeaderSize;
275 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.