00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __CHUNCK_H_
00021 #define __CHUNCK_H_
00022
00023 #ifdef HAVE_CONFIG_H
00024 #include "config.h"
00025 #endif
00026
00027 #include <string>
00028 #include <exception>
00029 #include <ostream>
00036 class chunck {
00037 public:
00038 virtual ~chunck() throw() {};
00039 typedef unsigned int type;
00040
00048 static std::string chunck_string(type t);
00049
00050 virtual type get_type() const throw() = 0;
00051 virtual unsigned int get_size() const throw() = 0;
00052 virtual chunck * sub_block() throw(std::exception) = 0;
00053 virtual bool eof() const throw() = 0;
00054 virtual unsigned int tell() const throw() = 0;
00055 virtual bool seek(int delta, std::ios::seekdir dir = std::ios::cur) throw (std::exception) = 0;
00056 virtual bool read(void * buffer, unsigned int size) throw(std::exception) = 0;
00057 virtual char get_char() throw(std::exception) = 0;
00058 virtual unsigned char get_byte() throw(std::exception) = 0;
00059 virtual short get_short() throw(std::exception) = 0;
00060 virtual unsigned short get_word() throw(std::exception) = 0;
00061 virtual unsigned int get_dword() throw(std::exception) = 0;
00062 };
00063
00064 class file_ptr;
00065
00071 class file_chunck : public chunck {
00072 private:
00073 file_ptr * _data;
00074 type _type;
00075 unsigned int _size;
00076 unsigned int _offset;
00077 unsigned int _cur_pos;
00078 protected:
00079 file_chunck() throw();
00080 public:
00081 file_chunck(const std::string & fname) throw(std::exception);
00082 type get_type() const throw();
00083 unsigned int get_size() const throw();
00084 chunck * sub_block() throw(std::exception);
00085 bool eof() const throw();
00086 unsigned int tell() const throw();
00087 bool seek(int delta, std::ios::seekdir dir = std::ios::cur) throw (std::exception);
00088 bool read(void * buffer, unsigned int size) throw(std::exception);
00089 char get_char() throw(std::exception);
00090 unsigned char get_byte() throw(std::exception);
00091 short get_short() throw(std::exception);
00092 unsigned short get_word() throw(std::exception);
00093 unsigned int get_dword() throw(std::exception);
00094 };
00095
00100 class cont_chunck : public chunck {
00101 private:
00102 char * _data;
00103 chunck::type _type;
00104 unsigned int _size;
00105 unsigned int _cur_pos;
00106 public:
00107 cont_chunck(char * data) throw(std::exception);
00108 chunck::type get_type() const throw();
00109 unsigned int get_size() const throw();
00110 chunck * sub_block() throw(std::exception);
00111 bool eof() const throw();
00112 unsigned int tell() const throw();
00113 bool seek(int delta, std::ios::seekdir dir = std::ios::cur) throw (std::exception);
00114 bool read(void * buffer, unsigned int size) throw(std::exception);
00115 char get_char() throw(std::exception);
00116 unsigned char get_byte() throw(std::exception);
00117 short get_short() throw(std::exception);
00118 unsigned short get_word() throw(std::exception);
00119 unsigned int get_dword() throw(std::exception);
00120 };
00121
00122 #endif