tagparser/vorbis/vorbiscommentfield.h

119 lines
3.3 KiB
C
Raw Normal View History

2015-04-22 19:22:01 +02:00
#ifndef MEDIA_VORBISCOMMENTFIELD_H
#define MEDIA_VORBISCOMMENTFIELD_H
2015-09-06 19:57:33 +02:00
#include "../generictagfield.h"
2015-04-22 19:22:01 +02:00
namespace IoUtilities {
class BinaryReader;
class BinaryWriter;
}
namespace Media {
2016-05-16 20:56:53 +02:00
/*!
* \brief The VorbisCommentFlags enum specifies flags which controls parsing and making of Vorbis comments.
*/
enum class VorbisCommentFlags : byte
{
None = 0x0, /**< Regular parsing/making. */
NoSignature = 0x1, /**< Skips the signature when parsing and making. */
NoFramingByte = 0x2, /**< Doesn't expect the framing bit to be present when parsing; does not make the framing bit when making. */
NoCovers = 0x4 /**< Skips all covers when making. */
};
inline bool operator &(VorbisCommentFlags lhs, VorbisCommentFlags rhs)
{
return static_cast<byte>(lhs) & static_cast<byte>(rhs);
}
inline VorbisCommentFlags operator |(VorbisCommentFlags lhs, VorbisCommentFlags rhs)
{
return static_cast<VorbisCommentFlags>(static_cast<byte>(lhs) | static_cast<byte>(rhs));
}
2015-04-22 19:22:01 +02:00
class VorbisCommentField;
class Diagnostics;
2015-04-22 19:22:01 +02:00
/*!
* \brief Defines traits for the TagField implementation of the VorbisCommentField class.
*/
template <>
2016-08-29 15:43:05 +02:00
class TAG_PARSER_EXPORT TagFieldTraits<VorbisCommentField>
2015-04-22 19:22:01 +02:00
{
public:
typedef std::string IdentifierType;
typedef uint32 TypeInfoType;
2015-04-22 19:22:01 +02:00
};
class OggIterator;
class TAG_PARSER_EXPORT VorbisCommentField : public TagField<VorbisCommentField>
2015-04-22 19:22:01 +02:00
{
friend class TagField<VorbisCommentField>;
public:
VorbisCommentField();
VorbisCommentField(const IdentifierType &id, const TagValue &value);
2015-04-22 19:22:01 +02:00
void parse(OggIterator &iterator, Diagnostics &diag);
void parse(OggIterator &iterator, uint64 &maxSize, Diagnostics &diag);
void parse(std::istream &stream, uint64 &maxSize, Diagnostics &diag);
bool make(IoUtilities::BinaryWriter &writer, VorbisCommentFlags flags, Diagnostics &diag);
2015-04-22 19:22:01 +02:00
bool isAdditionalTypeInfoUsed() const;
bool supportsNestedFields() const;
static typename std::string fieldIdFromString(const char *idString, std::size_t idStringSize = std::string::npos);
static std::string fieldIdToString(const std::string &id);
2015-04-22 19:22:01 +02:00
protected:
void cleared();
2016-05-16 20:56:53 +02:00
private:
template<class StreamType>
void internalParse(StreamType &stream, uint64 &maxSize, Diagnostics &diag);
2015-04-22 19:22:01 +02:00
};
/*!
* \brief Returns whether the additional type info is used.
*/
inline bool VorbisCommentField::isAdditionalTypeInfoUsed() const
{
return false;
}
/*!
* \brief Returns whether nested fields are supported.
*/
inline bool VorbisCommentField::supportsNestedFields() const
{
return false;
}
/*!
* \brief Converts the specified ID string representation to an actual ID.
* \remarks As Vorbis field IDs are plain text the string is just passed.
*/
inline std::string VorbisCommentField::fieldIdFromString(const char *idString, std::size_t idStringSize)
{
return idStringSize != std::string::npos ? std::string(idString, idStringSize) : std::string(idString);
}
/*!
* \brief Returns the string representation for the specified \a id.
* \remarks As Vorbis field IDs are plain text the string is just passed.
*/
inline std::string VorbisCommentField::fieldIdToString(const std::string &id)
{
return id;
}
2015-04-22 19:22:01 +02:00
/*!
* \brief Ensures the field is cleared.
*/
inline void VorbisCommentField::cleared()
{}
}
#endif // MEDIA_VORBISCOMMENTFIELD_H