00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
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
00256