Tag Parser  10.0.1
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
vorbiscomment.h
Go to the documentation of this file.
1 #ifndef TAG_PARSER_VORBISCOMMENT_H
2 #define TAG_PARSER_VORBISCOMMENT_H
3 
4 #include "./vorbiscommentfield.h"
5 
6 #include "../caseinsensitivecomparer.h"
7 #include "../fieldbasedtag.h"
8 #include "../mediaformat.h"
9 
10 namespace TagParser {
11 
12 class OggIterator;
13 class VorbisComment;
14 class Diagnostics;
15 
20 public:
23 };
24 
25 class TAG_PARSER_EXPORT VorbisComment : public FieldMapBasedTag<VorbisComment> {
26  friend class FieldMapBasedTag<VorbisComment>;
27 
28 public:
29  VorbisComment();
30 
31  static constexpr TagType tagType = TagType::VorbisComment;
32  static constexpr std::string_view tagName = "Vorbis comment";
33  static constexpr TagTextEncoding defaultTextEncoding = TagTextEncoding::Utf8;
34  bool canEncodingBeUsed(TagTextEncoding encoding) const override;
35 
37  const TagValue &value(KnownField field) const override;
39  bool setValue(KnownField field, const TagValue &value) override;
40 
41  void parse(OggIterator &iterator, VorbisCommentFlags flags, Diagnostics &diag);
42  void parse(std::istream &stream, std::uint64_t maxSize, VorbisCommentFlags flags, Diagnostics &diag);
43  void make(std::ostream &stream, VorbisCommentFlags flags, Diagnostics &diag);
44 
45  const TagValue &vendor() const;
46  void setVendor(const TagValue &vendor);
47  bool supportsMultipleValues(KnownField) const override;
48 
49 protected:
50  IdentifierType internallyGetFieldId(KnownField field) const;
51  KnownField internallyGetKnownField(const IdentifierType &id) const;
52 
53 private:
54  template <class StreamType> void internalParse(StreamType &stream, std::uint64_t maxSize, VorbisCommentFlags flags, Diagnostics &diag);
55 
56 private:
57  TagValue m_vendor;
58 };
59 
64 {
65 }
66 
68 {
69  return encoding == TagTextEncoding::Utf8;
70 }
71 
76 inline const TagValue &VorbisComment::vendor() const
77 {
78  return m_vendor;
79 }
80 
85 inline void VorbisComment::setVendor(const TagValue &vendor)
86 {
87  m_vendor = vendor;
88 }
89 
95 {
96  return true;
97 }
98 
99 } // namespace TagParser
100 
101 #endif // TAG_PARSER_VORBISCOMMENT_H
The Diagnostics class is a container for DiagMessage.
Definition: diagnostics.h:156
Defines traits for the specified ImplementationType.
Definition: fieldbasedtag.h:17
The FieldMapBasedTag provides a generic implementation of Tag which stores the tag fields using std::...
Definition: fieldbasedtag.h:31
The OggIterator class helps iterating through all segments of an OGG bitstream.
Definition: oggiterator.h:11
The TagValue class wraps values of different types.
Definition: tagvalue.h:95
The VorbisCommentField class is used by VorbisComment to store the fields.
Implementation of TagParser::Tag for Vorbis comments.
Definition: vorbiscomment.h:25
bool canEncodingBeUsed(TagTextEncoding encoding) const override
Returns an indication whether the specified encoding can be used to provide string values for the tag...
Definition: vorbiscomment.h:67
const TagValue & vendor() const
Returns the vendor.
Definition: vorbiscomment.h:76
VorbisComment()
Constructs a new Vorbis comment.
Definition: vorbiscomment.h:63
bool supportsMultipleValues(KnownField) const override
Allows multiple values for all fields.
Definition: vorbiscomment.h:94
void setVendor(const TagValue &vendor)
Sets the vendor.
Definition: vorbiscomment.h:85
#define TAG_PARSER_EXPORT
Marks the symbol to be exported by the tagparser library.
Contains all classes and functions of the TagInfo library.
Definition: aaccodebook.h:10
KnownField
Specifies the field.
Definition: tag.h:42
TagTextEncoding
Specifies the text encoding.
Definition: tagvalue.h:28
TagType
Specifies the tag type.
Definition: tag.h:20
VorbisCommentFlags
The VorbisCommentFlags enum specifies flags which controls parsing and making of Vorbis comments.
The CaseInsensitiveStringComparer struct defines a method for case-insensivive string comparison (les...