Tag Parser: vorbis/vorbiscomment.h Source File

Tag Parser 12.5.2 C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags

Loading...
Searching...
No Matches
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
10class OverallTests;
11
12namespace TagParser {
13
14class OggIterator;
15class VorbisComment;
16class Diagnostics;
17
21 template <> class TAG_PARSER_EXPORT FieldMapBasedTagTraits<VorbisComment> {
22public:
23 using FieldType = VorbisCommentField;
24 using Compare = CaseInsensitiveStringComparer;
25};
26
27 class TAG_PARSER_EXPORT VorbisComment : public FieldMapBasedTag<VorbisComment> {
28 friend class FieldMapBasedTag<VorbisComment>;
29 friend class ::OverallTests;
30
31public:
32 VorbisComment();
33
34 static constexpr TagType tagType = TagType::VorbisComment;
35 static constexpr std::string_view tagName = "Vorbis comment";
36 static constexpr TagTextEncoding defaultTextEncoding = TagTextEncoding::Utf8;
37 bool canEncodingBeUsed(TagTextEncoding encoding) const override;
38
39 using FieldMapBasedTag<VorbisComment>::value;
40 const TagValue &value(KnownField field) const override;
41 using FieldMapBasedTag<VorbisComment>::setValue;
42 bool setValue(KnownField field, const TagValue &value) override;
43
44 void parse(OggIterator &iterator, VorbisCommentFlags flags, Diagnostics &diag);
45 void parse(OggIterator &iterator, VorbisCommentFlags flags, std::uint64_t &padding, Diagnostics &diag);
46 void parse(std::istream &stream, std::uint64_t maxSize, VorbisCommentFlags flags, Diagnostics &diag);
47 void make(std::ostream &stream, VorbisCommentFlags flags, Diagnostics &diag);
48
49 const TagValue &vendor() const;
50 void setVendor(const TagValue &vendor);
51 bool supportsMultipleValues(KnownField) const override;
52
53protected:
54 IdentifierType internallyGetFieldId(KnownField field) const;
55 KnownField internallyGetKnownField(const IdentifierType &id) const;
56
57private:
58 template <class StreamType>
59 void internalParse(StreamType &stream, std::uint64_t maxSize, VorbisCommentFlags flags, std::uint64_t &padding, Diagnostics &diag);
60 void extendPositionInSetField(std::string_view field, std::string_view totalField, const std::string &diagContext, Diagnostics &diag);
61 void convertTotalFields(const std::string &diagContext, Diagnostics &diag);
62
63private:
64 TagValue m_vendor;
65};
66
70 inline VorbisComment::VorbisComment()
71{
72}
73
74 inline bool VorbisComment::canEncodingBeUsed(TagTextEncoding encoding) const
75{
76 return encoding == TagTextEncoding::Utf8;
77}
78
83 inline const TagValue &VorbisComment::vendor() const
84{
85 return m_vendor;
86}
87
92 inline void VorbisComment::setVendor(const TagValue &vendor)
93{
94 m_vendor = vendor;
95}
96
101 inline bool VorbisComment::supportsMultipleValues(KnownField) const
102{
103 return true;
104}
105
106} // namespace TagParser
107
108#endif // TAG_PARSER_VORBISCOMMENT_H
caseinsensitivecomparer.h
OverallTests
The OverallTests class tests reading and writing tags and parsing technical information for all suppo...
Definition overall.h:40
TagParser::Diagnostics
The Diagnostics class is a container for DiagMessage.
Definition diagnostics.h:156
TagParser::FieldMapBasedTagTraits< VorbisComment >::FieldType
VorbisCommentField FieldType
Definition vorbiscomment.h:23
TagParser::FieldMapBasedTagTraits< VorbisComment >::Compare
CaseInsensitiveStringComparer Compare
Definition vorbiscomment.h:24
TagParser::FieldMapBasedTagTraits
Defines traits for the specified ImplementationType.
Definition fieldbasedtag.h:17
TagParser::FieldMapBasedTag< VorbisComment >::IdentifierType
typename FieldMapBasedTagTraits< VorbisComment >::FieldType::IdentifierType IdentifierType
Definition fieldbasedtag.h:35
TagParser::FieldMapBasedTag< VorbisComment >::FieldMapBasedTag
FieldMapBasedTag()
Definition fieldbasedtag.h:100
TagParser::OggIterator
The OggIterator class helps iterating through all segments of an Ogg bitstream.
Definition oggiterator.h:11
TagParser::TagValue
The TagValue class wraps values of different types.
Definition tagvalue.h:147
TagParser::VorbisCommentField
The VorbisCommentField class is used by VorbisComment to store the fields.
Definition vorbiscommentfield.h:46
TagParser::VorbisComment
Implementation of TagParser::Tag for Vorbis comments.
Definition vorbiscomment.h:27
TagParser::VorbisComment::defaultTextEncoding
static constexpr TagTextEncoding defaultTextEncoding
Definition vorbiscomment.h:36
TagParser::VorbisComment::canEncodingBeUsed
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:74
TagParser::VorbisComment::make
void make(std::ostream &stream, VorbisCommentFlags flags, Diagnostics &diag)
Writes tag information to the specified stream.
Definition vorbiscomment.cpp:388
TagParser::VorbisComment::vendor
const TagValue & vendor() const
Returns the vendor.
Definition vorbiscomment.h:83
TagParser::VorbisComment::tagType
static constexpr TagType tagType
Definition vorbiscomment.h:34
TagParser::VorbisComment::parse
void parse(OggIterator &iterator, VorbisCommentFlags flags, Diagnostics &diag)
Parses tag information using the specified Ogg iterator.
Definition vorbiscomment.cpp:334
TagParser::VorbisComment::VorbisComment
VorbisComment()
Constructs a new Vorbis comment.
Definition vorbiscomment.h:70
TagParser::VorbisComment::supportsMultipleValues
bool supportsMultipleValues(KnownField) const override
Allows multiple values for all fields.
Definition vorbiscomment.h:101
TagParser::VorbisComment::internallyGetFieldId
IdentifierType internallyGetFieldId(KnownField field) const
Definition vorbiscomment.cpp:48
TagParser::VorbisComment::setVendor
void setVendor(const TagValue &vendor)
Sets the vendor.
Definition vorbiscomment.h:92
TagParser::VorbisComment::value
const TagValue & value(KnownField field) const override
Returns the value of the specified field.
Definition vorbiscomment.cpp:27
TagParser::VorbisComment::setValue
bool setValue(KnownField field, const TagValue &value) override
Assigns the given value to the specified field.
Definition vorbiscomment.cpp:37
TagParser::VorbisComment::tagName
static constexpr std::string_view tagName
Definition vorbiscomment.h:35
TagParser::VorbisComment::internallyGetKnownField
KnownField internallyGetKnownField(const IdentifierType &id) const
Definition vorbiscomment.cpp:123
fieldbasedtag.h
TAG_PARSER_EXPORT
#define TAG_PARSER_EXPORT
Marks the symbol to be exported by the tagparser library.
Definition global.h:14
mediaformat.h
TagParser
Contains all classes and functions of the TagInfo library.
Definition aaccodebook.h:10
TagParser::KnownField
KnownField
Specifies the field.
Definition tag.h:37
TagParser::TagTextEncoding
TagTextEncoding
Specifies the text encoding.
Definition tagvalue.h:29
TagParser::TagTextEncoding::Utf8
@ Utf8
Definition tagvalue.h:31
TagParser::TagType
TagType
Specifies the tag type.
Definition tagtype.h:11
TagParser::TagType::VorbisComment
@ VorbisComment
Definition tagtype.h:17
TagParser::VorbisCommentFlags
VorbisCommentFlags
The VorbisCommentFlags enum specifies flags which controls parsing and making of Vorbis comments.
Definition vorbiscommentfield.h:18
TagParser::CaseInsensitiveStringComparer
The CaseInsensitiveStringComparer struct defines a method for case-insensivive string comparison (les...
Definition caseinsensitivecomparer.h:30
vorbiscommentfield.h