8#include <c++utilities/conversion/binaryconversion.h>
9#include <c++utilities/conversion/stringbuilder.h>
33 static const string context(
"parsing \"AttachedFile\"-element");
37 subElement->
parse(diag);
38 switch (subElement->
id()) {
43 diag.emplace_back(
DiagLevel::Warning,
"Multiple \"FileDescription\"-elements found. Surplus elements will be ignored.", context);
50 diag.emplace_back(
DiagLevel::Warning,
"Multiple \"FileName\"-elements found. Surplus elements will be ignored.", context);
57 diag.emplace_back(
DiagLevel::Warning,
"Multiple \"FileMimeType\"-elements found. Surplus elements will be ignored.", context);
62 diag.emplace_back(
DiagLevel::Warning,
"Multiple \"FileData\"-elements found. Surplus elements will be ignored.", context);
70 diag.emplace_back(
DiagLevel::Warning,
"Multiple \"FileUID\"-elements found. Surplus elements will be ignored.", context);
98 diag.emplace_back(
DiagLevel::Critical,
"There is no data assigned.",
"making Matroska attachment");
116 : m_attachment(attachment)
121 if (
auto dataSize = attachment.
data() ? attachment.
data()->
size() :
static_cast<std::uint64_t
>(0)) {
125 m_attachedFileElementSize
130 for (
auto id : initializer_list<EbmlElement::IdentifierType>{
133 m_attachedFileElementSize += child->totalSize();
151 stream.write(buff, 2);
153 stream.write(buff, len);
163 for (
auto id : initializer_list<EbmlElement::IdentifierType>{
165 if ((child =
attachment().attachedFileElement()->childById(
id, diag))) {
176 stream.write(buff, 2);
178 stream.write(buff, len);
187 for (
auto id : initializer_list<EbmlElement::IdentifierType>{
189 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.
void copyEntirely(TargetStream &targetStream, Diagnostics &diag, AbortableProgressFeedback *progress)
Writes the entire element including all children to the specified targetStream.
void copyBuffer(TargetStream &targetStream)
Copies buffered data to targetStream.
std::uint64_t startOffset() const
Returns the start offset in the related stream.
const std::unique_ptr< char[]> & buffer()
Returns buffered data.
const IdentifierType & id() const
Returns the element ID.
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).
InvalidDataException() noexcept
Constructs a new exception.
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.