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 #ifndef __ZStream_Buffered__
00026 #define __ZStream_Buffered__ 1
00027
00028 #include "zconfig.h"
00029
00030 #include "ZStreamer.h"
00031
00032
00033 #pragma mark -
00034 #pragma mark * ZStreamR_Buffered
00035
00037
00038 class ZStreamR_Buffered : public ZStreamR
00039 {
00040 public:
00041 ZStreamR_Buffered(size_t iBufferSize, const ZStreamR& iStreamSource);
00042 ~ZStreamR_Buffered();
00043
00044
00045 virtual void Imp_Read(void* iDest, size_t iCount, size_t* oCountRead);
00046 virtual size_t Imp_CountReadable();
00047 virtual void Imp_Skip(uint64 iCount, uint64* oCountSkipped);
00048
00049
00051 void Abandon();
00052
00053 protected:
00054 const ZStreamR& fStreamSource;
00055 uint8* fBuffer;
00056 size_t fBufferSize;
00057 size_t fBufferOffset;
00058 };
00059
00060 typedef ZStreamerR_FT<ZStreamR_Buffered> ZStreamerR_Buffered;
00061
00062
00063 #pragma mark -
00064 #pragma mark * ZStreamW_Buffered
00065
00067
00068 class ZStreamW_Buffered : public ZStreamW
00069 {
00070 public:
00071 ZStreamW_Buffered(size_t iBufferSize, const ZStreamW& iStreamSink);
00072 ~ZStreamW_Buffered();
00073
00074
00075 virtual void Imp_Write(const void* iSource, size_t iCount, size_t* oCountWritten);
00076 virtual void Imp_Flush();
00077
00078
00079 void Abandon();
00080
00081 protected:
00082 void Internal_Flush();
00083
00084 const ZStreamW& fStreamSink;
00085 uint8* fBuffer;
00086 size_t fBufferSize;
00087 size_t fBufferOffset;
00088 };
00089
00090 typedef ZStreamerW_FT<ZStreamW_Buffered> ZStreamerW_Buffered;
00091
00092
00093 #pragma mark -
00094 #pragma mark * ZStreamR_DynamicBuffered
00095
00097
00098 class ZStreamR_DynamicBuffered : public ZStreamR
00099 {
00100 public:
00101 ZStreamR_DynamicBuffered(const ZStreamR& iStreamSource, const ZStreamRWPos& iStreamBuffer);
00102 ~ZStreamR_DynamicBuffered();
00103
00104
00105 virtual void Imp_Read(void* iDest, size_t iCount, size_t* oCountRead);
00106 virtual size_t Imp_CountReadable();
00107
00108
00109 void Rewind();
00110 void Commit();
00111
00112 protected:
00113 const ZStreamR& fStreamSource;
00114 const ZStreamRWPos& fStreamBuffer;
00115 enum { eModeReadBufferThenAppend, eModeReadBufferThenStream, eModeAppend, eModeStream } fMode;
00116 };
00117
00118
00119 #pragma mark -
00120 #pragma mark * ZStreamerR_DynamicBuffered
00121
00123
00124 class ZStreamerR_DynamicBuffered : public ZStreamerR
00125 {
00126 public:
00127 ZStreamerR_DynamicBuffered(ZRef<ZStreamerR> iStreamerSource,
00128 ZRef<ZStreamerRWPos> iStreamerBuffer);
00129
00130 virtual ~ZStreamerR_DynamicBuffered();
00131
00132
00133 virtual const ZStreamR& GetStreamR();
00134
00135
00136 ZStreamR_DynamicBuffered& GetStream();
00137
00138 protected:
00139 ZRef<ZStreamerR> fStreamerSource;
00140 ZRef<ZStreamerR> fStreamerBuffer;
00141 ZStreamR_DynamicBuffered fStream;
00142 };
00143
00144
00145 #pragma mark -
00146 #pragma mark * ZStreamW_DynamicBuffered
00147
00149
00150 class ZStreamW_DynamicBuffered : public ZStreamW
00151 {
00152 public:
00153 ZStreamW_DynamicBuffered(const ZStreamW& iStreamSink, const ZStreamRWPos& iStreamBuffer);
00154 ~ZStreamW_DynamicBuffered();
00155
00156
00157 virtual void Imp_Write(const void* iSource, size_t iCount, size_t* oCountWritten);
00158
00159 virtual void Imp_CopyFromDispatch(const ZStreamR& iStreamR, uint64 iCount,
00160 uint64* oCountRead, uint64* oCountWritten);
00161
00162 virtual void Imp_CopyFrom(const ZStreamR& iStreamR, uint64 iCount,
00163 uint64* oCountRead, uint64* oCountWritten);
00164
00165 virtual void Imp_Flush();
00166
00167 protected:
00168 void Internal_Flush();
00169
00170 const ZStreamW& fStreamSink;
00171 const ZStreamRWPos& fStreamBuffer;
00172 };
00173
00174
00175 #pragma mark -
00176 #pragma mark * ZStreamerW_DynamicBuffered
00177
00179
00180 class ZStreamerW_DynamicBuffered : public ZStreamerW
00181 {
00182 public:
00183 ZStreamerW_DynamicBuffered(
00184 ZRef<ZStreamerW> iStreamerReal, ZRef<ZStreamerRWPos> iStreamerBuffer);
00185
00186 virtual ~ZStreamerW_DynamicBuffered();
00187
00188
00189 virtual const ZStreamW& GetStreamW();
00190
00191 protected:
00192 ZRef<ZStreamerW> fStreamerSink;
00193 ZRef<ZStreamerRWPos> fStreamerBuffer;
00194 ZStreamW_DynamicBuffered fStream;
00195 };
00196
00197 #endif // __ZStream_Buffered__