Add GenericFileElement::copyPreferablyFromBuffer()

This commit is contained in:
Martchus 2017-06-17 00:29:49 +02:00
parent 6741e9ca0f
commit 03383a18b9
1 changed files with 11 additions and 0 deletions

View File

@ -192,6 +192,7 @@ public:
void makeBuffer();
void discardBuffer();
void copyBuffer(std::ostream &targetStream);
void copyPreferablyFromBuffer(std::ostream &targetStream);
const std::unique_ptr<char[]> &buffer();
implementationType *denoteFirstChild(uint32 offset);
@ -845,6 +846,16 @@ inline void GenericFileElement<ImplementationType>::copyBuffer(std::ostream &tar
targetStream.write(m_buffer.get(), totalSize());
}
/*!
* \brief Copies buffered data to \a targetStream if data has been buffered; copies from input stream otherwise.
* \remarks So this is copyBuffer() with a fallback to copyEntirely().
*/
template <class ImplementationType>
inline void GenericFileElement<ImplementationType>::copyPreferablyFromBuffer(std::ostream &targetStream)
{
m_buffer ? copyBuffer(targetStream) : copyEntirely(targetStream);
}
/*!
* \brief Returns buffered data. The returned array is totalSize() bytes long.
* \remarks Data must have been buffered using the makeBuffer() method.