tagparser/matroska/matroskaattachment.h

94 lines
2.3 KiB
C
Raw Normal View History

2015-04-22 19:22:01 +02:00
#ifndef MEDIA_MATROSKAATTACHMENT_H
#define MEDIA_MATROSKAATTACHMENT_H
2015-09-06 19:57:33 +02:00
#include "../abstractattachment.h"
2015-04-22 19:22:01 +02:00
namespace Media {
class EbmlElement;
class MatroskaAttachment;
2016-08-29 15:43:05 +02:00
class TAG_PARSER_EXPORT MatroskaAttachmentMaker
2015-04-22 19:22:01 +02:00
{
friend class MatroskaAttachment;
public:
void make(std::ostream &stream) const;
const MatroskaAttachment &attachment() const;
uint64 requiredSize() const;
void bufferCurrentAttachments();
2015-04-22 19:22:01 +02:00
private:
MatroskaAttachmentMaker(MatroskaAttachment &attachment);
MatroskaAttachment &m_attachment;
uint64 m_attachedFileElementSize;
uint64 m_totalSize;
};
/*!
* \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.
*/
inline uint64 MatroskaAttachmentMaker::requiredSize() const
{
return m_totalSize;
}
2016-08-29 15:43:05 +02:00
class TAG_PARSER_EXPORT MatroskaAttachment : public AbstractAttachment
2015-04-22 19:22:01 +02:00
{
public:
MatroskaAttachment();
void parse(EbmlElement *attachedFileElement);
MatroskaAttachmentMaker prepareMaking();
void make(std::ostream &stream);
EbmlElement *attachedFileElement() const;
private:
EbmlElement *m_attachedFileElement;
};
/*!
* \brief Constructs a new Matroska attachment.
*/
inline MatroskaAttachment::MatroskaAttachment() :
m_attachedFileElement(nullptr)
{}
/*!
* \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 Media::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()
{
return MatroskaAttachmentMaker(*this);
}
2015-04-22 19:22:01 +02:00
} // namespace Media
#endif // MEDIA_MATROSKAATTACHMENT_H