mirror of https://github.com/libAthena/athena.git
void-pointer for MemoryReader constructor
This commit is contained in:
parent
8df75c8f23
commit
ca0ff04340
|
@ -31,7 +31,7 @@ public:
|
||||||
* \param length The length of the existing buffer
|
* \param length The length of the existing buffer
|
||||||
* \param takeOwnership Memory will be freed with the reader if set
|
* \param takeOwnership Memory will be freed with the reader if set
|
||||||
*/
|
*/
|
||||||
MemoryReader(const atUint8* data, atUint64 length, bool takeOwnership=false);
|
MemoryReader(const void* data, atUint64 length, bool takeOwnership=false);
|
||||||
|
|
||||||
/*! \brief Sets the buffers position relative to the specified position.<br />
|
/*! \brief Sets the buffers position relative to the specified position.<br />
|
||||||
* It seeks relative to the current position by default.
|
* It seeks relative to the current position by default.
|
||||||
|
@ -85,7 +85,7 @@ public:
|
||||||
atUint64 readUBytesToBuf(void* buf, atUint64 len);
|
atUint64 readUBytesToBuf(void* buf, atUint64 len);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const atUint8* m_data = nullptr;
|
const void* m_data = nullptr;
|
||||||
atUint64 m_length = 0;
|
atUint64 m_length = 0;
|
||||||
atUint64 m_position = 0;
|
atUint64 m_position = 0;
|
||||||
bool m_owns = false;
|
bool m_owns = false;
|
||||||
|
@ -99,7 +99,7 @@ public:
|
||||||
* \param data The existing buffer
|
* \param data The existing buffer
|
||||||
* \param length The length of the existing buffer
|
* \param length The length of the existing buffer
|
||||||
*/
|
*/
|
||||||
MemoryCopyReader(const atUint8* data, atUint64 length);
|
MemoryCopyReader(const void* data, atUint64 length);
|
||||||
|
|
||||||
/*! \brief This constructor creates an instance from a file on disk.
|
/*! \brief This constructor creates an instance from a file on disk.
|
||||||
*
|
*
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace Athena
|
||||||
{
|
{
|
||||||
namespace io
|
namespace io
|
||||||
{
|
{
|
||||||
MemoryReader::MemoryReader(const atUint8* data, atUint64 length, bool takeOwnership)
|
MemoryReader::MemoryReader(const void* data, atUint64 length, bool takeOwnership)
|
||||||
: m_data(data),
|
: m_data(data),
|
||||||
m_length(length),
|
m_length(length),
|
||||||
m_position(0),
|
m_position(0),
|
||||||
|
@ -38,10 +38,10 @@ MemoryReader::MemoryReader(const atUint8* data, atUint64 length, bool takeOwners
|
||||||
MemoryReader::~MemoryReader()
|
MemoryReader::~MemoryReader()
|
||||||
{
|
{
|
||||||
if (m_owns)
|
if (m_owns)
|
||||||
delete[] m_data;
|
delete[] reinterpret_cast<const atUint8*>(m_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
MemoryCopyReader::MemoryCopyReader(const atUint8* data, atUint64 length)
|
MemoryCopyReader::MemoryCopyReader(const void* data, atUint64 length)
|
||||||
: MemoryReader(data, length, false)
|
: MemoryReader(data, length, false)
|
||||||
{
|
{
|
||||||
if (!data)
|
if (!data)
|
||||||
|
@ -138,7 +138,7 @@ atUint64 MemoryReader::readUBytesToBuf(void* buf, atUint64 length)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(buf, (const atUint8*)(m_data + m_position), length);
|
memcpy(buf, reinterpret_cast<const atUint8*>(m_data) + m_position, length);
|
||||||
m_position += length;
|
m_position += length;
|
||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue