2018-03-06 23:09:15 +01:00
|
|
|
#ifndef TAG_PARSER_VORBISCOMMENTFIELD_H
|
|
|
|
#define TAG_PARSER_VORBISCOMMENTFIELD_H
|
2015-04-22 19:22:01 +02:00
|
|
|
|
2015-09-06 19:57:33 +02:00
|
|
|
#include "../generictagfield.h"
|
2015-04-22 19:22:01 +02:00
|
|
|
|
2019-06-10 22:49:11 +02:00
|
|
|
namespace CppUtilities {
|
2015-04-22 19:22:01 +02:00
|
|
|
class BinaryReader;
|
|
|
|
class BinaryWriter;
|
2019-06-12 20:40:45 +02:00
|
|
|
} // namespace CppUtilities
|
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
|
|
|
|
2016-05-16 20:56:53 +02:00
|
|
|
/*!
|
|
|
|
* \brief The VorbisCommentFlags enum specifies flags which controls parsing and making of Vorbis comments.
|
|
|
|
*/
|
2019-03-13 19:06:42 +01:00
|
|
|
enum class VorbisCommentFlags : std::uint8_t {
|
2016-05-16 20:56:53 +02:00
|
|
|
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. */
|
|
|
|
};
|
|
|
|
|
2018-04-29 21:14:02 +02:00
|
|
|
constexpr bool operator&(VorbisCommentFlags lhs, VorbisCommentFlags rhs)
|
2016-05-16 20:56:53 +02:00
|
|
|
{
|
2019-03-13 19:06:42 +01:00
|
|
|
return static_cast<std::uint8_t>(lhs) & static_cast<std::uint8_t>(rhs);
|
2016-05-16 20:56:53 +02:00
|
|
|
}
|
|
|
|
|
2018-04-29 21:14:02 +02:00
|
|
|
constexpr VorbisCommentFlags operator|(VorbisCommentFlags lhs, VorbisCommentFlags rhs)
|
2016-05-16 20:56:53 +02:00
|
|
|
{
|
2019-03-13 19:06:42 +01:00
|
|
|
return static_cast<VorbisCommentFlags>(static_cast<std::uint8_t>(lhs) | static_cast<std::uint8_t>(rhs));
|
2016-05-16 20:56:53 +02:00
|
|
|
}
|
|
|
|
|
2015-04-22 19:22:01 +02:00
|
|
|
class VorbisCommentField;
|
2018-03-05 17:49:29 +01:00
|
|
|
class Diagnostics;
|
2015-04-22 19:22:01 +02:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Defines traits for the TagField implementation of the VorbisCommentField class.
|
|
|
|
*/
|
2018-03-07 01:17:50 +01:00
|
|
|
template <> class TAG_PARSER_EXPORT TagFieldTraits<VorbisCommentField> {
|
2015-04-22 19:22:01 +02:00
|
|
|
public:
|
2018-07-11 13:19:43 +02:00
|
|
|
using IdentifierType = std::string;
|
2019-03-13 19:06:42 +01:00
|
|
|
using TypeInfoType = std::uint32_t;
|
2015-04-22 19:22:01 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class OggIterator;
|
|
|
|
|
2018-03-07 01:17:50 +01:00
|
|
|
class TAG_PARSER_EXPORT VorbisCommentField : public TagField<VorbisCommentField> {
|
2015-04-22 19:22:01 +02:00
|
|
|
friend class TagField<VorbisCommentField>;
|
|
|
|
|
|
|
|
public:
|
|
|
|
VorbisCommentField();
|
2017-03-07 17:16:17 +01:00
|
|
|
VorbisCommentField(const IdentifierType &id, const TagValue &value);
|
2015-04-22 19:22:01 +02:00
|
|
|
|
2018-03-05 17:49:29 +01:00
|
|
|
void parse(OggIterator &iterator, Diagnostics &diag);
|
2019-03-13 19:06:42 +01:00
|
|
|
void parse(OggIterator &iterator, std::uint64_t &maxSize, Diagnostics &diag);
|
|
|
|
void parse(std::istream &stream, std::uint64_t &maxSize, Diagnostics &diag);
|
2019-06-10 22:49:11 +02:00
|
|
|
bool make(CppUtilities::BinaryWriter &writer, VorbisCommentFlags flags, Diagnostics &diag);
|
2015-04-22 19:22:01 +02:00
|
|
|
bool isAdditionalTypeInfoUsed() const;
|
|
|
|
bool supportsNestedFields() const;
|
|
|
|
|
2021-01-30 21:53:06 +01:00
|
|
|
static typename std::string fieldIdFromString(std::string_view idString);
|
2017-01-23 00:25:53 +01:00
|
|
|
static std::string fieldIdToString(const std::string &id);
|
|
|
|
|
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, 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;
|
|
|
|
}
|
|
|
|
|
2017-01-23 00:25:53 +01:00
|
|
|
/*!
|
|
|
|
* \brief Converts the specified ID string representation to an actual ID.
|
|
|
|
* \remarks As Vorbis field IDs are plain text the string is just passed.
|
|
|
|
*/
|
2021-01-30 21:53:06 +01:00
|
|
|
inline std::string VorbisCommentField::fieldIdFromString(std::string_view idString)
|
2017-01-23 00:25:53 +01:00
|
|
|
{
|
2021-01-30 21:53:06 +01:00
|
|
|
return std::string(idString);
|
2017-01-23 00:25:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \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;
|
|
|
|
}
|
|
|
|
|
2018-03-07 01:17:50 +01:00
|
|
|
} // namespace TagParser
|
|
|
|
|
2018-03-06 23:09:15 +01:00
|
|
|
#endif // TAG_PARSER_VORBISCOMMENTFIELD_H
|