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);
47 std::uint32_t m_framesSize;
48 std::uint32_t m_requiredSize;
49 std::vector<Id3v2FrameMaker> m_maker;
66 return m_requiredSize;
86 static constexpr std::string_view
tagName =
"ID3v2 tag";
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);
106 std::uint8_t
flags()
const;
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.
typename FieldMapBasedTagTraits< Id3v2Tag >::FieldType::IdentifierType IdentifierType
typename FieldMapBasedTagTraits< Id3v2Tag >::FieldType FieldType
std::vector< const TagValue * > values(const IdentifierType &id) const
The Id3v2Frame class is used by Id3v2Tag to store the fields.
std::uint64_t requiredSize() const
Returns the number of bytes which will be written when making the tag.
void make(std::ostream &stream, std::uint32_t padding, Diagnostics &diag)
Saves the tag (specified when constructing the object) to the specified stream.
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.
void make(std::ostream &targetStream, std::uint32_t padding, Diagnostics &diag)
Writes tag information to the specified stream.
static constexpr TagType tagType
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.
bool supportsMultipleValues(KnownField field) const override
Allows multiple values for some fields.
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.
void setVersion(std::uint8_t majorVersion, std::uint8_t revisionVersion)
Sets the version to the specified majorVersion and the specified revisionVersion.
KnownField internallyGetKnownField(const IdentifierType &id) const
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.
void internallyGetValuesFromField(const FieldType &field, std::vector< const TagValue * > &values) const
Adds additional values as well.
bool internallySetValues(const IdentifierType &id, const std::vector< TagValue > &values)
Uses default implementation for non-text frames and applies special handling to text frames.
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.
TagDataType internallyGetProposedDataType(const std::uint32_t &id) const
std::uint64_t paddingSize() const
Returns the size of the padding between the tag and the first MPEG frame if one is present; otherwise...
Id3v2TagMaker prepareMaking(Diagnostics &diag)
Prepares making.
void ensureTextValuesAreProperlyEncoded() override
Ensures the encoding of all assigned text values is supported by the tag by converting the character ...
static constexpr std::string_view tagName
static constexpr TagTextEncoding defaultTextEncoding
bool supportsDescription(KnownField field) const override
Returns an indications whether the specified field supports descriptions.
IdentifierType internallyGetFieldId(KnownField field) const
bool isExperimental() const
Returns an indication whether the tag is labeled as experimental.
friend class Id3v2TagMaker
void parse(std::istream &sourceStream, const std::uint64_t maximalSize, Diagnostics &diag)
Parses tag information from the specified stream.
#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.
bool operator()(std::uint32_t lhs, std::uint32_t rhs) const
Returns true if lhs goes before rhs; otherwise returns false.