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

datafile_inputprovider.h

Go to the documentation of this file.
00001 /*
00002         $Id: datafile_inputprovider.h,v 1.2 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         File purpose:
00015                 Datafile input source provider, part of the i/o data component.
00016 
00017 */
00018 
00019 #ifndef header_datafile_inputprovider
00020 #define header_datafile_inputprovider
00021 
00022 #ifdef __BEOS__
00023 #include <gnu/zlib.h>
00024 #else
00025 #include <zlib.h>
00026 #endif
00027 
00028 #include <stack>
00029 
00030 #include "API/Core/System/cl_assert.h"
00031 #include "API/Core/IOData/inputsource.h"
00032 #include "API/Core/IOData/inputsource_provider.h"
00033 
00034 class CL_Zipped_Position
00035 {
00036 public:
00037         gzFile gzfile;
00038         int datafile_pos;
00039         int seek_pos;
00040 };
00041 
00042 class CL_InputSource_Datafile : public CL_InputSource
00043 {
00044 protected:
00045         std::string filename;
00046         std::string datafile;
00047         int datafile_handle;
00048 
00049         int objsize;
00050 
00051         gzFile gzfile;
00052         int index_open;
00053         int datafile_open;
00054 
00055         std::stack<CL_Zipped_Position> index_stack;
00056         
00057         int seek_pos;
00058 
00059         void open_index();
00060         void close_index();
00061 
00062 public:
00063         CL_InputSource_Datafile(const char *index, const char *datafile);
00064         CL_InputSource_Datafile(const CL_InputSource_Datafile *source);
00065         virtual ~CL_InputSource_Datafile();
00066 
00067         // Change input data endianess (defaults to little endian)
00068         virtual void set_system_mode();
00069         virtual void set_big_endian_mode();
00070         virtual void set_little_endian_mode();
00071 
00072         // read 32 bit integer:
00073         virtual int read_int32();
00074         virtual unsigned int read_uint32();
00075 
00076         // read 16 bit short:
00077         virtual short read_short16();
00078         virtual unsigned short read_ushort16();
00079 
00080         // read 8 bit char:
00081         virtual char read_char8();
00082         virtual unsigned char read_uchar8();
00083 
00084         virtual float read_float32();
00085 
00086         // read larger amounts of data (no endian and 64 bit conversion):
00087         // returns num bytes actually read
00088         virtual int read(void *data, int size);
00089 
00090         virtual void open();
00091         virtual void close();
00092 
00093         // Make a copy of the current InputSource, standing at the same position.
00094         virtual CL_InputSource *clone() const;
00095 
00096         // Returns current position in input source
00097         virtual int tell() const;
00098         virtual void seek(int pos, SeekEnum seek_type);
00099 
00100         // Returns the size of the input source
00101         virtual int size() const;
00102 
00103         virtual std::string read_string();
00104 
00105         virtual void push_position();
00106         virtual void pop_position();
00107 };
00108 
00109 class CL_InputSourceProvider_Datafile : public CL_InputSourceProvider
00110 {
00111 protected:
00112         std::string datafile;
00113 public:
00114         CL_InputSourceProvider_Datafile(const char *datafile);
00115         virtual CL_InputSource *open_source(const char *filename);
00116         virtual CL_InputSourceProvider *clone();
00117 };
00118 
00119 #endif

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