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

simplestream.h

Go to the documentation of this file.
00001 /*
00002     This file is part of Advanced Strategic Command; http://www.asc-hq.de
00003     Copyright (C) 1994-1999  Martin Bickel  and  Marc Schellenberger
00004 
00005     This program is free software; you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation; either version 2 of the License, or
00008     (at your option) any later version.
00009 
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013     GNU General Public License for more details.
00014 
00015     You should have received a copy of the GNU General Public License
00016     along with this program; see the file COPYING. If not, write to the
00017     Free Software Foundation, Inc., 59 Temple Place, Suite 330,
00018     Boston, MA  02111-1307  USA
00019 */
00020 
00021 #ifndef simplestreamH
00022 #define simplestreamH
00023 
00024 #include <time.h>
00025 #include "ascstring.h"
00026 #include "errors.h"
00027 #include "basestreaminterface.h"
00028 
00029 class tnbufstream  : public tnstream {
00030            char  minbuf;
00031            int datalen;
00032 
00033        protected:
00034            char* zeiger;
00035            IOMode  _mode;
00036            int   actmempos;
00037            int   memsize;
00038            int   datasize;
00039 
00040            virtual void readbuffer( void ) = 0;
00041            virtual void writebuffer( void ) = 0;
00042            virtual void close( void ) {};
00043        public:
00044            tnbufstream ( );
00045            virtual void writedata ( const void* buf, int size );
00046            virtual int  readdata  ( void* buf, int size, bool excpt = true  );
00047 
00048            virtual ~tnbufstream ( );
00049 
00050       };
00051 
00052 class tn_file_buf_stream : public tnbufstream {
00053             FILE* fp;
00054             int actfilepos;
00055 
00056             bool sizeCached;
00057             int sizeValue;
00058             bool timeCached;
00059             int timeValue;
00060 
00061 
00062         protected:
00063             void readbuffer( void );
00064             void writebuffer( void );
00065 
00066 
00067         public:
00068             tn_file_buf_stream ( const ASCString& _fileName, IOMode mode );
00069             virtual void seek ( int newpos );
00070             virtual int getstreamsize ( void );
00071             virtual int getSize ( void ) { return getstreamsize(); };
00072             virtual time_t get_time ( void );
00073             virtual ~tn_file_buf_stream( );
00074   };
00075 
00076 
00077 class tfileerror : public ASCexception {
00078    ASCString _filename;
00079   public:
00080    tfileerror ( const ASCString& fileName ) ;
00081    const ASCString& getFileName() const { return _filename; };
00082    tfileerror ( void ) {};
00083 };
00084 
00085 class tinvalidmode : public tfileerror {
00086   public:
00087    int orgmode, requestmode;
00088    tinvalidmode ( const ASCString& fileName, tnstream::IOMode org_mode, tnstream::IOMode requested_mode ) ;
00089 };
00090 
00091 class treadafterend : public tfileerror {
00092   public:
00093    treadafterend ( const ASCString& fileName );
00094 };
00095 
00096 class tinternalerror: public ASCexception {
00097    int linenum;
00098    const char* sourcefilename;
00099   public:
00100    tinternalerror ( const char* filename, int l );
00101 };
00102 
00103 
00104 #endif

Generated on Tue Jun 24 01:27:52 2008 for Advanced Strategic Command by  doxygen 1.4.2