2018-03-06 23:09:15 +01:00
|
|
|
#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
|
|
|
|
2018-03-06 23:09:15 +01:00
|
|
|
namespace TagParser {
|
2015-04-22 19:22:01 +02:00
|
|
|
|
|
|
|
class OggIterator;
|
2016-03-22 22:52:36 +01:00
|
|
|
class VorbisComment;
|
2018-03-05 17:49:29 +01:00
|
|
|
class Diagnostics;
|
2016-03-22 22:52:36 +01:00
|
|
|
|
2017-03-07 00:02:59 +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> {
|
2017-03-07 00:02:59 +01:00
|
|
|
public:
|
2018-07-11 13:19:43 +02:00
|
|
|
using FieldType = VorbisCommentField;
|
|
|
|
using Compare = CaseInsensitiveStringComparer;
|
2017-03-07 00:02:59 +01:00
|
|
|
};
|
|
|
|
|
2018-03-07 01:17:50 +01:00
|
|
|
class TAG_PARSER_EXPORT VorbisComment : public FieldMapBasedTag<VorbisComment> {
|
2017-03-07 01:52:26 +01:00
|
|
|
friend class FieldMapBasedTag<VorbisComment>;
|
|
|
|
|
2015-04-22 19:22:01 +02:00
|
|
|
public:
|
|
|
|
VorbisComment();
|
|
|
|
|
2017-01-23 00:25:53 +01:00
|
|
|
static constexpr TagType tagType = TagType::VorbisComment;
|
2017-03-07 00:02:59 +01:00
|
|
|
static constexpr const char *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
|
|
|
|
2017-03-07 01:52:26 +01:00
|
|
|
using FieldMapBasedTag<VorbisComment>::value;
|
2018-03-07 01:11:42 +01:00
|
|
|
const TagValue &value(KnownField field) const override;
|
2017-03-07 01:52:26 +01:00
|
|
|
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
|
|
|
|
2018-03-05 17:49:29 +01: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);
|
2018-03-05 17:49:29 +01:00
|
|
|
void make(std::ostream &stream, VorbisCommentFlags flags, Diagnostics &diag);
|
2015-04-22 19:22:01 +02:00
|
|
|
|
2015-07-27 23:13:03 +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
|
|
|
|
2017-03-07 01:52:26 +01:00
|
|
|
protected:
|
2017-03-07 17:16:17 +01:00
|
|
|
IdentifierType internallyGetFieldId(KnownField field) const;
|
|
|
|
KnownField internallyGetKnownField(const IdentifierType &id) const;
|
2017-03-07 01:52:26 +01:00
|
|
|
|
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);
|
2016-05-16 20:56:53 +02:00
|
|
|
|
2015-04-22 19:22:01 +02:00
|
|
|
private:
|
2015-07-27 23:13:03 +02:00
|
|
|
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.
|
|
|
|
* \remarks Also accessable via value(KnownField::Vendor).
|
|
|
|
*/
|
2015-07-27 23:13:03 +02: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.
|
2016-03-22 22:52:36 +01:00
|
|
|
* \remarks Also accessable via setValue(KnownField::Vendor, vendor).
|
|
|
|
*/
|
2015-07-27 23:13:03 +02: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
|
|
|
|
2018-03-06 23:09:15 +01:00
|
|
|
#endif // TAG_PARSER_VORBISCOMMENT_H
|