MrSID Decode SDK for Raster Reference Manual  9.5.5.5244
lt_ioDynamicMemStream.h
Go to the documentation of this file.
1 //
2 // This code is property of Celartem, Inc dba Extensis.
3 // Copyright (c) 1995-2023. All rights reserved.
4 // Use permitted only under license from Extensis.
5 //
6 /* PUBLIC */
7 
8 #ifndef LT_IO_DYNAMIC_MEM_STREAM_H
9 #define LT_IO_DYNAMIC_MEM_STREAM_H
10 
11 #include "lt_ioStreamInf.h"
12 #include <stdlib.h>
13 
14 LT_BEGIN_LIZARDTECH_NAMESPACE
15 
16 
28 {
29 public:
32 #if defined(LT_OS_WINCE)
33  typedef void* (__cdecl * Allocator)(size_t);
34  typedef void(__cdecl *Deallocator)(void*);
35  typedef void*(__cdecl *Reallocator)(void*,size_t);
36 #else
37  typedef void*(*Allocator)(size_t);
38  typedef void(*Deallocator)(void*);
39  typedef void*(*Reallocator)(void*,size_t);
40 #endif
42 
43 public:
46 
57  virtual LT_STATUS initialize( lt_uint32 size = 4096, float growthRate=2 );
58 
73  Allocator allo, Deallocator deallo,
74  Reallocator reallo=nullptr, float growthRate=2 );
75 
78  virtual bool isEOF();
79  virtual bool isOpen();
80  virtual LT_STATUS open();
81  virtual LT_STATUS close();
82  virtual lt_uint32 read( lt_uint8 *pDest, lt_uint32 numBytes );
83  virtual lt_uint32 write( const lt_uint8 *pSrc, lt_uint32 numBytes );
84  virtual LT_STATUS seek( lt_int64 offset, LTIOSeekDir origin );
85  virtual lt_int64 tell();
86 
87 
95  Allocator getAllocator() const { return m_alloc; }
96 
100  Deallocator getDeallocator() const { return m_dealloc; }
101 
105  Reallocator getReallocator() const { return m_realloc; }
106 
115  const lt_uint8* getData() const { return m_data; }
116 
117 
129 
137  lt_uint64 size() const { return m_userSize; }
138 
142  virtual LT_STATUS getLastError() const;
143  virtual const char* getID() const;
144  virtual char *readString(int delimiter);
145 
146 protected:
148  bool grow(lt_uint32 numBytes);
149 
152 
155 
158 
161 
164 
166  bool m_isOpen;
167 
170 
173 
176 
177  void* defaultRealloc(void*,size_t);
178 
180 
181  bool m_isEOF;
182 
185 };
186 
187 
188 LT_END_LIZARDTECH_NAMESPACE
189 
190 
191 #endif // LT_IO_DYNAMIC_MEM_STREAM_H
LTIOSeekDir
Stream seek directions.
Definition: lt_lib_io.h:26
lt_uint32 LT_STATUS
An integral status code.
Definition: lt_status.h:30
unsigned long long int lt_uint64
unsigned 64-bit integer
Definition: lt_types.h:59
unsigned char lt_uint8
unsigned 8-bit integer
Definition: lt_types.h:36
unsigned int lt_uint32
unsigned 32-bit integer
Definition: lt_types.h:44
long long int lt_int64
signed 64-bit integer
Definition: lt_types.h:57
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
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.

Extensis