tagparser/vorbis/vorbiscomment.h

89 lines
2.3 KiB
C
Raw Normal View History

2015-04-22 19:22:01 +02:00
#ifndef MEDIA_VORBISCOMMENT_H
#define MEDIA_VORBISCOMMENT_H
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
namespace Media {
class OggIterator;
2016-03-22 22:52:36 +01:00
class VorbisComment;
/*!
* \brief Defines traits for the TagField implementation of the VorbisComment class.
*/
template <>
class TAG_PARSER_EXPORT FieldMapBasedTagTraits<VorbisComment>
{
public:
typedef VorbisComment implementationType;
typedef VorbisCommentField fieldType;
typedef CaseInsensitiveStringComparer compare;
};
class TAG_PARSER_EXPORT VorbisComment : public FieldMapBasedTag<VorbisComment>
2015-04-22 19:22:01 +02:00
{
public:
VorbisComment();
static constexpr TagType tagType = TagType::VorbisComment;
static constexpr const char *tagName = "Vorbis comment";
static constexpr TagTextEncoding defaultTextEncoding = TagTextEncoding::Utf8;
2015-04-22 19:22:01 +02:00
bool canEncodingBeUsed(TagTextEncoding encoding) const;
const TagValue &value(KnownField field) const;
bool setValue(KnownField field, const TagValue &value);
2015-04-22 19:22:01 +02:00
std::string fieldId(KnownField field) const;
KnownField knownField(const std::string &id) const;
2016-05-16 20:56:53 +02:00
void parse(OggIterator &iterator, VorbisCommentFlags flags = VorbisCommentFlags::None);
void parse(std::istream &stream, uint64 maxSize, VorbisCommentFlags flags = VorbisCommentFlags::None);
2016-05-14 00:24:01 +02:00
void make(std::ostream &stream, VorbisCommentFlags flags = VorbisCommentFlags::None);
2015-04-22 19:22:01 +02:00
const TagValue &vendor() const;
void setVendor(const TagValue &vendor);
2015-04-22 19:22:01 +02:00
2016-05-16 20:56:53 +02:00
private:
template<class StreamType>
void internalParse(StreamType &stream, uint64 maxSize, VorbisCommentFlags flags);
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()
{}
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).
*/
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).
*/
inline void VorbisComment::setVendor(const TagValue &vendor)
2015-04-22 19:22:01 +02:00
{
m_vendor = vendor;
}
}
#endif // MEDIA_VORBISCOMMENT_H