Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

chunck.h

Go to the documentation of this file.
00001 /*
00002 Copyright (c) 2002 Xavier Trochu
00003 
00004 This software is provided 'as-is', without any express or implied warranty. In no event
00005 will the authors be held liable for any damages arising from the use of this software.
00006 
00007 Permission is granted to anyone to use this software for any purpose, including commercial
00008 applications, and to alter it and redistribute it freely, subject to the following
00009 restrictions:
00010 
00011 1. The origin of this software must not be misrepresented; you must not claim that you
00012    wrote the original software. If you use this software in a product, an acknowledgment
00013    in the product documentation would be appreciated but is not required.
00014 
00015 2. Altered source versions must be plainly marked as such, and must not be misrepresented 
00016    as being the original software.
00017 
00018 3. This notice may not be removed or altered from any source distribution.
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

Generated on Fri Aug 9 22:54:29 2002 for san_player by doxygen1.2.16