00001 /* 00002 $Id: inputsource_memory_generic.h,v 1.3 2001/01/11 00:30:32 plasmoid Exp $ 00003 00004 ------------------------------------------------------------------------ 00005 ClanLib, the platform independent game SDK. 00006 00007 This library is distributed under the GNU LIBRARY GENERAL PUBLIC LICENSE 00008 version 2. See COPYING for details. 00009 00010 For a total list of contributers see CREDITS. 00011 00012 ------------------------------------------------------------------------ 00013 */ 00014 00015 #ifndef header_inputsource_memory_generic 00016 #define header_inputsource_memory_generic 00017 00018 #include "API/Core/IOData/inputsource.h" 00019 #include "API/Core/IOData/inputsource_provider.h" 00020 00021 class CL_OutputSource_MemoryGeneric; 00022 00023 class CL_InputSource_MemoryGeneric : public CL_InputSource 00024 //: Interface to read data from a memory_generic source. 00025 // CL_InputSource_MemoryGeneric is used to read data from a memory_generic source. 00027 { 00028 public: 00029 CL_InputSource_MemoryGeneric(void *data, int size, bool delete_data = false); 00030 CL_InputSource_MemoryGeneric(const CL_InputSource_MemoryGeneric *MG); 00031 //: MemoryGeneric copy constructor. 00032 //Makes a seperate copy of the memory in MG. 00035 00036 virtual ~CL_InputSource_MemoryGeneric(); 00037 00038 virtual void set_system_mode(); 00039 //: Changes input data endianess to the local systems mode. 00040 00041 virtual void set_big_endian_mode(); 00042 //: Changes input data endianess to big endian mode. 00043 00044 virtual void set_little_endian_mode(); 00045 //: Changes input data endianess to little endian mode. This is the 00046 //: default setting. 00047 00048 virtual int read_int32(); 00049 //: Reads a signed 32 bit integer from input source. 00051 00052 virtual unsigned int read_uint32(); 00053 //: Reads a unsigned 32 bit integer from input source. 00055 00056 virtual short read_short16(); 00057 //: Reads a signed 16 bit integer (short) from input source. 00059 00060 virtual unsigned short read_ushort16(); 00061 //: Reads a unsigned 16 bit integer (short) from input source. 00063 00064 virtual char read_char8(); 00065 //: Reads a signed 8 bit integer (char) from input source. 00067 00068 virtual unsigned char read_uchar8(); 00069 //: Reads a unsigned 8 bit integer (char) from input source. 00071 00072 virtual float read_float32(); 00073 //: Reads an ieee format floating point from input source. 00075 00076 virtual bool read_bool(); 00077 //: Reads a bool from input source. 00079 00080 virtual int read(void *data, int size); 00081 //: Reads larger amounts of data (no endian and 64 bit conversion). 00085 00086 virtual void open(); 00087 //: Opens the input source. By default, it is open. 00088 00089 virtual void close(); 00090 //: Closes the input source. 00091 00092 virtual CL_InputSource *clone() const; 00093 //: Make a copy of the current InputSource, standing at the same position. 00095 00096 virtual int tell() const; 00097 //: Returns current position in input source. 00099 00100 virtual void seek(int pos, SeekEnum seek_type); 00101 //: Seeks to the specified position in the input source. 00104 00105 virtual int size() const; 00106 //: Returns the size of the input source 00108 00109 virtual std::string read_string(); 00110 //: Reads a string from the input source. 00112 00113 virtual void push_position(); 00114 //: Pushes the current input source position. The position can be restored again with pop_position. 00115 00116 virtual void pop_position(); 00117 //: Pops a previous pushed input source position (returns to the position). 00118 00119 virtual void purge(); 00120 //: Purges the input buffer of data without deleting the buffer 00121 00122 private: 00123 unsigned char *m_data; 00124 unsigned int m_pos, m_size; 00125 bool m_delete_data; 00126 }; 00127 00128 class CL_InputSourceProvider_Memory : public CL_InputSourceProvider { 00129 unsigned char *m_data; 00130 unsigned int m_size; 00131 bool m_delete_data; 00132 public: 00133 CL_InputSourceProvider_Memory(unsigned char *data, unsigned int size, bool delete_data); 00134 CL_InputSourceProvider_Memory(CL_InputSource_MemoryGeneric *MG); 00135 CL_InputSourceProvider_Memory(CL_OutputSource_MemoryGeneric *MG); 00136 virtual CL_InputSource *open_source(const char *handle); 00137 virtual CL_InputSourceProvider *clone(); 00138 00139 }; 00140 #endif
1.2.6 written by Dimitri van Heesch,
© 1997-2001