Tag Parser  6.2.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 MEDIA_VORBISCOMMENT_H
2 #define MEDIA_VORBISCOMMENT_H
3 
4 #include "./vorbiscommentfield.h"
5 
6 #include "../caseinsensitivecomparer.h"
7 #include "../fieldbasedtag.h"
8 #include "../mediaformat.h"
9 
10 namespace Media {
11 
12 class OggIterator;
13 class VorbisComment;
14 
15 class TAG_PARSER_EXPORT VorbisComment : public FieldMapBasedTag<VorbisCommentField, CaseInsensitiveStringComparer>
16 {
17 public:
18  VorbisComment();
19 
20  static constexpr TagType tagType = TagType::VorbisComment;
21  TagType type() const;
22  const char *typeName() const;
23  TagTextEncoding proposedTextEncoding() const;
24  bool canEncodingBeUsed(TagTextEncoding encoding) const;
25 
26  const TagValue &value(KnownField field) const;
27  bool setValue(KnownField field, const TagValue &value);
28  std::string fieldId(KnownField field) const;
29  KnownField knownField(const std::string &id) const;
30 
31  void parse(OggIterator &iterator, VorbisCommentFlags flags = VorbisCommentFlags::None);
32  void parse(std::istream &stream, uint64 maxSize, VorbisCommentFlags flags = VorbisCommentFlags::None);
33  void make(std::ostream &stream, VorbisCommentFlags flags = VorbisCommentFlags::None);
34 
35  const TagValue &vendor() const;
36  void setVendor(const TagValue &vendor);
37 
38 private:
39  template<class StreamType>
40  void internalParse(StreamType &stream, uint64 maxSize, VorbisCommentFlags flags);
41 
42 private:
43  TagValue m_vendor;
44 };
45 
50 {}
51 
53 {
55 }
56 
57 inline const char *VorbisComment::typeName() const
58 {
59  return "Vorbis comment";
60 }
61 
63 {
64  return TagTextEncoding::Utf8;
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 
90 }
91 
92 #endif // MEDIA_VORBISCOMMENT_H
The TagValue class wraps values of different types.
Definition: tagvalue.h:63
bool canEncodingBeUsed(TagTextEncoding encoding) const
Returns an indication whether the specified encoding can be used to provide string values for the tag...
Definition: vorbiscomment.h:67
Implementation of Media::Tag for Vorbis comments.
Definition: vorbiscomment.h:15
KnownField
Specifies the field.
Definition: tag.h:42
TagTextEncoding
Specifies the text encoding.
Definition: tagvalue.h:21
void setVendor(const TagValue &vendor)
Sets the vendor.
Definition: vorbiscomment.h:85
TagTextEncoding proposedTextEncoding() const
Returns the proposed text encoding.
Definition: vorbiscomment.h:62
The FieldMapBasedTag provides a generic implementation of Tag which stores the tag fields using std::...
Definition: fieldbasedtag.h:25
TagType
Specifies the tag type.
Definition: tag.h:21
const TagValue & vendor() const
Returns the vendor.
Definition: vorbiscomment.h:76
TagType type() const
Returns the type of the tag as Media::TagType.
Definition: vorbiscomment.h:52
The OggIterator class helps iterating through all segments of an OGG bitstream.
Definition: oggiterator.h:11
Contains all classes and functions of the TagInfo library.
Definition: exceptions.h:9
const char * typeName() const
Returns the type name of the tag as C-style string.
Definition: vorbiscomment.h:57
VorbisComment()
Constructs a new Vorbis comment.
Definition: vorbiscomment.h:49
#define TAG_PARSER_EXPORT
Marks the symbol to be exported by the tagparser library.
VorbisCommentFlags
The VorbisCommentFlags enum specifies flags which controls parsing and making of Vorbis comments...