fixed buffer being released instead of discarded
This commit is contained in:
parent
fa52b09b68
commit
000eb92506
|
@ -26,7 +26,7 @@ public:
|
||||||
std::istream::pos_type size() const;
|
std::istream::pos_type size() const;
|
||||||
const std::unique_ptr<char[]> &buffer() const;
|
const std::unique_ptr<char[]> &buffer() const;
|
||||||
void makeBuffer() const;
|
void makeBuffer() const;
|
||||||
void releaseBuffer();
|
void discardBuffer();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
StreamDataBlock();
|
StreamDataBlock();
|
||||||
|
@ -80,11 +80,11 @@ inline const std::unique_ptr<char[]> &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
|
class LIB_EXPORT FileDataBlock : public StreamDataBlock
|
||||||
|
|
|
@ -192,7 +192,7 @@ public:
|
||||||
void copyWithoutChilds(std::ostream &targetStream);
|
void copyWithoutChilds(std::ostream &targetStream);
|
||||||
void copyEntirely(std::ostream &targetStream);
|
void copyEntirely(std::ostream &targetStream);
|
||||||
void makeBuffer();
|
void makeBuffer();
|
||||||
void releaseBuffer();
|
void discardBuffer();
|
||||||
void copyBuffer(std::ostream &targetStream);
|
void copyBuffer(std::ostream &targetStream);
|
||||||
const std::unique_ptr<char[]> &buffer();
|
const std::unique_ptr<char[]> &buffer();
|
||||||
implementationType *denoteFirstChild(uint32 offset);
|
implementationType *denoteFirstChild(uint32 offset);
|
||||||
|
@ -816,6 +816,10 @@ void GenericFileElement<ImplementationType>::copyEntirely(std::ostream &targetSt
|
||||||
copyInternal(targetStream, startOffset(), totalSize());
|
copyInternal(targetStream, startOffset(), totalSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Buffers the element (header and data).
|
||||||
|
* \remarks The element must have been parsed.
|
||||||
|
*/
|
||||||
template <class ImplementationType>
|
template <class ImplementationType>
|
||||||
void GenericFileElement<ImplementationType>::makeBuffer()
|
void GenericFileElement<ImplementationType>::makeBuffer()
|
||||||
{
|
{
|
||||||
|
@ -824,18 +828,29 @@ void GenericFileElement<ImplementationType>::makeBuffer()
|
||||||
container().stream().read(m_buffer.get(), totalSize());
|
container().stream().read(m_buffer.get(), totalSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Discards buffered data.
|
||||||
|
*/
|
||||||
template <class ImplementationType>
|
template <class ImplementationType>
|
||||||
inline void GenericFileElement<ImplementationType>::releaseBuffer()
|
inline void GenericFileElement<ImplementationType>::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 <class ImplementationType>
|
template <class ImplementationType>
|
||||||
inline void GenericFileElement<ImplementationType>::copyBuffer(std::ostream &targetStream)
|
inline void GenericFileElement<ImplementationType>::copyBuffer(std::ostream &targetStream)
|
||||||
{
|
{
|
||||||
targetStream.write(m_buffer.get(), totalSize());
|
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 <class ImplementationType>
|
template <class ImplementationType>
|
||||||
inline const std::unique_ptr<char[]> &GenericFileElement<ImplementationType>::buffer()
|
inline const std::unique_ptr<char[]> &GenericFileElement<ImplementationType>::buffer()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue