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

PlainFile.h

Go to the documentation of this file.
00001 /* Copyright (C) 2000 KOM/Darmstadt University of Technology 00002 * 00003 * You are allowed to use all other parts of the code under the following terms: 00004 * 00005 * For non-commercial use, code may be used in unmodified form provided 00006 * that this copyright notice and this permission notice appear in 00007 * supporting documentation. 00008 * 00009 * This software is provided "as is" and without any express or implied 00010 * warranties, including, without limitation, the implied warranty of 00011 * fitness for a particular purpose. 00012 * 00013 * The code may be subjected to the GNU General Public License, Version 2, 00014 * and re-distributed under the terms of this license. 00015 * As a special exception, permission is granted to link this code 00016 * with the Qt library and distribute executables, as long as you 00017 * follow the requirements of the GNU GPL in regard to all of the 00018 * software in the executable aside from Qt. 00019 * 00020 * Commercial use other than under the terms of the GNU General Public 00021 * License is allowed only after express negotiation of conditions 00022 * with the authors. 00023 */ 00024 #ifndef PLAINFILE_H 00025 #define PLAINFILE_H 00026 00027 #include "sh/SHReturnCodes.h" 00028 00029 class MNRope; 00030 namespace SH 00031 { 00032 class SinkEndpoint; 00033 }; 00034 00035 class PlainReader 00036 { 00037 public: 00040 PlainReader( ); 00041 00045 virtual ~PlainReader(); 00046 00051 virtual int getByte( ) = 0; 00052 00059 int getByte( unsigned char* dest ); 00060 00067 int get2Bytes( unsigned char* dest ); 00068 00075 int get3Bytes( unsigned char* dest ); 00076 00083 int get4Bytes( unsigned char* dest ); 00084 00094 int getByte( unsigned int& dest ); 00095 00106 int get2Bytes( unsigned int& dest ); 00107 00114 int get3Bytes( unsigned int& dest ); 00115 00122 int get4Bytes( unsigned int& dest ); 00123 00131 int addByte( unsigned int& dest ); 00132 00141 int add2Bytes( unsigned int& dest ); 00142 00149 int add3Bytes( unsigned int& dest ); 00150 }; 00151 00152 class PlainFileReader : public PlainReader 00153 { 00154 int _fd; 00155 bool _eof; 00156 unsigned char* _buffer; 00157 unsigned int _bytes; 00158 unsigned int _ptr; 00159 const size_t _max; 00160 00161 public: 00177 PlainFileReader( int fd, size_t bufmax = 4096 ); 00178 00181 virtual ~PlainFileReader(); 00182 00187 int getByte( ); 00188 00196 virtual bool eof() const; 00197 00201 int fd() const; 00202 }; 00203 00204 class PlainRopeReader : public PlainReader 00205 { 00206 SH::SinkEndpoint* _pull_here; 00207 MNRope* _rope; 00208 size_t _index; 00209 bool _eof; 00210 const size_t _max; 00211 00212 public: 00228 PlainRopeReader( SH::SinkEndpoint* pull_here, size_t bufmax = 4096 ); 00229 00232 virtual ~PlainRopeReader(); 00233 00238 int getByte( ); 00239 00247 virtual bool eof() const; 00248 00252 SH::SinkEndpoint* ep() const; 00253 }; 00254 00255 #endif /* PLAINFILE_H */ 00256

Generated on Sun Mar 6 13:35:49 2005 for Komssys by doxygen 1.3.8