diff --git a/abstractattachment.h b/abstractattachment.h index 7e9dcf2..5defdd5 100644 --- a/abstractattachment.h +++ b/abstractattachment.h @@ -26,7 +26,7 @@ public: std::istream::pos_type size() const; const std::unique_ptr &buffer() const; void makeBuffer() const; - void releaseBuffer(); + void discardBuffer(); protected: StreamDataBlock(); @@ -80,11 +80,11 @@ inline const std::unique_ptr &StreamDataBlock::buffer() const } /*! - * \brief Releases buffered data. + * \brief Discards buffered data. */ -inline void StreamDataBlock::releaseBuffer() +inline void StreamDataBlock::discardBuffer() { - m_buffer.release(); + m_buffer.reset(); } class LIB_EXPORT FileDataBlock : public StreamDataBlock diff --git a/genericfileelement.h b/genericfileelement.h index d267a0e..d7c59f1 100644 --- a/genericfileelement.h +++ b/genericfileelement.h @@ -192,7 +192,7 @@ public: void copyWithoutChilds(std::ostream &targetStream); void copyEntirely(std::ostream &targetStream); void makeBuffer(); - void releaseBuffer(); + void discardBuffer(); void copyBuffer(std::ostream &targetStream); const std::unique_ptr &buffer(); implementationType *denoteFirstChild(uint32 offset); @@ -816,6 +816,10 @@ void GenericFileElement::copyEntirely(std::ostream &targetSt copyInternal(targetStream, startOffset(), totalSize()); } +/*! + * \brief Buffers the element (header and data). + * \remarks The element must have been parsed. + */ template void GenericFileElement::makeBuffer() { @@ -824,18 +828,29 @@ void GenericFileElement::makeBuffer() container().stream().read(m_buffer.get(), totalSize()); } +/*! + * \brief Discards buffered data. + */ template -inline void GenericFileElement::releaseBuffer() +inline void GenericFileElement::discardBuffer() { - m_buffer.release(); + m_buffer.reset(); } +/*! + * \brief Copies buffered data to \a targetStream. + * \remarks Data must have been buffered using the makeBuffer() method. + */ template inline void GenericFileElement::copyBuffer(std::ostream &targetStream) { targetStream.write(m_buffer.get(), totalSize()); } +/*! + * \brief Returns buffered data. The returned array is totalSize() bytes long. + * \remarks Data must have been buffered using the makeBuffer() method. + */ template inline const std::unique_ptr &GenericFileElement::buffer() {