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_MEMORY_STREAM_H_
00028 #define CEYLAN_MEMORY_STREAM_H_
00029
00030
00031 #include "CeylanSystem.h"
00032 #include "CeylanTypes.h"
00033 #include "CeylanInputOutputStream.h"
00034
00035
00036 #include <string>
00037
00038
00039
00040
00041 namespace Ceylan
00042 {
00043
00044
00045
00046 namespace System
00047 {
00048
00049
00050
00051
00058 class CEYLAN_DLL MemoryStream: public InputOutputStream
00059 {
00060
00061
00062 public:
00063
00064
00065
00067 typedef Size Index ;
00068
00069
00071 class MemoryStreamException: public SystemException
00072 {
00073 public:
00074
00075 explicit MemoryStreamException(
00076 const std::string & reason ) ;
00077
00078 virtual ~MemoryStreamException() throw() ;
00079
00080 } ;
00081
00082
00083
00090 explicit MemoryStream( Size bufferSize ) ;
00091
00092
00093
00103 virtual ~MemoryStream() throw() ;
00104
00105
00106
00111 virtual void blank() ;
00112
00113
00114
00124 virtual bool close() ;
00125
00126
00127
00128
00135 virtual Size getSize() const ;
00136
00137
00138
00155 virtual Size read( Ceylan::Byte * buffer, Size maxLength ) ;
00156
00157
00158
00163 virtual bool hasAvailableData() const ;
00164
00165
00166
00178 virtual Size write( const std::string & message ) ;
00179
00180
00181
00196 virtual Size write( const Ceylan::Byte * buffer,
00197 Size maxLength ) ;
00198
00199
00200
00201
00202
00203
00204
00205
00215 virtual Index getIndexOfNextFreeChunk() const ;
00216
00217
00218
00228 virtual Byte * getAddressOfNextFreeChunk() const ;
00229
00230
00231
00242 virtual Size getSizeOfNextFreeChunk() const ;
00243
00244
00245
00247 virtual Index getBlockIndex() const ;
00248
00249
00250
00252 virtual Size getBlockLength() const ;
00253
00254
00255
00264 virtual Ceylan::Byte getElementAt( Index targetIndex ) const ;
00265
00266
00267
00283 virtual void increaseFilledBlockOf( Size bytesAdded ) ;
00284
00285
00286
00296 virtual void moveFilledBlockToBufferStart() ;
00297
00298
00299
00300
00301
00302
00303
00304
00311 virtual StreamID getStreamID() const ;
00312
00313
00314
00320 virtual StreamID getInputStreamID() const ;
00321
00322
00323
00329 virtual StreamID getOutputStreamID() const ;
00330
00331
00332
00348 virtual const std::string toString(
00349 Ceylan::VerbosityLevels level = Ceylan::high ) const ;
00350
00351
00352
00353
00354
00355 protected:
00356
00357
00358
00360 Size _size ;
00361
00362
00368 Size _index ;
00369
00370
00375 Size _len ;
00376
00377
00379 Ceylan::Byte * _buffer ;
00380
00381
00382
00383 private:
00384
00385
00386
00395 MemoryStream( const MemoryStream & source ) ;
00396
00397
00398
00407 MemoryStream & operator = ( const MemoryStream & source ) ;
00408
00409
00410
00411 } ;
00412
00413 }
00414
00415
00416 }
00417
00418
00419
00420 #endif // CEYLAN_MEMORY_STREAM_H_
00421