00001 #ifndef CLASSLIB_MEMORY_STORAGE_H 00002 # define CLASSLIB_MEMORY_STORAGE_H 00003 00004 //<<<<<< INCLUDES >>>>>> 00005 00006 # include "classlib/sysapi/system.h" 00007 # include "classlib/iobase/Storage.h" 00008 00009 namespace lat { 00010 //<<<<<< PUBLIC DEFINES >>>>>> 00011 //<<<<<< PUBLIC CONSTANTS >>>>>> 00012 //<<<<<< PUBLIC TYPES >>>>>> 00013 //<<<<<< PUBLIC VARIABLES >>>>>> 00014 //<<<<<< PUBLIC FUNCTIONS >>>>>> 00015 //<<<<<< CLASS DECLARATIONS >>>>>> 00016 00017 class MemoryStorage : public Storage 00018 { 00019 public: 00020 MemoryStorage (IOBuffer data = IOBuffer ((void *) 0, 0)); 00021 MemoryStorage (const void *data, IOSize n); 00022 ~MemoryStorage (void); 00023 00024 using Storage::read; 00025 using Storage::write; 00026 00027 virtual IOSize read (void *into, IOSize n); 00028 virtual IOSize write (const void *from, IOSize n); 00029 00030 virtual IOOffset size (void) const; 00031 virtual IOOffset position (void) const; 00032 virtual IOOffset position (IOOffset offset, Relative whence = SET); 00033 virtual void resize (IOOffset size); 00034 00035 virtual IOBuffer data (void) const; 00036 00037 protected: 00038 virtual void extend (IOSize by); 00039 00040 unsigned char *m_buffer; //< Buffer base pointer. 00041 unsigned char *m_current; //< Current "file position". 00042 unsigned char *m_top; //< High mark of anything written. 00043 unsigned char *m_limit; //< Top of allocated buffer extent. 00044 bool m_growable; //< Flag indicating whether buffer can grow. 00045 }; 00046 00047 //<<<<<< INLINE PUBLIC FUNCTIONS >>>>>> 00048 //<<<<<< INLINE MEMBER FUNCTIONS >>>>>> 00049 00050 } // namespace lat 00051 #endif // CLASSLIB_MEMORY_STORAGE_H