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

file_inputprovider.h

Go to the documentation of this file.
00001 /*
00002         $Id: file_inputprovider.h,v 1.4 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         File purpose:
00015                 File input source provider, part of the i/o data component.
00016 
00017 */
00018 
00020 
00021 #ifndef header_file_inputprovider
00022 #define header_file_inputprovider
00023 
00024 #include "inputsource.h"
00025 
00026 #include <stack>
00027 #include <stdio.h>
00028 
00029 class CL_InputSourceProvider_File : public CL_InputSourceProvider
00030 {
00031 public:
00032 
00033         CL_InputSourceProvider_File(const char *path);
00034         virtual CL_InputSource *open_source(const char *filename);
00035         virtual CL_InputSourceProvider *clone();
00036 protected:
00037         std::string provider_path;
00038 };
00039 
00040 class CL_InputSource_File : public CL_InputSource
00041 {
00042 protected:
00043         std::stack<int> stack;
00044         std::string filename;
00045         FILE *filehandle;
00046         int filesize;
00047 
00048 public:
00049         CL_InputSource_File(const char *filename);
00050         CL_InputSource_File(const CL_InputSource_File *source);
00051         virtual ~CL_InputSource_File();
00052 
00053         // Change input data endianess (defaults to little endian)
00054         virtual void set_system_mode();
00055         virtual void set_big_endian_mode();
00056         virtual void set_little_endian_mode();
00057 
00058         // read 32 bit integer:
00059         virtual int read_int32();
00060         virtual unsigned int read_uint32();
00061 
00062         // read 16 bit short:
00063         virtual short read_short16();
00064         virtual unsigned short read_ushort16();
00065 
00066         // read 8 bit char:
00067         virtual char read_char8();
00068         virtual unsigned char read_uchar8();
00069 
00070         virtual float read_float32();
00071 
00072         // read larger amounts of data (no endian and 64 bit conversion):
00073         // returns num bytes actually read
00074         virtual int read(void *data, int size);
00075 
00076         virtual void open();
00077         virtual void close();
00078 
00079         // Make a copy of the current InputSource, standing at the same position.
00080         virtual CL_InputSource *clone() const;
00081 
00082         // Returns current position in input source
00083         virtual int tell() const;
00084         virtual void seek(int pos, SeekEnum seek_type);
00085 
00086         // Returns the size of the input source
00087         virtual int size() const;
00088 
00089         virtual std::string read_string();
00090 
00091         virtual void push_position();
00092         virtual void pop_position();
00093 };
00094 
00095 #endif

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