mirror of https://github.com/libAthena/athena.git
parent
1b67cce607
commit
8124d219d9
|
@ -1217,7 +1217,7 @@ protected:
|
||||||
template <typename T>
|
template <typename T>
|
||||||
IStreamReader& operator>>(IStreamReader& lhs, T& rhs)
|
IStreamReader& operator>>(IStreamReader& lhs, T& rhs)
|
||||||
{
|
{
|
||||||
rhs = lhs.readVal<T>(rhs);
|
rhs = lhs.readVal<T>();
|
||||||
return lhs;
|
return lhs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,8 @@ namespace io
|
||||||
*/
|
*/
|
||||||
class MemoryReader : public IStreamReader
|
class MemoryReader : public IStreamReader
|
||||||
{
|
{
|
||||||
|
protected:
|
||||||
|
MemoryReader() = default;
|
||||||
public:
|
public:
|
||||||
virtual ~MemoryReader();
|
virtual ~MemoryReader();
|
||||||
|
|
||||||
|
@ -83,10 +85,10 @@ public:
|
||||||
atUint64 readUBytesToBuf(void* buf, atUint64 len);
|
atUint64 readUBytesToBuf(void* buf, atUint64 len);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const atUint8* m_data;
|
const atUint8* m_data = nullptr;
|
||||||
atUint64 m_length;
|
atUint64 m_length = 0;
|
||||||
atUint64 m_position;
|
atUint64 m_position = 0;
|
||||||
bool m_owns;
|
bool m_owns = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MemoryCopyReader : public MemoryReader
|
class MemoryCopyReader : public MemoryReader
|
||||||
|
@ -104,8 +106,7 @@ public:
|
||||||
* \param filename The file to create the stream from
|
* \param filename The file to create the stream from
|
||||||
*/
|
*/
|
||||||
MemoryCopyReader(const std::string& filename)
|
MemoryCopyReader(const std::string& filename)
|
||||||
: MemoryReader(NULL, 0),
|
: m_filepath(filename)
|
||||||
m_filepath(filename)
|
|
||||||
{loadData();}
|
{loadData();}
|
||||||
|
|
||||||
void setData(const atUint8* data, atUint64 length);
|
void setData(const atUint8* data, atUint64 length);
|
||||||
|
|
|
@ -84,7 +84,7 @@ std::string vsprintf(const char* fmt, va_list list)
|
||||||
int size = 512;
|
int size = 512;
|
||||||
char* buffer = 0;
|
char* buffer = 0;
|
||||||
buffer = new char[size];
|
buffer = new char[size];
|
||||||
int nsize = ::vsnprintf(buffer, size, fmt, list);
|
int nsize = ::vsprintf(buffer, fmt, list);
|
||||||
|
|
||||||
while (size <= nsize)
|
while (size <= nsize)
|
||||||
{
|
{
|
||||||
|
@ -92,7 +92,7 @@ std::string vsprintf(const char* fmt, va_list list)
|
||||||
delete[] buffer;
|
delete[] buffer;
|
||||||
buffer = 0;
|
buffer = 0;
|
||||||
buffer = new char[nsize + 1]; //+1 for /0
|
buffer = new char[nsize + 1]; //+1 for /0
|
||||||
nsize = ::vsnprintf(buffer, size, fmt, list);
|
nsize = ::vsprintf(buffer, fmt, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ret(buffer);
|
std::string ret(buffer);
|
||||||
|
|
Loading…
Reference in New Issue