Tag Parser  8.0.1
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
vorbiscommentfield.h
Go to the documentation of this file.
1 #ifndef TAG_PARSER_VORBISCOMMENTFIELD_H
2 #define TAG_PARSER_VORBISCOMMENTFIELD_H
3 
4 #include "../generictagfield.h"
5 
6 namespace IoUtilities {
7 class BinaryReader;
8 class BinaryWriter;
9 } // namespace IoUtilities
10 
11 namespace TagParser {
12 
16 enum class VorbisCommentFlags : byte {
17  None = 0x0,
18  NoSignature = 0x1,
19  NoFramingByte = 0x2,
20  NoCovers = 0x4
21 };
22 
24 {
25  return static_cast<byte>(lhs) & static_cast<byte>(rhs);
26 }
27 
29 {
30  return static_cast<VorbisCommentFlags>(static_cast<byte>(lhs) | static_cast<byte>(rhs));
31 }
32 
33 class VorbisCommentField;
34 class Diagnostics;
35 
40 public:
41  using IdentifierType = std::string;
42  using TypeInfoType = uint32;
43 };
44 
45 class OggIterator;
46 
47 class TAG_PARSER_EXPORT VorbisCommentField : public TagField<VorbisCommentField> {
49 
50 public:
52  VorbisCommentField(const IdentifierType &id, const TagValue &value);
53 
54  void parse(OggIterator &iterator, Diagnostics &diag);
55  void parse(OggIterator &iterator, uint64 &maxSize, Diagnostics &diag);
56  void parse(std::istream &stream, uint64 &maxSize, Diagnostics &diag);
57  bool make(IoUtilities::BinaryWriter &writer, VorbisCommentFlags flags, Diagnostics &diag);
58  bool isAdditionalTypeInfoUsed() const;
59  bool supportsNestedFields() const;
60 
61  static typename std::string fieldIdFromString(const char *idString, std::size_t idStringSize = std::string::npos);
62  static std::string fieldIdToString(const std::string &id);
63 
64 private:
65  void reset();
66  template <class StreamType> void internalParse(StreamType &stream, uint64 &maxSize, Diagnostics &diag);
67 };
68 
73 {
74  return false;
75 }
76 
81 {
82  return false;
83 }
84 
89 inline std::string VorbisCommentField::fieldIdFromString(const char *idString, std::size_t idStringSize)
90 {
91  return idStringSize != std::string::npos ? std::string(idString, idStringSize) : std::string(idString);
92 }
93 
98 inline std::string VorbisCommentField::fieldIdToString(const std::string &id)
99 {
100  return id;
101 }
102 
106 inline void VorbisCommentField::reset()
107 {
108 }
109 
110 } // namespace TagParser
111 
112 #endif // TAG_PARSER_VORBISCOMMENTFIELD_H
VorbisCommentFlags
The VorbisCommentFlags enum specifies flags which controls parsing and making of Vorbis comments...
Defines traits for the specified ImplementationType.
The OggIterator class helps iterating through all segments of an OGG bitstream.
Definition: oggiterator.h:11
constexpr XingHeaderFlags operator &(XingHeaderFlags lhs, XingHeaderFlags rhs)
bool supportsNestedFields() const
Returns whether nested fields are supported.
constexpr XingHeaderFlags operator|(XingHeaderFlags lhs, XingHeaderFlags rhs)
static std::string fieldIdToString(const std::string &id)
Returns the string representation for the specified id.
Contains utility classes helping to read and write streams.
The TagField class is used by FieldMapBasedTag to store the fields.
const IdentifierType & id() const
Returns the id of the current TagField.
bool isAdditionalTypeInfoUsed() const
Returns whether the additional type info is used.
The VorbisCommentField class is used by VorbisComment to store the fields.
The TagValue class wraps values of different types.
Definition: tagvalue.h:65
Contains all classes and functions of the TagInfo library.
Definition: aaccodebook.h:9
static std::string fieldIdFromString(const char *idString, std::size_t idStringSize=std::string::npos)
Converts the specified ID string representation to an actual ID.
#define TAG_PARSER_EXPORT
Marks the symbol to be exported by the tagparser library.
The Diagnostics class is a container for DiagMessage.
Definition: diagnostics.h:156