6 #include <c++utilities/conversion/binaryconversion.h> 7 #include <c++utilities/conversion/stringbuilder.h> 32 static const string context(
"parsing \"AttachedFile\"-element");
33 m_attachedFileElement = attachedFileElement;
36 subElement->
parse(diag);
37 switch (subElement->
id()) {
42 diag.emplace_back(DiagLevel::Warning,
"Multiple \"FileDescription\"-elements found. Surplus elements will be ignored.", context);
49 diag.emplace_back(DiagLevel::Warning,
"Multiple \"FileName\"-elements found. Surplus elements will be ignored.", context);
53 if (mimeType().empty()) {
56 diag.emplace_back(DiagLevel::Warning,
"Multiple \"FileMimeType\"-elements found. Surplus elements will be ignored.", context);
61 diag.emplace_back(DiagLevel::Warning,
"Multiple \"FileData\"-elements found. Surplus elements will be ignored.", context);
63 setData(make_unique<StreamDataBlock>(std::bind(&EbmlElement::stream, subElement), subElement->
dataOffset(), ios_base::beg,
69 diag.emplace_back(DiagLevel::Warning,
"Multiple \"FileUID\"-elements found. Surplus elements will be ignored.", context);
81 diag.emplace_back(DiagLevel::Warning,
"Unknown child element \"" % subElement->
idToString() +
"\" found.", context);
94 void MatroskaAttachment::make(std::ostream &stream,
Diagnostics &diag)
96 if (!data() || !data()->size()) {
97 diag.emplace_back(DiagLevel::Critical,
"There is no data assigned.",
"making Matroska attachment");
100 prepareMaking(diag).make(stream, diag);
115 : m_attachment(attachment)
120 if (
auto dataSize = attachment.
data() ? attachment.
data()->
size() :
static_cast<istream::pos_type
>(0)) {
124 m_attachedFileElementSize
129 for (
auto id : initializer_list<EbmlElement::IdentifierType>{
132 m_attachedFileElementSize += child->totalSize();
150 stream.write(buff, 2);
152 stream.write(buff, len);
162 for (
auto id : initializer_list<EbmlElement::IdentifierType>{
164 if ((child =
attachment().attachedFileElement()->childById(
id, diag))) {
175 stream.write(buff, 2);
177 stream.write(buff, len);
186 for (
auto id : initializer_list<EbmlElement::IdentifierType>{
188 if ((child =
attachment().attachedFileElement()->childById(
id, diag))) {
TAG_PARSER_EXPORT const char * description()
static void makeSimpleElement(std::ostream &stream, IdentifierType id, uint64 content)
Makes a simple EBML element.
void copyEntirely(std::ostream &targetStream, Diagnostics &diag, AbortableProgressFeedback *progress)
Writes the entire element including all childs to the specified targetStream.
const std::string & description() const
Returns a description of the attachment.
void makeBuffer()
Buffers the element (header and data).
const std::unique_ptr< char[]> & buffer()
Returns buffered data.
ImplementationType * nextSibling()
Returns the next sibling of the element.
ImplementationType * firstChild()
Returns the first child of the element.
static byte calculateSizeDenotationLength(uint64 size)
Returns the length of the size denotation for the specified size in byte.
std::string readString()
Reads the content of the element as string.
const MatroskaAttachment & attachment() const
Returns the associated attachment.
void bufferCurrentAttachments(Diagnostics &diag)
uint64 startOffset() const
Returns the start offset in the related stream.
void make(std::ostream &stream, Diagnostics &diag) const
Saves the attachment (specified when constructing the object) to the specified stream (makes an "Atta...
static byte calculateUIntegerLength(uint64 integer)
Returns the length of the specified unsigned integer in byte.
void makeBuffer() const
Buffers the data block.
const StreamDataBlock * data() const
Returns a reference to the data of the attachment.
uint64 totalSize() const
Returns the total size of the element.
std::string idToString() const
Converts the specified EBML ID to a printable string.
uint64 dataOffset() const
Returns the data offset of the element in the related stream.
uint64 id() const
Returns the ID of the attachment.
Contains utility classes helping to read and write streams.
void parse(Diagnostics &diag)
Parses the header information of the element which is read from the related stream at the start offse...
const std::string & name() const
Returns the (file) name of the attachment.
static byte makeSizeDenotation(uint64 size, char *buff)
Makes the size denotation for the specified size and stores it to buff.
uint64 readUInteger()
Reads the content of the element as unsigned integer.
void copyBuffer(std::ostream &targetStream)
Copies buffered data to targetStream.
EbmlElement * attachedFileElement() const
Returns the "AttachedFile"-element which has been specified when the parse() method has been called...
std::istream::pos_type size() const
Returns the size of the data block.
void copyTo(std::ostream &stream) const
Copies the data to the specified stream.
const IdentifierType & id() const
Returns the element ID.
ImplementationType * childById(const IdentifierType &id, Diagnostics &diag)
Returns the first child with the specified id.
const std::string & mimeType() const
Returns the MIME-type of the attachment.