tagparser/vorbis/vorbiscomment.h

107 lines
3.1 KiB
C
Raw Permalink Normal View History

#ifndef TAG_PARSER_VORBISCOMMENT_H
#define TAG_PARSER_VORBISCOMMENT_H
2015-04-22 19:22:01 +02:00
2015-09-06 19:57:33 +02:00
#include "./vorbiscommentfield.h"
2015-04-22 19:22:01 +02:00
2015-09-06 19:57:33 +02:00
#include "../caseinsensitivecomparer.h"
#include "../fieldbasedtag.h"
2016-03-22 22:52:36 +01:00
#include "../mediaformat.h"
2015-04-22 19:22:01 +02:00
class OverallTests;
namespace TagParser {
2015-04-22 19:22:01 +02:00
class OggIterator;
2016-03-22 22:52:36 +01:00
class VorbisComment;
class Diagnostics;
2016-03-22 22:52:36 +01:00
/*!
* \brief Defines traits for the TagField implementation of the VorbisComment class.
*/
2018-03-07 01:17:50 +01:00
template <> class TAG_PARSER_EXPORT FieldMapBasedTagTraits<VorbisComment> {
public:
2018-07-11 13:19:43 +02:00
using FieldType = VorbisCommentField;
using Compare = CaseInsensitiveStringComparer;
};
2018-03-07 01:17:50 +01:00
class TAG_PARSER_EXPORT VorbisComment : public FieldMapBasedTag<VorbisComment> {
friend class FieldMapBasedTag<VorbisComment>;
friend class ::OverallTests;
2015-04-22 19:22:01 +02:00
public:
VorbisComment();
static constexpr TagType tagType = TagType::VorbisComment;
static constexpr std::string_view tagName = "Vorbis comment";
static constexpr TagTextEncoding defaultTextEncoding = TagTextEncoding::Utf8;
2018-03-07 01:11:42 +01:00
bool canEncodingBeUsed(TagTextEncoding encoding) const override;
2015-04-22 19:22:01 +02:00
using FieldMapBasedTag<VorbisComment>::value;
2018-03-07 01:11:42 +01:00
const TagValue &value(KnownField field) const override;
using FieldMapBasedTag<VorbisComment>::setValue;
2018-03-07 01:11:42 +01:00
bool setValue(KnownField field, const TagValue &value) override;
2015-04-22 19:22:01 +02:00
void parse(OggIterator &iterator, VorbisCommentFlags flags, Diagnostics &diag);
2019-03-13 19:06:42 +01:00
void parse(std::istream &stream, std::uint64_t maxSize, VorbisCommentFlags flags, Diagnostics &diag);
void make(std::ostream &stream, VorbisCommentFlags flags, Diagnostics &diag);
2015-04-22 19:22:01 +02:00
const TagValue &vendor() const;
void setVendor(const TagValue &vendor);
2018-07-13 12:25:00 +02:00
bool supportsMultipleValues(KnownField) const override;
2015-04-22 19:22:01 +02:00
protected:
IdentifierType internallyGetFieldId(KnownField field) const;
KnownField internallyGetKnownField(const IdentifierType &id) const;
2016-05-16 20:56:53 +02:00
private:
2019-03-13 19:06:42 +01:00
template <class StreamType> void internalParse(StreamType &stream, std::uint64_t maxSize, VorbisCommentFlags flags, Diagnostics &diag);
void extendPositionInSetField(std::string_view field, std::string_view totalField, const std::string &diagContext, Diagnostics &diag);
void convertTotalFields(const std::string &diagContext, Diagnostics &diag);
2016-05-16 20:56:53 +02:00
2015-04-22 19:22:01 +02:00
private:
TagValue m_vendor;
2015-04-22 19:22:01 +02:00
};
/*!
* \brief Constructs a new Vorbis comment.
*/
inline VorbisComment::VorbisComment()
2018-03-07 01:17:50 +01:00
{
}
2015-04-22 19:22:01 +02:00
inline bool VorbisComment::canEncodingBeUsed(TagTextEncoding encoding) const
{
return encoding == TagTextEncoding::Utf8;
}
2016-03-22 22:52:36 +01:00
/*!
* \brief Returns the vendor.
2021-07-02 03:00:50 +02:00
* \remarks Also accessible via value(KnownField::Vendor).
2016-03-22 22:52:36 +01:00
*/
inline const TagValue &VorbisComment::vendor() const
2015-04-22 19:22:01 +02:00
{
return m_vendor;
}
2016-03-22 22:52:36 +01:00
/*!
2016-05-14 00:24:01 +02:00
* \brief Sets the vendor.
2021-07-02 03:00:50 +02:00
* \remarks Also accessible via setValue(KnownField::Vendor, vendor).
2016-03-22 22:52:36 +01:00
*/
inline void VorbisComment::setVendor(const TagValue &vendor)
2015-04-22 19:22:01 +02:00
{
m_vendor = vendor;
}
2018-07-13 12:25:00 +02:00
/*!
* \brief Allows multiple values for all fields.
* \remarks "Field names are not required to be unique (occur once) within a comment header."
*/
inline bool VorbisComment::supportsMultipleValues(KnownField) const
{
return true;
}
2018-03-07 01:17:50 +01:00
} // namespace TagParser
2015-04-22 19:22:01 +02:00
#endif // TAG_PARSER_VORBISCOMMENT_H