00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef CEYLAN_INPUT_STREAM_H_
00028 #define CEYLAN_INPUT_STREAM_H_
00029
00030
00031 #include "CeylanStream.h"
00032 #include "CeylanTypes.h"
00033
00034
00035 #include <list>
00036 #include <string>
00037
00038
00039
00040
00041 namespace Ceylan
00042 {
00043
00044
00045
00046 namespace System
00047 {
00048
00049
00050
00065 class CEYLAN_DLL InputStream : public virtual Stream
00066 {
00067
00068
00069 public:
00070
00071
00072
00078 class InputStreamException : public StreamException
00079 {
00080 public:
00081
00082 explicit InputStreamException(
00083 const std::string & reason ) :
00084 StreamException( reason )
00085 {
00086
00087 }
00088
00089 } ;
00090
00091
00092
00094 class SelectFailedException : public InputStreamException
00095 {
00096 public:
00097
00098 explicit SelectFailedException(
00099 const std::string & reason ) :
00100 InputStreamException( reason )
00101 {
00102
00103 }
00104
00105 } ;
00106
00107
00108
00110 class ReadFailedException: public InputStreamException
00111 {
00112 public:
00113
00114 explicit ReadFailedException(
00115 const std::string & reason ) :
00116 InputStreamException( reason )
00117 {
00118
00119 }
00120
00121 } ;
00122
00123
00124
00131 class EOFException: public InputStreamException
00132 {
00133 public:
00134
00135 explicit EOFException(
00136 const std::string & reason ) :
00137 InputStreamException( reason )
00138 {
00139
00140 }
00141
00142 } ;
00143
00144
00145
00154 explicit InputStream( bool blocking = true ) ;
00155
00156
00157
00159 virtual ~InputStream() throw() ;
00160
00161
00162
00164 bool isSelected() const ;
00165
00166
00167
00177 bool isFaulty() const ;
00178
00179
00180
00189 virtual StreamID getInputStreamID() const = 0 ;
00190
00191
00192
00205 virtual const std::string toString(
00206 Ceylan::VerbosityLevels level = Ceylan::high ) const ;
00207
00208
00209
00210
00211
00212
00213
00218 virtual bool hasAvailableData() const = 0 ;
00219
00220
00221
00245 virtual Size read( Ceylan::Byte * buffer, Size length ) ;
00246
00247
00248
00256 virtual void clearInput() ;
00257
00258
00259
00260
00261
00262
00263
00264
00273 virtual Ceylan::Sint8 readSint8() ;
00274
00275
00276
00285 virtual Ceylan::Uint8 readUint8() ;
00286
00287
00288
00297 virtual Ceylan::Sint16 readSint16() ;
00298
00299
00300
00309 virtual Ceylan::Uint16 readUint16() ;
00310
00311
00312
00321 virtual Ceylan::Sint32 readSint32() ;
00322
00323
00324
00333 virtual Ceylan::Uint32 readUint32() ;
00334
00335
00336
00337
00338
00339
00340
00349 virtual Ceylan::Float32 readFloat32() ;
00350
00351
00352
00361 virtual Ceylan::Float64 readFloat64() ;
00362
00363
00364
00378 virtual void readString( std::string & result ) ;
00379
00380
00381
00391 virtual void skipWhitespaces( Ceylan::Uint8 & firstNonSpace ) ;
00392
00393
00394
00395
00396
00397
00398
00399
00416 static Ceylan::Uint16 Select( std::list<InputStream*> & is ) ;
00417
00418
00419
00438 static Ceylan::Uint16 Test( std::list<InputStream*> & is ) ;
00439
00440
00441
00442
00443 protected:
00444
00445
00446
00448 virtual void setSelected( bool newStatus ) ;
00449
00450
00451
00458 void setFaulty( bool newFaultyState = true ) ;
00459
00460
00461
00469 virtual void setStreamID( StreamID newInputStreamID ) ;
00470
00471
00472
00473
00474 private:
00475
00476
00478 bool _isSelected ;
00479
00480
00482 bool _isFaulty ;
00483
00484
00485
00494 InputStream( const InputStream & source ) ;
00495
00496
00497
00506 InputStream & operator = ( const InputStream & source ) ;
00507
00508
00509 } ;
00510
00511
00512 }
00513
00514 }
00515
00516
00517
00518 #endif // CEYLAN_INPUT_STREAM_H_
00519