Allow one to disable the automatic handling of ID3v2 record fields
This commit is contained in:
parent
ad6c3baf85
commit
9da53e6d82
|
@ -515,7 +515,9 @@ void Id3v2Tag::parse(istream &stream, const std::uint64_t maximalSize, Diagnosti
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
convertOldRecordDateFields(context, diag);
|
if (m_handlingFlags & Id3v2HandlingFlags::ConvertRecordDateFields) {
|
||||||
|
convertOldRecordDateFields(context, diag);
|
||||||
|
}
|
||||||
|
|
||||||
// check for extended header
|
// check for extended header
|
||||||
if (!hasFooter()) {
|
if (!hasFooter()) {
|
||||||
|
@ -733,7 +735,9 @@ Id3v2TagMaker::Id3v2TagMaker(Id3v2Tag &tag, Diagnostics &diag)
|
||||||
throw VersionNotSupportedException();
|
throw VersionNotSupportedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
tag.prepareRecordDataForMaking(context, diag);
|
if (m_tag.m_handlingFlags & Id3v2HandlingFlags::ConvertRecordDateFields) {
|
||||||
|
tag.prepareRecordDataForMaking(context, diag);
|
||||||
|
}
|
||||||
|
|
||||||
// prepare frames
|
// prepare frames
|
||||||
m_maker.reserve(tag.fields().size());
|
m_maker.reserve(tag.fields().size());
|
||||||
|
|
|
@ -5,10 +5,27 @@
|
||||||
|
|
||||||
#include "../fieldbasedtag.h"
|
#include "../fieldbasedtag.h"
|
||||||
|
|
||||||
|
#include <c++utilities/misc/flagenumclass.h>
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
namespace TagParser {
|
namespace TagParser {
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief The Id3v2Flags enum specifies flags which controls parsing and making of ID3v2 tags.
|
||||||
|
*/
|
||||||
|
enum class Id3v2HandlingFlags : std::uint64_t {
|
||||||
|
None = 0, /**< Regular parsing/making. */
|
||||||
|
ConvertRecordDateFields = (1 << 1), /**< whether record date fields should be converted when parsing/making */
|
||||||
|
Defaults = ConvertRecordDateFields, /**< set of flags considered good defaults */
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace TagParser
|
||||||
|
|
||||||
|
CPP_UTILITIES_MARK_FLAG_ENUM_CLASS(TagParser, TagParser::Id3v2HandlingFlags)
|
||||||
|
|
||||||
|
namespace TagParser {
|
||||||
|
|
||||||
class Id3v2Tag;
|
class Id3v2Tag;
|
||||||
|
|
||||||
struct TAG_PARSER_EXPORT FrameComparer {
|
struct TAG_PARSER_EXPORT FrameComparer {
|
||||||
|
@ -78,6 +95,8 @@ public:
|
||||||
void parse(std::istream &sourceStream, const std::uint64_t maximalSize, Diagnostics &diag);
|
void parse(std::istream &sourceStream, const std::uint64_t maximalSize, Diagnostics &diag);
|
||||||
Id3v2TagMaker prepareMaking(Diagnostics &diag);
|
Id3v2TagMaker prepareMaking(Diagnostics &diag);
|
||||||
void make(std::ostream &targetStream, std::uint32_t padding, Diagnostics &diag);
|
void make(std::ostream &targetStream, std::uint32_t padding, Diagnostics &diag);
|
||||||
|
Id3v2HandlingFlags handlingFlags() const;
|
||||||
|
void setHandlingFlags(Id3v2HandlingFlags flags);
|
||||||
|
|
||||||
std::uint8_t majorVersion() const;
|
std::uint8_t majorVersion() const;
|
||||||
std::uint8_t revisionVersion() const;
|
std::uint8_t revisionVersion() const;
|
||||||
|
@ -110,6 +129,7 @@ private:
|
||||||
std::uint32_t m_sizeExcludingHeader;
|
std::uint32_t m_sizeExcludingHeader;
|
||||||
std::uint32_t m_extendedHeaderSize;
|
std::uint32_t m_extendedHeaderSize;
|
||||||
std::uint64_t m_paddingSize;
|
std::uint64_t m_paddingSize;
|
||||||
|
Id3v2HandlingFlags m_handlingFlags;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -122,6 +142,7 @@ inline Id3v2Tag::Id3v2Tag()
|
||||||
, m_sizeExcludingHeader(0)
|
, m_sizeExcludingHeader(0)
|
||||||
, m_extendedHeaderSize(0)
|
, m_extendedHeaderSize(0)
|
||||||
, m_paddingSize(0)
|
, m_paddingSize(0)
|
||||||
|
, m_handlingFlags(Id3v2HandlingFlags::Defaults)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,6 +174,22 @@ inline bool Id3v2Tag::supportsMimeType(KnownField field) const
|
||||||
return field == KnownField::Cover;
|
return field == KnownField::Cover;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Returns flags influencing the behavior when parsing/making the ID3v2 tag.
|
||||||
|
*/
|
||||||
|
inline Id3v2HandlingFlags Id3v2Tag::handlingFlags() const
|
||||||
|
{
|
||||||
|
return m_handlingFlags;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Sets flags influencing the behavior when parsing/making the ID3v2 tag.
|
||||||
|
*/
|
||||||
|
inline void Id3v2Tag::setHandlingFlags(Id3v2HandlingFlags flags)
|
||||||
|
{
|
||||||
|
m_handlingFlags = flags;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Returns the major version if known; otherwise returns 0.
|
* \brief Returns the major version if known; otherwise returns 0.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue