Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

inputsource.h

Go to the documentation of this file.
00001 /*
00002         $Id: inputsource.h,v 1.5 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
00018 #define header_inputsource
00019 
00020 #include <string>
00021 
00022 class CL_InputSource
00023 //: Interface to read data.
00024 // CL_InputSource is used to read data from different types of input sources.
00025 // In most cases, this is regular files and ClanLib zlib compressed datafiles.
00026 // <br>
00027 // To access some system specific input source types, such as datafiles and
00028 // regular ones, use the static create functions in the CL_InputSourceProvider
00029 // class.
00031 {
00032 public:
00033         virtual ~CL_InputSource() { return; }
00034 
00035         virtual void set_system_mode()=0;
00036         //: Changes input data endianess to the local systems mode.
00037 
00038         virtual void set_big_endian_mode()=0;
00039         //: Changes input data endianess to big endian mode.
00040 
00041         virtual void set_little_endian_mode()=0;
00042         //: Changes input data endianess to little endian mode. This is the 
00043         //: default setting.
00044 
00045         virtual int read_int32()=0;
00046         //: Reads a signed 32 bit integer from input source.
00048 
00049         virtual unsigned int read_uint32()=0;
00050         //: Reads a unsigned 32 bit integer from input source.
00052 
00053         virtual short read_short16()=0;
00054         //: Reads a signed 16 bit integer (short) from input source.
00056 
00057         virtual unsigned short read_ushort16()=0;
00058         //: Reads a unsigned 16 bit integer (short) from input source.
00060 
00061         virtual char read_char8()=0;
00062         //: Reads a signed 8 bit integer (char) from input source.
00064 
00065         virtual unsigned char read_uchar8()=0;
00066         //: Reads a unsigned 8 bit integer (char) from input source.
00068 
00069         virtual float read_float32()=0;
00070         //: Reads an ieee format floating point from input source.
00072 
00073         virtual int read(void *data, int size)=0;
00074         //: Reads larger amounts of data (no endian and 64 bit conversion).
00078         
00079         virtual void open()=0;
00080         //: Opens the input source. By default, it is open.
00081         
00082         virtual void close()=0;
00083         //: Closes the input source.
00084 
00085         virtual CL_InputSource *clone() const =0;
00086         //: Make a copy of the current InputSource, standing at the same position.
00088 
00089         enum SeekEnum
00090         {
00091                 seek_set,        // from beginning of index
00092                 seek_cur,        // from current position
00093                 seek_end         // from end of index
00094         };
00095 
00096         virtual int tell() const =0;
00097         //: Returns current position in input source.
00099 
00100         virtual void seek(int pos, SeekEnum seek_type)=0;
00101         //: Seeks to the specified position in the input source.
00104 
00105         virtual int size() const =0;
00106         //: Returns the size of the input source
00108 
00109         virtual std::string read_string()=0;
00110         // Reads a string from the input source.
00111         // <br>
00112         // The binary format expected in the input source is first an uint32 telling the length of the
00113         // string, and then the string itself.
00115 
00116         virtual void push_position()=0;
00117         //: Pushes the current input source position. The position can be restored again with pop_position.
00118         
00119         virtual void pop_position()=0;
00120         //: Pops a previous pushed input source position (returns to the position).
00121 
00122 protected:
00123         bool little_endian_mode;
00124   //: The current system mode
00125 
00126 };
00127 
00128 #endif

Generated at Wed Apr 4 19:54:00 2001 for ClanLib by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001