MrSID Decode SDK for Raster Reference Manual  9.5.1.4427
lt_ioDynamicMemStream.h
Go to the documentation of this file.
1 /* $Id$ */
2 /* //////////////////////////////////////////////////////////////////////////
3 // //
4 // This code is Copyright (c) 2004 LizardTech, Inc, 1008 Western Avenue, //
5 // Suite 200, Seattle, WA 98104. Unauthorized use or distribution //
6 // prohibited. Access to and use of this code is permitted only under //
7 // license from LizardTech, Inc. Portions of the code are protected by //
8 // US and foreign patents and other filings. All Rights Reserved. //
9 // //
11 /* PUBLIC */
12 
13 
14 #ifndef LT_IO_DYNAMIC_MEM_STREAM_H
15 #define LT_IO_DYNAMIC_MEM_STREAM_H
16 
17 #include "lt_ioStreamInf.h"
18 #include <stdlib.h>
19 
21 
22 
23 
34 {
35 public:
38 #if defined(LT_OS_WINCE)
39  typedef void* (__cdecl * Allocator)(size_t);
40  typedef void(__cdecl *Deallocator)(void*);
41  typedef void*(__cdecl *Reallocator)(void*,size_t);
42 #else
43  typedef void*(*Allocator)(size_t);
44  typedef void(*Deallocator)(void*);
45  typedef void*(*Reallocator)(void*,size_t);
46 #endif
47 
48 
49 public:
51  virtual ~LTIODynamicMemStream();
52 
63  virtual LT_STATUS initialize( lt_uint32 size = 4096, float growthRate=2 );
64 
78  virtual LT_STATUS initialize( lt_uint32 size,
79  Allocator allo, Deallocator deallo,
80  Reallocator reallo=NULL, float growthRate=2 );
81 
84  virtual bool isEOF();
85  virtual bool isOpen();
86  virtual LT_STATUS open();
87  virtual LT_STATUS close();
88  virtual lt_uint32 read( lt_uint8 *pDest, lt_uint32 numBytes );
89  virtual lt_uint32 write( const lt_uint8 *pSrc, lt_uint32 numBytes );
90  virtual LT_STATUS seek( lt_int64 offset, LTIOSeekDir origin );
91  virtual lt_int64 tell();
92 
93 
101  Allocator getAllocator() const { return m_alloc; }
102 
106  Deallocator getDeallocator() const { return m_dealloc; }
107 
111  Reallocator getReallocator() const { return m_realloc; }
112 
121  const lt_uint8* getData() const { return m_data; }
122 
123 
134  LT_STATUS detachAndClose(lt_uint8*& data);
135 
143  lt_uint64 size() const { return m_userSize; }
144 
147  virtual LTIOStreamInf* duplicate();
148  virtual LT_STATUS getLastError() const;
149  virtual const char* getID() const;
150 
151 protected:
153  bool grow(lt_uint32 numBytes);
154 
157 
160 
163 
166 
169 
171  bool m_isOpen;
172 
174  Allocator m_alloc;
175 
177  Deallocator m_dealloc;
178 
180  Reallocator m_realloc;
181 
182  void* defaultRealloc(void*,size_t);
183 
185 
186  bool m_isEOF;
187 
190 };
191 
192 
194 
195 
196 #endif // LT_IO_DYNAMIC_MEM_STREAM_H
lt_uint32 m_bufferSize
size of buffer as allocated
Deallocator getDeallocator() const
Returns the deallocator function pointer.
#define LT_END_NAMESPACE(theNameSpace)
compiler does not support namespaces
Definition: lt_define.h:85
Allocator m_alloc
allocator function
float m_growthRate
the factor of growth of the memory [1-2):
lt_uint32 LT_STATUS
An integral status code.
Definition: lt_status.h:39
Reallocator m_realloc
reallocator
lt_uint32 m_userSize
size of buffer as accessible by user
LTIOSeekDir
Stream seek directions.
Definition: lt_lib_io.h:30
Abstract definition of a stream.
const lt_uint8 * getData() const
Get the underlying buffer.
lt_uint8 * m_data
pointer to buffer
lt_uint32 m_cur
current position
Reallocator getReallocator() const
Returns the reallocator function pointer.
lt_uint32 m_initialSize
initial size of buffer
Deallocator m_dealloc
deallocator
Allocator getAllocator() const
Returns the allocator function pointer.
#define LT_BEGIN_NAMESPACE(theNameSpace)
compiler does not support namespaces
Definition: lt_define.h:84
holds a memory buffer of variable size
unsigned int lt_uint32
unsigned 32-bit integer
Definition: lt_types.h:54
lt_uint64 size() const
Returns the number of bytes which are in the stream.
unsigned char lt_uint8
unsigned 8-bit integer
Definition: lt_types.h:46

LizardTech