Tag Parser
9.1.0
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
|
Go to the documentation of this file.
6 #include <c++utilities/conversion/binaryconversion.h>
7 #include <c++utilities/conversion/stringbuilder.h>
31 static const string context(
"parsing \"AttachedFile\"-element");
32 m_attachedFileElement = attachedFileElement;
35 subElement->
parse(diag);
36 switch (subElement->
id()) {
41 diag.emplace_back(DiagLevel::Warning,
"Multiple \"FileDescription\"-elements found. Surplus elements will be ignored.", context);
48 diag.emplace_back(DiagLevel::Warning,
"Multiple \"FileName\"-elements found. Surplus elements will be ignored.", context);
52 if (mimeType().empty()) {
55 diag.emplace_back(DiagLevel::Warning,
"Multiple \"FileMimeType\"-elements found. Surplus elements will be ignored.", context);
60 diag.emplace_back(DiagLevel::Warning,
"Multiple \"FileData\"-elements found. Surplus elements will be ignored.", context);
62 setData(make_unique<StreamDataBlock>(std::bind(&EbmlElement::stream, subElement), subElement->
dataOffset(), ios_base::beg,
68 diag.emplace_back(DiagLevel::Warning,
"Multiple \"FileUID\"-elements found. Surplus elements will be ignored.", context);
80 diag.emplace_back(DiagLevel::Warning,
"Unknown child element \"" % subElement->
idToString() +
"\" found.", context);
93 void MatroskaAttachment::make(std::ostream &stream,
Diagnostics &diag)
95 if (!data() || !data()->size()) {
96 diag.emplace_back(DiagLevel::Critical,
"There is no data assigned.",
"making Matroska attachment");
99 prepareMaking(diag).make(stream, diag);
114 : m_attachment(attachment)
119 if (
auto dataSize = attachment.
data() ? attachment.
data()->
size() : static_cast<istream::pos_type>(0)) {
123 m_attachedFileElementSize
128 for (
auto id : initializer_list<EbmlElement::IdentifierType>{
131 m_attachedFileElementSize += child->totalSize();
149 stream.write(buff, 2);
151 stream.write(buff, len);
161 for (
auto id : initializer_list<EbmlElement::IdentifierType>{
163 if ((child =
attachment().attachedFileElement()->childById(
id, diag))) {
174 stream.write(buff, 2);
176 stream.write(buff, len);
185 for (
auto id : initializer_list<EbmlElement::IdentifierType>{
187 if ((child =
attachment().attachedFileElement()->childById(
id, diag))) {
EbmlElement * attachedFileElement() const
Returns the "AttachedFile"-element which has been specified when the parse() method has been called.
static std::uint8_t calculateUIntegerLength(std::uint64_t integer)
Returns the length of the specified unsigned integer in byte.
void makeBuffer() const
Buffers the data block.
void copyTo(std::ostream &stream) const
Copies the data to the specified stream.
static std::uint8_t calculateSizeDenotationLength(std::uint64_t size)
Returns the length of the size denotation for the specified size in byte.
void bufferCurrentAttachments(Diagnostics &diag)
std::istream::pos_type size() const
Returns the size of the data block.
const std::string & name() const
Returns the (file) name of the attachment.
std::uint64_t readUInteger()
Reads the content of the element as unsigned integer.
void makeBuffer()
Buffers the element (header and data).
std::uint64_t startOffset() const
Returns the start offset in the related stream.
const std::string & mimeType() const
Returns the MIME-type of the attachment.
The Diagnostics class is a container for DiagMessage.
std::uint64_t id() const
Returns the ID of the attachment.
Contains all classes and functions of the TagInfo library.
ImplementationType * nextSibling()
Returns the next sibling of the element.
const IdentifierType & id() const
Returns the element ID.
void parse(Diagnostics &diag)
Parses the header information of the element which is read from the related stream at the start offse...
static void makeSimpleElement(std::ostream &stream, IdentifierType id, std::uint64_t content)
Makes a simple EBML element.
std::string readString()
Reads the content of the element as string.
const MatroskaAttachment & attachment() const
Returns the associated attachment.
void make(std::ostream &stream, Diagnostics &diag) const
Saves the attachment (specified when constructing the object) to the specified stream (makes an "Atta...
Implementation of TagParser::AbstractAttachment for the Matroska container.
ImplementationType * firstChild()
Returns the first child of the element.
static std::uint8_t makeSizeDenotation(std::uint64_t size, char *buff)
Makes the size denotation for the specified size and stores it to buff.
The EbmlElement class helps to parse EBML files such as Matroska files.
const std::unique_ptr< char[]> & buffer()
Returns buffered data.
ImplementationType * childById(const IdentifierType &id, Diagnostics &diag)
Returns the first child with the specified id.
std::string idToString() const
Converts the specified EBML ID to a printable string.
void copyBuffer(std::ostream &targetStream)
Copies buffered data to targetStream.
const std::string & description() const
Returns a description of the attachment.
The exception that is thrown when the data to be parsed or to be made seems invalid and therefore can...
const StreamDataBlock * data() const
Returns a reference to the data of the attachment.
std::uint64_t dataOffset() const
Returns the data offset of the element in the related stream.
void copyEntirely(std::ostream &targetStream, Diagnostics &diag, AbortableProgressFeedback *progress)
Writes the entire element including all childs to the specified targetStream.
std::uint64_t totalSize() const
Returns the total size of the element.
constexpr const TAG_PARSER_EXPORT char * description()