00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef ACE_IOSTREAM_H
00015 #define ACE_IOSTREAM_H
00016 #include "ace/pre.h"
00017
00018 #include "ace/config-all.h"
00019
00020 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00021 # pragma once
00022 #endif
00023
00024
00025
00026
00027
00028
00029 #if defined (ACE_HAS_STANDARD_CPP_LIBRARY) && (ACE_HAS_STANDARD_CPP_LIBRARY == 1)
00030 # if !defined (ACE_USES_OLD_IOSTREAMS) && !defined (ACE_LACKS_ACE_IOSTREAM)
00031 # define ACE_LACKS_ACE_IOSTREAM
00032 # endif
00033 #endif
00034
00035 #if !defined (ACE_LACKS_ACE_IOSTREAM)
00036
00037 #include "ace/OS.h"
00038 #include "ace/streams.h"
00039
00040 #if defined (ACE_HAS_STRING_CLASS)
00041 #if defined (ACE_WIN32) && defined (_MSC_VER)
00042 typedef CString ACE_IOStream_String;
00043 #else
00044 #if !defined (ACE_HAS_STDCPP_STL_INCLUDES)
00045 #include <String.h>
00046 typedef String ACE_IOStream_String;
00047 #else
00048 #include <string>
00049
00050 #if defined(ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB)
00051 typedef std::string ACE_IOStream_String;
00052 #else
00053 typedef string ACE_IOStream_String;
00054 #endif
00055 #endif
00056 #endif
00057
00058 #if defined (__DECCXX_VER)
00059 # if __DECCXX_VER < 50700000
00060 # include <stl_macros>
00061 # else
00062 # include <stdcomp>
00063 # endif
00064 #endif
00065
00066 class ACE_Export ACE_Quoted_String : public ACE_IOStream_String
00067 {
00068 public:
00069 inline ACE_Quoted_String (void) { *this = ""; }
00070 inline ACE_Quoted_String (const char *c) { *this = ACE_IOStream_String (c); }
00071 inline ACE_Quoted_String (const ACE_IOStream_String &s) { *this = s; }
00072 inline ACE_Quoted_String &operator= (const ACE_IOStream_String& s)
00073 {
00074 return (ACE_Quoted_String &) ACE_IOStream_String::operator= (s);
00075 }
00076 inline ACE_Quoted_String &operator = (const char c) {
00077 return (ACE_Quoted_String &) ACE_IOStream_String::operator= (c);
00078 }
00079 inline ACE_Quoted_String &operator = (const char *c) {
00080 return (ACE_Quoted_String &) ACE_IOStream_String::operator= (c);
00081 }
00082 inline int operator < (const ACE_Quoted_String &s) const {
00083 return *(ACE_IOStream_String *) this < (ACE_IOStream_String) s;
00084 }
00085 #if defined (ACE_WIN32) && defined (_MSC_VER)
00086 inline int length (void) { return this->GetLength (); }
00087 #endif
00088 };
00089
00090 #endif
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144 class ACE_Export ACE_Streambuf : public streambuf
00145 {
00146 public:
00147
00148
00149
00150
00151
00152
00153
00154 virtual ~ACE_Streambuf (void);
00155
00156
00157 ACE_Time_Value *recv_timeout (ACE_Time_Value *tv = NULL);
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168 char *reset_put_buffer (char *newBuffer = NULL,
00169 u_int _streambuf_size = 0,
00170 u_int _pptr = 0 );
00171
00172
00173
00174 u_int put_avail (void);
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185 char *reset_get_buffer (char *newBuffer = NULL,
00186 u_int _streambuf_size = 0,
00187 u_int _gptr = 0,
00188 u_int _egptr = 0);
00189
00190
00191
00192 u_int get_waiting (void);
00193
00194
00195
00196 u_int get_avail (void);
00197
00198
00199 u_int streambuf_size (void);
00200
00201
00202
00203 u_char timeout (void);
00204
00205 protected:
00206 ACE_Streambuf (u_int streambuf_size,
00207 int io_mode);
00208
00209
00210
00211 virtual int sync (void);
00212
00213
00214 virtual int underflow (void);
00215
00216
00217
00218 virtual int overflow (int = EOF);
00219
00220
00221
00222 void reset_base (void);
00223
00224 protected:
00225
00226 char *eback_saved_;
00227 char *gptr_saved_;
00228 char *egptr_saved_;
00229 char *pbase_saved_;
00230 char *pptr_saved_;
00231 char *epptr_saved_;
00232
00233
00234
00235
00236 u_char cur_mode_;
00237 const u_char get_mode_;
00238 const u_char put_mode_;
00239
00240
00241
00242 int mode_;
00243
00244
00245
00246 const u_int streambuf_size_;
00247
00248
00249 u_char timeout_;
00250
00251
00252
00253 ACE_Time_Value recv_timeout_value_;
00254 ACE_Time_Value *recv_timeout_;
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265 int syncin (void);
00266
00267
00268
00269 int syncout (void);
00270
00271
00272
00273 int flushbuf (void);
00274
00275
00276
00277
00278
00279
00280 int fillbuf (void);
00281
00282
00283
00284
00285
00286
00287
00288 virtual int get_one_byte (void);
00289
00290
00291
00292
00293
00294
00295
00296 virtual ssize_t send (char *buf,
00297 ssize_t len) = 0;
00298 virtual ssize_t recv (char *buf,
00299 ssize_t len,
00300 ACE_Time_Value *tv = NULL) = 0;
00301 virtual ssize_t recv (char *buf,
00302 ssize_t len,
00303 int flags,
00304 ACE_Time_Value *tv = NULL) = 0;
00305 virtual ssize_t recv_n (char *buf,
00306 ssize_t len,
00307 int flags = 0,
00308 ACE_Time_Value *tv = NULL) = 0;
00309
00310 virtual ACE_HANDLE get_handle (void);
00311
00312 #if defined (ACE_HAS_STANDARD_CPP_LIBRARY) && (ACE_HAS_STANDARD_CPP_LIBRARY != 0) && !defined (ACE_USES_OLD_IOSTREAMS)
00313 char *base (void) const
00314 {
00315 return cur_mode_ == get_mode_ ? eback_saved_
00316 : cur_mode_ == put_mode_ ? pbase_saved_
00317 : 0;
00318 }
00319 char *ebuf (void) const
00320 {
00321 return cur_mode_ == 0 ? 0 : base () + streambuf_size_;
00322 }
00323
00324 int blen (void) const
00325 {
00326 return streambuf_size_;
00327 }
00328
00329 void setb (char* b, char* eb, int =0)
00330 {
00331 setbuf (b, (eb - b));
00332 }
00333
00334 int out_waiting (void)
00335 {
00336 return pptr () - pbase ();
00337 }
00338 #endif
00339 };
00340
00341
00342
00343
00344
00345
00346
00347 typedef ios& (*__manip_)(ios&);
00348 typedef istream& (*__imanip_)(istream&);
00349 typedef ostream& (*__omanip_)(ostream&);
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360 #define GET_SIG(MT,DT) inline virtual MT& operator>> (DT v)
00361 #if defined (__KCC) || (defined (__SUNPRO_CC) && __SUNPRO_CC > 0x510)
00362 #define GET_CODE { \
00363 if (ipfx (0)) \
00364 { \
00365 (*((istream*)this)) >> (v); \
00366 } \
00367 isfx (); \
00368 return *this; \
00369 }
00370 #else
00371 #define GET_CODE { \
00372 if (ipfx (0)) \
00373 { \
00374 iostream::operator>> (v); \
00375 } \
00376 isfx (); \
00377 return *this; \
00378 }
00379 #endif
00380 #define GET_PROT(MT,DT,CODE) GET_SIG(MT,DT) CODE
00381 #define GET_FUNC(MT,DT) GET_PROT(MT,DT,GET_CODE)
00382
00383
00384
00385
00386
00387 #define PUT_SIG(MT,DT) inline virtual MT& operator<< (DT v)
00388 #if defined (__KCC) || (defined (__SUNPRO_CC) && __SUNPRO_CC > 0x510)
00389 #define PUT_CODE { \
00390 if (opfx ()) \
00391 { \
00392 (*((ostream *) this)) << (v); \
00393 } \
00394 osfx (); \
00395 return *this; \
00396 }
00397 #else
00398 #define PUT_CODE { \
00399 if (opfx ()) \
00400 { \
00401 iostream::operator<< (v); \
00402 } \
00403 osfx (); \
00404 return *this; \
00405 }
00406 #endif
00407 #define PUT_PROT(MT,DT,CODE) PUT_SIG(MT,DT) CODE
00408 #define PUT_FUNC(MT,DT) PUT_PROT(MT,DT,PUT_CODE)
00409
00410
00411
00412
00413
00414 #if defined (ACE_LACKS_CHAR_STAR_RIGHT_SHIFTS)
00415 #define GET_FUNC_SET0(MT,CODE,CODE2) \
00416 GET_PROT(MT,short &,CODE) \
00417 GET_PROT(MT,u_short &,CODE) \
00418 GET_PROT(MT,int &,CODE) \
00419 GET_PROT(MT,u_int &,CODE) \
00420 GET_PROT(MT,long &,CODE) \
00421 GET_PROT(MT,u_long &,CODE) \
00422 GET_PROT(MT,float &,CODE) \
00423 GET_PROT(MT,double &,CODE) \
00424 GET_PROT(MT,char &,CODE) \
00425 GET_PROT(MT,u_char &,CODE) \
00426 GET_PROT(MT,char *,CODE) \
00427 inline virtual MT& operator>>(__omanip_ func) CODE2 \
00428 inline virtual MT& operator>>(__manip_ func) CODE2
00429 #elif defined (ACE_LACKS_CHAR_RIGHT_SHIFTS)
00430 #define GET_FUNC_SET0(MT,CODE,CODE2) \
00431 GET_PROT(MT,short &,CODE) \
00432 GET_PROT(MT,u_short &,CODE) \
00433 GET_PROT(MT,int &,CODE) \
00434 GET_PROT(MT,u_int &,CODE) \
00435 GET_PROT(MT,long &,CODE) \
00436 GET_PROT(MT,u_long &,CODE) \
00437 GET_PROT(MT,float &,CODE) \
00438 GET_PROT(MT,double &,CODE) \
00439 inline virtual MT& operator>>(__omanip_ func) CODE2 \
00440 inline virtual MT& operator>>(__manip_ func) CODE2
00441 #else
00442 #define GET_FUNC_SET0(MT,CODE,CODE2) \
00443 GET_PROT(MT,short &,CODE) \
00444 GET_PROT(MT,u_short &,CODE) \
00445 GET_PROT(MT,int &,CODE) \
00446 GET_PROT(MT,u_int &,CODE) \
00447 GET_PROT(MT,long &,CODE) \
00448 GET_PROT(MT,u_long &,CODE) \
00449 GET_PROT(MT,float &,CODE) \
00450 GET_PROT(MT,double &,CODE) \
00451 GET_PROT(MT,char &,CODE) \
00452 GET_PROT(MT,u_char &,CODE) \
00453 GET_PROT(MT,char *,CODE) \
00454 GET_PROT(MT,u_char *,CODE) \
00455 inline virtual MT& operator>>(__omanip_ func) CODE2 \
00456 inline virtual MT& operator>>(__manip_ func) CODE2
00457 #endif
00458
00459 #define PUT_FUNC_SET0(MT,CODE,CODE2) \
00460 PUT_PROT(MT,short,CODE) \
00461 PUT_PROT(MT,u_short,CODE) \
00462 PUT_PROT(MT,int,CODE) \
00463 PUT_PROT(MT,u_int,CODE) \
00464 PUT_PROT(MT,long,CODE) \
00465 PUT_PROT(MT,u_long,CODE) \
00466 PUT_PROT(MT,float,CODE) \
00467 PUT_PROT(MT,double,CODE) \
00468 PUT_PROT(MT,char,CODE) \
00469 PUT_PROT(MT,u_char,CODE) \
00470 PUT_PROT(MT,const char *,CODE) \
00471 PUT_PROT(MT,u_char *,CODE) \
00472 PUT_PROT(MT,void *,CODE) \
00473 inline virtual MT& operator<<(__omanip_ func) CODE2 \
00474 inline virtual MT& operator<<(__manip_ func) CODE2
00475
00476 #if defined (ACE_LACKS_SIGNED_CHAR)
00477 #define GET_FUNC_SET1(MT,CODE,CODE2) GET_FUNC_SET0(MT,CODE,CODE2)
00478 #define PUT_FUNC_SET1(MT,CODE,CODE2) PUT_FUNC_SET0(MT,CODE,CODE2)
00479 #else
00480 #if defined (ACE_LACKS_CHAR_STAR_RIGHT_SHIFTS)
00481 #define GET_FUNC_SET1(MT,CODE,CODE2) \
00482 GET_PROT(MT,signed char &,CODE) \
00483 GET_FUNC_SET0(MT,CODE,CODE2)
00484 #else
00485 #define GET_FUNC_SET1(MT,CODE,CODE2) \
00486 GET_PROT(MT,signed char &,CODE) \
00487 GET_PROT(MT,signed char *,CODE) \
00488 GET_FUNC_SET0(MT,CODE,CODE2)
00489 #endif
00490
00491 #define PUT_FUNC_SET1(MT,CODE,CODE2) \
00492 PUT_FUNC(MT,signed char) \
00493 PUT_FUNC(MT,const signed char *) \
00494 PUT_FUNC_SET0(MT,CODE,CODE2)
00495 #endif
00496
00497 #define GET_MANIP_CODE { if (ipfx ()) { (*func) (*this); } isfx (); return *this; }
00498 #define PUT_MANIP_CODE { if (opfx ()) { (*func) (*this); } osfx (); return *this; }
00499
00500 #define GET_FUNC_SET(MT) GET_FUNC_SET1(MT,GET_CODE,GET_MANIP_CODE)
00501 #define PUT_FUNC_SET(MT) PUT_FUNC_SET1(MT,PUT_CODE,PUT_MANIP_CODE)
00502 #define GETPUT_FUNC_SET(MT) GET_FUNC_SET(MT) PUT_FUNC_SET(MT)
00503
00504 #define GET_SIG_SET(MT) GET_FUNC_SET1(MT,= 0;,= 0;)
00505 #define PUT_SIG_SET(MT) PUT_FUNC_SET1(MT,= 0;,= 0;)
00506 #define GETPUT_SIG_SET(MT) GET_SIG_SET(MT) PUT_SIG_SET(MT)
00507
00508
00509 #include "ace/IOStream_T.h"
00510 #endif
00511
00512 #include "ace/post.h"
00513 #endif