tagparser/matroska/matroskaattachment.h

92 lines
2.5 KiB
C
Raw Normal View History

#ifndef TAG_PARSER_MATROSKAATTACHMENT_H
#define TAG_PARSER_MATROSKAATTACHMENT_H
2015-04-22 19:22:01 +02:00
2015-09-06 19:57:33 +02:00
#include "../abstractattachment.h"
2015-04-22 19:22:01 +02:00
namespace TagParser {
2015-04-22 19:22:01 +02:00
class EbmlElement;
class MatroskaAttachment;
2018-03-07 01:17:50 +01:00
class TAG_PARSER_EXPORT MatroskaAttachmentMaker {
2015-04-22 19:22:01 +02:00
friend class MatroskaAttachment;
public:
void make(std::ostream &stream, Diagnostics &diag) const;
2015-04-22 19:22:01 +02:00
const MatroskaAttachment &attachment() const;
2019-03-13 19:06:42 +01:00
std::uint64_t requiredSize() const;
void bufferCurrentAttachments(Diagnostics &diag);
2015-04-22 19:22:01 +02:00
private:
MatroskaAttachmentMaker(MatroskaAttachment &attachment, Diagnostics &diag);
2015-04-22 19:22:01 +02:00
MatroskaAttachment &m_attachment;
2019-03-13 19:06:42 +01:00
std::uint64_t m_attachedFileElementSize;
std::uint64_t m_totalSize;
2015-04-22 19:22:01 +02:00
};
/*!
* \brief Returns the associated attachment.
*/
inline const MatroskaAttachment &MatroskaAttachmentMaker::attachment() const
{
return m_attachment;
}
/*!
* \brief Returns the number of bytes which will be written when making the attachment.
*/
2019-03-13 19:06:42 +01:00
inline std::uint64_t MatroskaAttachmentMaker::requiredSize() const
2015-04-22 19:22:01 +02:00
{
return m_totalSize;
}
class TAG_PARSER_EXPORT MatroskaAttachment final : public AbstractAttachment {
2015-04-22 19:22:01 +02:00
public:
MatroskaAttachment();
void parse(EbmlElement *attachedFileElement, Diagnostics &diag);
MatroskaAttachmentMaker prepareMaking(Diagnostics &diag);
void make(std::ostream &stream, Diagnostics &diag);
2015-04-22 19:22:01 +02:00
EbmlElement *attachedFileElement() const;
private:
EbmlElement *m_attachedFileElement;
};
/*!
* \brief Constructs a new Matroska attachment.
*/
2018-03-07 01:17:50 +01:00
inline MatroskaAttachment::MatroskaAttachment()
: m_attachedFileElement(nullptr)
{
}
2015-04-22 19:22:01 +02:00
/*!
* \brief Returns the "AttachedFile"-element which has been specified when the parse() method has been called.
*/
inline EbmlElement *MatroskaAttachment::attachedFileElement() const
{
return m_attachedFileElement;
}
/*!
* \brief Prepares making.
* \returns Returns a MatroskaAttachmentMaker object which can be used to actually make the attachment.
* \remarks The attachment must NOT be mutated after making is prepared when it is intended to actually
* make the attachment using the make method of the returned object.
* \throws Throws TagParser::Failure or a derived exception when a making error occurs.
*
* This method might be useful when it is necessary to know the size of the attachment before making it.
* \sa make()
*/
inline MatroskaAttachmentMaker MatroskaAttachment::prepareMaking(Diagnostics &diag)
{
return MatroskaAttachmentMaker(*this, diag);
}
2018-03-07 01:17:50 +01:00
} // namespace TagParser
2015-04-22 19:22:01 +02:00
#endif // TAG_PARSER_MATROSKAATTACHMENT_H