00001
00002
00003
00004
00005
00006
00007 #ifndef COH_OCTET_ARRAY_WRITE_BUFFER_HPP
00008 #define COH_OCTET_ARRAY_WRITE_BUFFER_HPP
00009
00010 #include "coherence/lang.ns"
00011
00012 #include "coherence/io/AbstractWriteBuffer.hpp"
00013 #include "coherence/io/ReadBuffer.hpp"
00014
00015 #include <limits>
00016
00017 COH_OPEN_NAMESPACE2(coherence,io)
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 class COH_EXPORT OctetArrayWriteBuffer
00030 : public cloneable_spec<OctetArrayWriteBuffer,
00031 extends<AbstractWriteBuffer> >
00032 {
00033 friend class factory<OctetArrayWriteBuffer>;
00034
00035
00036
00037 public:
00038 typedef this_spec::Handle Handle;
00039 typedef this_spec::View View;
00040 typedef this_spec::Holder Holder;
00041
00042
00043
00044
00045 protected:
00046
00047
00048
00049
00050
00051
00052
00053 OctetArrayWriteBuffer(Array<octet_t>::Handle hab);
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065 OctetArrayWriteBuffer(size32_t cbCap,
00066 size32_t cbMax = (std::numeric_limits<size32_t>::max)());
00067
00068
00069
00070
00071 OctetArrayWriteBuffer(const OctetArrayWriteBuffer& that);
00072
00073
00074
00075
00076 public:
00077
00078
00079
00080 virtual size32_t length() const;
00081
00082
00083
00084
00085 virtual size32_t getCapacity() const;
00086
00087
00088
00089
00090 virtual size32_t getMaximumCapacity() const;
00091
00092
00093
00094
00095 virtual void write(size32_t ofDest, octet_t b);
00096
00097
00098
00099
00100 virtual void write(size32_t ofDest, Array<octet_t>::View vabSrc,
00101 size32_t ofSrc, size32_t cbSrc);
00102
00103
00104
00105
00106 virtual void write(size32_t ofDest, ReadBuffer::View vBufSrc,
00107 size32_t ofSrc, size32_t cbSrc);
00108
00109
00110
00111
00112 using AbstractWriteBuffer::write;
00113
00114
00115
00116
00117 virtual void retain(size32_t of, size32_t cb);
00118
00119
00120
00121
00122 using AbstractWriteBuffer::retain;
00123
00124
00125
00126
00127 virtual ReadBuffer::View getUnsafeReadBuffer() const;
00128
00129
00130
00131
00132 protected:
00133
00134
00135
00136 virtual BufferOutput::Handle instantiateBufferOutput();
00137
00138
00139
00140
00141
00142
00143
00144
00145 virtual void checkBounds(size32_t of, size32_t cb);
00146
00147
00148
00149
00150
00151
00152 virtual void grow(size32_t cbCap);
00153
00154
00155
00156
00157
00158
00159
00160
00161 virtual void updateLength(size32_t cb);
00162
00163
00164
00165
00166 public:
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176 class COH_EXPORT OctetArrayBufferOutput
00177 : public class_spec<OctetArrayBufferOutput,
00178 extends<AbstractBufferOutput> >
00179 {
00180 friend class factory<OctetArrayBufferOutput>;
00181
00182
00183
00184 protected:
00185
00186
00187
00188
00189
00190
00191 OctetArrayBufferOutput(OctetArrayWriteBuffer::Handle hBuf);
00192
00193
00194
00195 public:
00196
00197
00198
00199 virtual void writeChar16(wchar16_t ch);
00200
00201
00202
00203
00204 virtual void writeString(String::View vs);
00205
00206
00207
00208
00209 virtual void writeInt16(int16_t n);
00210
00211
00212
00213
00214 virtual void writeInt32(int32_t n);
00215
00216
00217
00218
00219 virtual void writeInt64(int64_t n);
00220
00221
00222
00223
00224 virtual void writeFloat32(float32_t fl);
00225
00226
00227
00228
00229 virtual void writeFloat64(float64_t dfl);
00230
00231
00232
00233 protected:
00234
00235
00236
00237
00238
00239 virtual void moveOffset(size32_t cb);
00240
00241
00242
00243 protected:
00244
00245
00246
00247 FinalHandle<OctetArrayWriteBuffer> f_hBuf;
00248 };
00249
00250
00251
00252
00253 protected:
00254
00255
00256
00257 virtual void onEscape(bool fEscaped) const;
00258
00259
00260
00261
00262 protected:
00263
00264
00265
00266 MemberHandle<Array<octet_t> > m_hab;
00267
00268
00269
00270
00271
00272 mutable octet_t* m_pab;
00273
00274
00275
00276
00277 size32_t m_cbab;
00278
00279
00280
00281
00282
00283 size32_t m_cb;
00284
00285
00286
00287
00288
00289 size32_t m_cbMax;
00290
00291
00292
00293
00294
00295 mutable MemberHandle<ReadBuffer> m_hBufUnsafe;
00296 };
00297
00298 COH_CLOSE_NAMESPACE2
00299
00300 #endif // COH_OCTET_ARRAY_WRITE_BUFFER_HPP