MrSID Decode SDK for Raster Reference Manual  9.5.5.5244
LTIODynamicMemStream Class Reference

holds a memory buffer of variable size More...

#include <lt_ioDynamicMemStream.h>

Inheritance diagram for LTIODynamicMemStream:
LTIOStreamInf

Public Member Functions

Initialization functions
virtual LT_STATUS initialize (lt_uint32 size=4096, float growthRate=2)
 Initializes the stream. More...
 
virtual LT_STATUS initialize (lt_uint32 size, Allocator allo, Deallocator deallo, Reallocator reallo=nullptr, float growthRate=2)
 Initializes the stream, with custom memory management. More...
 
virtual bool isEOF ()
 Initializes the stream. More...
 
virtual bool isOpen ()
 Initializes the stream. More...
 
virtual LT_STATUS open ()
 Initializes the stream. More...
 
virtual LT_STATUS close ()
 Initializes the stream. More...
 
virtual lt_uint32 read (lt_uint8 *pDest, lt_uint32 numBytes)
 Initializes the stream. More...
 
virtual lt_uint32 write (const lt_uint8 *pSrc, lt_uint32 numBytes)
 Initializes the stream. More...
 
virtual LT_STATUS seek (lt_int64 offset, LTIOSeekDir origin)
 Initializes the stream. More...
 
virtual lt_int64 tell ()
 Initializes the stream. More...
 
- Public Member Functions inherited from LTIOStreamInf
virtual ~LTIOStreamInf ()=0
 

Memory Allocation and Deallocation Functions

typedef void *(* Allocator) (size_t)
 
typedef void(* Deallocator) (void *)
 
typedef void *(* Reallocator) (void *, size_t)
 
 LTIODynamicMemStream ()
 
virtual ~LTIODynamicMemStream ()
 

Memory Management

lt_uint8 * m_data
 pointer to buffer More...
 
lt_uint32 m_initialSize
 initial size of buffer More...
 
lt_uint32 m_bufferSize
 size of buffer as allocated More...
 
lt_uint32 m_userSize
 size of buffer as accessible by user More...
 
lt_uint32 m_cur
 current position
More...
 
bool m_isOpen
 openness More...
 
Allocator m_alloc
 allocator function More...
 
Deallocator m_dealloc
 deallocator More...
 
Reallocator m_realloc
 reallocator More...
 
LT_STATUS m_lastError
 pointer to buffer More...
 
bool m_isEOF
 pointer to buffer More...
 
float m_growthRate
 the factor of growth of the memory [1-2): More...
 
Allocator getAllocator () const
 Returns the allocator function pointer. More...
 
Deallocator getDeallocator () const
 Returns the deallocator function pointer. More...
 
Reallocator getReallocator () const
 Returns the reallocator function pointer. More...
 
const lt_uint8 * getData () const
 Get the underlying buffer. More...
 
LT_STATUS detachAndClose (lt_uint8 *&data)
 Detach the underlying buffer from the stream, and closes the stream. More...
 
lt_uint64 size () const
 Returns the number of bytes which are in the stream. More...
 
virtual LTIOStreamInf * duplicate ()
 pointer to buffer More...
 
virtual LT_STATUS getLastError () const
 pointer to buffer More...
 
virtual const char * getID () const
 pointer to buffer More...
 
virtual char * readString (int delimiter)
 pointer to buffer More...
 
bool grow (lt_uint32 numBytes)
 extend size of data buffer if required More...
 
void * defaultRealloc (void *, size_t)
 pointer to buffer More...
 

Detailed Description

Unlike LTIOMemStream, which uses a fixed-size buffer, this class will grow its buffer as you write past the end of it. It is most suitable for use as an internal "temp stream". The stream is initially empty.

The stream cannot hold more than 2^32 bytes of data.

Definition at line 27 of file lt_ioDynamicMemStream.h.

Member Typedef Documentation

◆ Allocator

typedef void*(* LTIODynamicMemStream::Allocator) (size_t)

Definition at line 37 of file lt_ioDynamicMemStream.h.

◆ Deallocator

typedef void(* LTIODynamicMemStream::Deallocator) (void *)

Definition at line 38 of file lt_ioDynamicMemStream.h.

◆ Reallocator

typedef void*(* LTIODynamicMemStream::Reallocator) (void *, size_t)

Definition at line 39 of file lt_ioDynamicMemStream.h.

Constructor & Destructor Documentation

◆ LTIODynamicMemStream()

LTIODynamicMemStream::LTIODynamicMemStream ( )

◆ ~LTIODynamicMemStream()

virtual LTIODynamicMemStream::~LTIODynamicMemStream ( )
virtual

Member Function Documentation

◆ close()

virtual LT_STATUS LTIODynamicMemStream::close ( )
virtual
Parameters
sizeinitial size of buffer in bytes
growthRatefactor of growth Valid Values: [1-2)

Implements LTIOStreamInf.

◆ defaultRealloc()

void* LTIODynamicMemStream::defaultRealloc ( void *  ,
size_t   
)
protected

◆ detachAndClose()

LT_STATUS LTIODynamicMemStream::detachAndClose ( lt_uint8 *&  data)

The caller is responsible for deallocating the buffer. (Note that you must use the Deallocator method, not delete[].)

Parameters
datareceives pointer to underlying buffer
Returns
LT_STS_Success upon success

◆ duplicate()

virtual LTIOStreamInf* LTIODynamicMemStream::duplicate ( )
virtual

Implements LTIOStreamInf.

◆ getAllocator()

Allocator LTIODynamicMemStream::getAllocator ( ) const
inline

Definition at line 95 of file lt_ioDynamicMemStream.h.

References m_alloc.

◆ getData()

const lt_uint8* LTIODynamicMemStream::getData ( ) const
inline

The pointer is guaranteed to be good until the next call to write(), or close()

Returns
pointer to underlying buffer

Definition at line 115 of file lt_ioDynamicMemStream.h.

References m_data.

◆ getDeallocator()

Deallocator LTIODynamicMemStream::getDeallocator ( ) const
inline

Definition at line 100 of file lt_ioDynamicMemStream.h.

References m_dealloc.

◆ getID()

virtual const char* LTIODynamicMemStream::getID ( ) const
virtual

Implements LTIOStreamInf.

◆ getLastError()

virtual LT_STATUS LTIODynamicMemStream::getLastError ( ) const
virtual

Implements LTIOStreamInf.

◆ getReallocator()

Reallocator LTIODynamicMemStream::getReallocator ( ) const
inline

Definition at line 105 of file lt_ioDynamicMemStream.h.

References m_realloc.

◆ grow()

bool LTIODynamicMemStream::grow ( lt_uint32  numBytes)
protected

◆ initialize() [1/2]

virtual LT_STATUS LTIODynamicMemStream::initialize ( lt_uint32  size,
Allocator  allo,
Deallocator  deallo,
Reallocator  reallo = nullptr,
float  growthRate = 2 
)
virtual

The allocator function should return nullptr in the event of failure, as opposed to throwing an exception – that is, be like malloc() and not like new.

Parameters
sizeinitial size of buffer in bytes
allouser-defined memory allocator
deallouser-defined memory deallocator
reallouser-defined memory reallocator
growthRatefactor of growth Valid Values: [1-2)

◆ initialize() [2/2]

virtual LT_STATUS LTIODynamicMemStream::initialize ( lt_uint32  size = 4096,
float  growthRate = 2 
)
virtual
Parameters
sizeinitial size of buffer in bytes
growthRatefactor of growth Valid Values: [1-2)

◆ isEOF()

virtual bool LTIODynamicMemStream::isEOF ( )
virtual
Parameters
sizeinitial size of buffer in bytes
growthRatefactor of growth Valid Values: [1-2)

Implements LTIOStreamInf.

◆ isOpen()

virtual bool LTIODynamicMemStream::isOpen ( )
virtual
Parameters
sizeinitial size of buffer in bytes
growthRatefactor of growth Valid Values: [1-2)

Implements LTIOStreamInf.

◆ open()

virtual LT_STATUS LTIODynamicMemStream::open ( )
virtual
Parameters
sizeinitial size of buffer in bytes
growthRatefactor of growth Valid Values: [1-2)

Implements LTIOStreamInf.

◆ read()

virtual lt_uint32 LTIODynamicMemStream::read ( lt_uint8 *  pDest,
lt_uint32  numBytes 
)
virtual
Parameters
sizeinitial size of buffer in bytes
growthRatefactor of growth Valid Values: [1-2)

Implements LTIOStreamInf.

◆ readString()

virtual char* LTIODynamicMemStream::readString ( int  delimiter)
virtual

Reimplemented from LTIOStreamInf.

◆ seek()

virtual LT_STATUS LTIODynamicMemStream::seek ( lt_int64  offset,
LTIOSeekDir  origin 
)
virtual
Parameters
sizeinitial size of buffer in bytes
growthRatefactor of growth Valid Values: [1-2)

Implements LTIOStreamInf.

◆ size()

lt_uint64 LTIODynamicMemStream::size ( ) const
inline

This may be smaller than the amount actually allocated.

Returns
size (in bytes) of stream

Definition at line 137 of file lt_ioDynamicMemStream.h.

References m_userSize.

◆ tell()

virtual lt_int64 LTIODynamicMemStream::tell ( )
virtual
Parameters
sizeinitial size of buffer in bytes
growthRatefactor of growth Valid Values: [1-2)

Implements LTIOStreamInf.

◆ write()

virtual lt_uint32 LTIODynamicMemStream::write ( const lt_uint8 *  pSrc,
lt_uint32  numBytes 
)
virtual
Parameters
sizeinitial size of buffer in bytes
growthRatefactor of growth Valid Values: [1-2)

Implements LTIOStreamInf.

Member Data Documentation

◆ m_alloc

Allocator LTIODynamicMemStream::m_alloc
protected

Definition at line 169 of file lt_ioDynamicMemStream.h.

Referenced by getAllocator().

◆ m_bufferSize

lt_uint32 LTIODynamicMemStream::m_bufferSize
protected

Definition at line 157 of file lt_ioDynamicMemStream.h.

◆ m_cur

lt_uint32 LTIODynamicMemStream::m_cur
protected

Definition at line 163 of file lt_ioDynamicMemStream.h.

◆ m_data

lt_uint8* LTIODynamicMemStream::m_data
protected

Definition at line 151 of file lt_ioDynamicMemStream.h.

Referenced by getData().

◆ m_dealloc

Deallocator LTIODynamicMemStream::m_dealloc
protected

Definition at line 172 of file lt_ioDynamicMemStream.h.

Referenced by getDeallocator().

◆ m_growthRate

float LTIODynamicMemStream::m_growthRate
protected

Definition at line 184 of file lt_ioDynamicMemStream.h.

◆ m_initialSize

lt_uint32 LTIODynamicMemStream::m_initialSize
protected

Definition at line 154 of file lt_ioDynamicMemStream.h.

◆ m_isEOF

bool LTIODynamicMemStream::m_isEOF
protected

Definition at line 181 of file lt_ioDynamicMemStream.h.

◆ m_isOpen

bool LTIODynamicMemStream::m_isOpen
protected

Definition at line 166 of file lt_ioDynamicMemStream.h.

◆ m_lastError

LT_STATUS LTIODynamicMemStream::m_lastError
protected

Definition at line 179 of file lt_ioDynamicMemStream.h.

◆ m_realloc

Reallocator LTIODynamicMemStream::m_realloc
protected

Definition at line 175 of file lt_ioDynamicMemStream.h.

Referenced by getReallocator().

◆ m_userSize

lt_uint32 LTIODynamicMemStream::m_userSize
protected

Definition at line 160 of file lt_ioDynamicMemStream.h.

Referenced by size().


The documentation for this class was generated from the following file:

Extensis