8 #ifndef LT_IO_DYNAMIC_MEM_STREAM_H
9 #define LT_IO_DYNAMIC_MEM_STREAM_H
14 LT_BEGIN_LIZARDTECH_NAMESPACE
32 #if defined(LT_OS_WINCE)
33 typedef void* (__cdecl *
Allocator)(
size_t);
37 typedef void*(*Allocator)(size_t);
39 typedef void*(*Reallocator)(
void*,size_t);
188 LT_END_LIZARDTECH_NAMESPACE
LTIOSeekDir
Stream seek directions.
lt_uint32 LT_STATUS
An integral status code.
unsigned long long int lt_uint64
unsigned 64-bit integer
unsigned char lt_uint8
unsigned 8-bit integer
unsigned int lt_uint32
unsigned 32-bit integer
long long int lt_int64
signed 64-bit integer
holds a memory buffer of variable size
float m_growthRate
the factor of growth of the memory [1-2):
virtual LT_STATUS close()
Initializes the stream.
lt_uint32 m_cur
current position
void * defaultRealloc(void *, size_t)
pointer to buffer
lt_uint32 m_bufferSize
size of buffer as allocated
virtual LT_STATUS seek(lt_int64 offset, LTIOSeekDir origin)
Initializes the stream.
virtual const char * getID() const
pointer to buffer
virtual LT_STATUS initialize(lt_uint32 size=4096, float growthRate=2)
Initializes the stream.
const lt_uint8 * getData() const
Get the underlying buffer.
virtual LT_STATUS open()
Initializes the stream.
virtual LT_STATUS getLastError() const
pointer to buffer
void(* Deallocator)(void *)
bool m_isEOF
pointer to buffer
virtual lt_uint32 read(lt_uint8 *pDest, lt_uint32 numBytes)
Initializes the stream.
LT_STATUS detachAndClose(lt_uint8 *&data)
Detach the underlying buffer from the stream, and closes the stream.
bool grow(lt_uint32 numBytes)
extend size of data buffer if required
virtual lt_int64 tell()
Initializes the stream.
Allocator m_alloc
allocator function
virtual lt_uint32 write(const lt_uint8 *pSrc, lt_uint32 numBytes)
Initializes the stream.
Reallocator m_realloc
reallocator
Allocator getAllocator() const
Returns the allocator function pointer.
virtual bool isOpen()
Initializes the stream.
void *(* Reallocator)(void *, size_t)
lt_uint32 m_userSize
size of buffer as accessible by user
LT_STATUS m_lastError
pointer to buffer
virtual LTIOStreamInf * duplicate()
pointer to buffer
virtual LT_STATUS initialize(lt_uint32 size, Allocator allo, Deallocator deallo, Reallocator reallo=nullptr, float growthRate=2)
Initializes the stream, with custom memory management.
lt_uint32 m_initialSize
initial size of buffer
lt_uint64 size() const
Returns the number of bytes which are in the stream.
virtual ~LTIODynamicMemStream()
void *(* Allocator)(size_t)
Deallocator m_dealloc
deallocator
Deallocator getDeallocator() const
Returns the deallocator function pointer.
virtual bool isEOF()
Initializes the stream.
Reallocator getReallocator() const
Returns the reallocator function pointer.
virtual char * readString(int delimiter)
pointer to buffer
lt_uint8 * m_data
pointer to buffer
Abstract definition of a stream.