00001 /* 00002 $Id: inputsource_memory.h,v 1.3 2001/03/04 17:54:47 mbn 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 00016 00017 #ifndef header_inputsource_memory 00018 #define header_inputsource_memory 00019 00020 #include "inputsource.h" 00021 00022 class CL_InputSource_Memory : public CL_InputSource 00023 //: Interface to read data from a memory source. 00024 // CL_InputSource_Memory is used to read data from a memory source. 00026 { 00027 public: 00028 CL_InputSource_Memory(std::string data); 00029 virtual ~CL_InputSource_Memory(); 00030 00031 virtual void set_system_mode(); 00032 //: Changes input data endianess to the local systems mode. 00033 00034 virtual void set_big_endian_mode(); 00035 //: Changes input data endianess to big endian mode. 00036 00037 virtual void set_little_endian_mode(); 00038 //: Changes input data endianess to little endian mode. This is the 00039 //: default setting. 00040 00041 virtual int read_int32(); 00042 //: Reads a signed 32 bit integer from input source. 00044 00045 virtual unsigned int read_uint32(); 00046 //: Reads a unsigned 32 bit integer from input source. 00048 00049 virtual short read_short16(); 00050 //: Reads a signed 16 bit integer (short) from input source. 00052 00053 virtual unsigned short read_ushort16(); 00054 //: Reads a unsigned 16 bit integer (short) from input source. 00056 00057 virtual char read_char8(); 00058 //: Reads a signed 8 bit integer (char) from input source. 00060 00061 virtual unsigned char read_uchar8(); 00062 //: Reads a unsigned 8 bit integer (char) from input source. 00064 00065 virtual float read_float32(); 00066 //: Reads an ieee format floating point from input source. 00068 00069 virtual bool read_bool(); 00070 //: Reads a bool from input source. 00072 00073 virtual int read(void *data, int size); 00074 //: Reads larger amounts of data (no endian and 64 bit conversion). 00078 00079 virtual void open(); 00080 //: Opens the input source. By default, it is open. 00081 00082 virtual void close(); 00083 //: Closes the input source. 00084 00085 virtual CL_InputSource *clone() const; 00086 //: Make a copy of the current InputSource, standing at the same position. 00088 00089 virtual int tell() const; 00090 //: Returns current position in input source. 00092 00093 virtual void seek(int pos, SeekEnum seek_type); 00094 //: Seeks to the specified position in the input source. 00097 00098 virtual int size() const; 00099 //: Returns the size of the input source 00101 00102 virtual std::string read_string(); 00103 // Reads a clanstring (int32 len, char[len] str) string from the source. 00104 00105 virtual void push_position(); 00106 //: Pushes the current input source position. The position can be restored again with pop_position. 00107 00108 virtual void pop_position(); 00109 //: Pops a previous pushed input source position (returns to the position). 00110 00111 std::string get_data() { return m_data; } 00112 // Returns the data source. 00113 00114 private: 00115 std::string m_data; 00116 unsigned int m_pos; 00117 bool m_delete_data; 00118 }; 00119 00120 #endif
1.2.6 written by Dimitri van Heesch,
© 1997-2001