mirror of
https://github.com/libAthena/athena.git
synced 2025-12-09 21:47:52 +00:00
Add missing takeOwnership behavior
This commit is contained in:
@@ -99,7 +99,7 @@ public:
|
||||
* @param data The buffer to write
|
||||
* @param length The amount to write
|
||||
*/
|
||||
inline void writeBytes(const atInt8* data, atUint64 len) {writeUBytes((atUint8*)data, len);}
|
||||
inline void writeBytes(const void* data, atUint64 len) {writeUBytes((atUint8*)data, len);}
|
||||
|
||||
/** @brief Writes an Int16 to the buffer and advances the buffer.
|
||||
* It also swaps the bytes depending on the platform and Stream settings.
|
||||
|
||||
@@ -23,12 +23,14 @@ class MemoryWriter : public IStreamWriter
|
||||
{
|
||||
public:
|
||||
|
||||
virtual ~MemoryWriter();
|
||||
|
||||
/*! \brief This constructor references an existing buffer to write to in-place.
|
||||
*
|
||||
* \param data The existing buffer
|
||||
* \param length The length of the existing buffer
|
||||
*/
|
||||
explicit MemoryWriter(atUint8* data, atUint64 length);
|
||||
explicit MemoryWriter(atUint8* data, atUint64 length, bool takeOwnership = false);
|
||||
|
||||
/*! \brief Sets the buffers position relative to the specified position.<br />
|
||||
* It seeks relative to the current position by default.
|
||||
@@ -54,23 +56,18 @@ public:
|
||||
|
||||
inline bool isOpen() const {return true;}
|
||||
|
||||
/*! \brief Sets the buffer to the given one, deleting the current one.<br />
|
||||
* <b>BEWARE:</b> As this deletes the current buffer it WILL cause a loss of data
|
||||
* if that was not the intent.<br />
|
||||
* Once you pass the data to setData <b>DO NOT</b> delete the buffer
|
||||
* as Stream now owns the address, this is done to keep memory usage down.
|
||||
/*! \brief Sets the buffer to the given one, deleting the current one if it owns it.<br />
|
||||
* \param data The new buffer.
|
||||
* \param length The length of the new buffer.
|
||||
* \param takeOwnership Whether the Stream now owns the buffer.
|
||||
* \throw IOException
|
||||
*/
|
||||
void setData(atUint8* data, atUint64 length);
|
||||
void setData(atUint8* data, atUint64 length, bool takeOwnership = false);
|
||||
|
||||
|
||||
/*! \brief Returns a copy of the current buffer.<br />
|
||||
* Changes to the copy do not affect the buffer so it's perfectly safe to
|
||||
* directly edit the buffer and use setData to set the new information.<br />
|
||||
* However once you pass the data to setData <b>DO NOT</b> delete the buffer
|
||||
* as Stream now owns the address, this is done to keep memory usage down.
|
||||
* \return Uint8* The copy of the buffer.
|
||||
*/
|
||||
atUint8* data() const;
|
||||
@@ -108,6 +105,7 @@ protected:
|
||||
atUint8* m_data;
|
||||
atUint64 m_length;
|
||||
atUint64 m_position;
|
||||
bool m_bufferOwned;
|
||||
std::string m_filepath; //!< Path to the target file
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user