6#include <c++utilities/conversion/binaryconversion.h>
7#include <c++utilities/conversion/stringbuilder.h>
31 static const string context(
"parsing \"AttachedFile\"-element");
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);
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);
68 diag.emplace_back(
DiagLevel::Warning,
"Multiple \"FileUID\"-elements found. Surplus elements will be ignored.", context);
96 diag.emplace_back(
DiagLevel::Critical,
"There is no data assigned.",
"making Matroska attachment");
114 : m_attachment(attachment)
119 if (
auto dataSize = attachment.
data() ? attachment.
data()->
size() :
static_cast<std::uint64_t
>(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))) {
void setDescription(std::string_view description)
Sets a description of the attachment.
void clear()
Resets the object to its initial state.
const std::string & mimeType() const
Returns the MIME-type of the attachment.
const std::string & description() const
Returns a description of the attachment.
void setData(std::unique_ptr< StreamDataBlock > &&data)
Sets the data for the attachment.
const std::string & name() const
Returns the (file) name of the attachment.
std::uint64_t id() const
Returns the ID of the attachment.
void setName(std::string_view name)
Sets the (file) name of the attachment.
void setId(std::uint64_t id)
Sets the ID of the attachment.
const StreamDataBlock * data() const
Returns a reference to the data of the attachment.
void setMimeType(std::string_view mimeType)
Sets the MIME-type of the attachment.
The Diagnostics class is a container for DiagMessage.
The EbmlElement class helps to parse EBML files such as Matroska files.
static void makeSimpleElement(std::ostream &stream, IdentifierType id, std::uint64_t content)
Makes a simple EBML element.
static std::uint8_t calculateSizeDenotationLength(std::uint64_t size)
Returns the length of the size denotation for the specified size in byte.
std::string idToString() const
Converts the specified EBML ID to a printable string.
std::string readString()
Reads the content of the element as string.
std::uint64_t readUInteger()
Reads the content of the element as unsigned integer.
static std::uint8_t makeSizeDenotation(std::uint64_t size, char *buff)
Makes the size denotation for the specified size and stores it to buff.
static std::uint8_t calculateUIntegerLength(std::uint64_t integer)
Returns the length of the specified unsigned integer in byte.
std::uint64_t startOffset() const
Returns the start offset in the related stream.
void copyEntirely(std::ostream &targetStream, Diagnostics &diag, AbortableProgressFeedback *progress)
Writes the entire element including all children to the specified targetStream.
const std::unique_ptr< char[]> & buffer()
Returns buffered data.
const IdentifierType & id() const
Returns the element ID.
std::iostream & stream()
Returns the related stream.
void copyBuffer(std::ostream &targetStream)
Copies buffered data to targetStream.
ImplementationType * childById(const IdentifierType &id, Diagnostics &diag)
Returns the first child with the specified id.
ImplementationType * nextSibling()
Returns the next sibling of the element.
ImplementationType * firstChild()
Returns the first child of the element.
std::uint64_t totalSize() const
Returns the total size of the element.
void parse(Diagnostics &diag)
Parses the header information of the element which is read from the related stream at the start offse...
std::uint64_t dataOffset() const
Returns the data offset of the element in the related stream.
void makeBuffer()
Buffers the element (header and data).
The exception that is thrown when the data to be parsed or to be made seems invalid and therefore can...
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...
void bufferCurrentAttachments(Diagnostics &diag)
Implementation of TagParser::AbstractAttachment for the Matroska container.
EbmlElement * attachedFileElement() const
Returns the "AttachedFile"-element which has been specified when the parse() method has been called.
void make(std::ostream &stream, Diagnostics &diag)
Writes the attachment to the specified stream (makes an "AttachedFile"-element).
MatroskaAttachmentMaker prepareMaking(Diagnostics &diag)
Prepares making.
void parse(EbmlElement *attachedFileElement, Diagnostics &diag)
Parses attachment from the specified attachedFileElement.
void makeBuffer() const
Buffers the data block.
std::uint64_t size() const
Returns the size of the data block.
void copyTo(std::ostream &stream) const
Copies the data to the specified stream.
Contains all classes and functions of the TagInfo library.