00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef ACE_IOSTREAM_T_H
00019 #define ACE_IOSTREAM_T_H
00020 #include "ace/pre.h"
00021
00022 #include "ace/IOStream.h"
00023
00024 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00025 # pragma once
00026 #endif
00027
00028 #if !defined (ACE_LACKS_ACE_IOSTREAM)
00029
00030 # include "ace/INET_Addr.h"
00031 # include "ace/Global_Macros.h"
00032
00033 # if defined (ACE_LACKS_IOSTREAM_FX)
00034 # include "ace/os_include/os_ctype.h"
00035 # endif
00036
00037 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00038
00039 # if defined (ACE_HAS_STRING_CLASS)
00040 template <class STREAM> STREAM & operator>> (STREAM &stream, ACE_Quoted_String &str);
00041 template <class STREAM> STREAM & operator<< (STREAM &stream, ACE_Quoted_String &str);
00042 # endif
00043
00044 template <class STREAM>
00045 class ACE_Streambuf_T : public ACE_Streambuf
00046 {
00047 public:
00048
00049
00050
00051
00052
00053
00054 ACE_Streambuf_T (STREAM *peer,
00055 u_int streambuf_size = ACE_STREAMBUF_SIZE,
00056 int io_mode = ios::in | ios::out);
00057
00058 virtual ssize_t send (char *buf, ssize_t len);
00059
00060 virtual ssize_t recv (char *buf,
00061 ssize_t len,
00062 ACE_Time_Value *tv = 0);
00063
00064 virtual ssize_t recv (char *buf,
00065 ssize_t len,
00066 int flags,
00067 ACE_Time_Value * tv = 0);
00068
00069 virtual ssize_t recv_n (char *buf,
00070 ssize_t len,
00071 int flags = 0,
00072 ACE_Time_Value *tv = 0);
00073
00074 protected:
00075 virtual ACE_HANDLE get_handle (void);
00076
00077
00078 STREAM *peer_;
00079 };
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110 template <class STREAM>
00111 class ACE_IOStream : public iostream, public STREAM
00112 {
00113 public:
00114
00115 ACE_IOStream (STREAM &stream,
00116 u_int streambuf_size = ACE_STREAMBUF_SIZE);
00117
00118
00119
00120
00121
00122
00123 ACE_IOStream (u_int streambuf_size = ACE_STREAMBUF_SIZE);
00124
00125
00126
00127 virtual ~ACE_IOStream (void);
00128
00129
00130
00131 virtual int close (void);
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141 int eof (void) const;
00142
00143 # if defined (ACE_HAS_STRING_CLASS)
00144
00145
00146
00147
00148
00149 virtual ACE_IOStream<STREAM> &operator>> (ACE_IOStream_String &v);
00150
00151
00152 virtual ACE_IOStream<STREAM> &operator<< (ACE_IOStream_String &v);
00153
00154 # endif
00155
00156 GETPUT_FUNC_SET (ACE_IOStream<STREAM>)
00157
00158 # if defined (ACE_LACKS_IOSTREAM_FX)
00159 virtual int ipfx (int noskip = 0)
00160 {
00161 if (good ())
00162 {
00163 if (tie () != 0)
00164 tie ()->flush ();
00165 if (!noskip && flags () & skipws)
00166 {
00167 int ch;
00168 while (isspace (ch = rdbuf ()->sbumpc ()))
00169 continue;
00170 if (ch != EOF)
00171 rdbuf ()->sputbackc (ch);
00172 }
00173 if (good ())
00174 return 1;
00175 }
00176 # if !defined (ACE_WIN32)
00177
00178 setstate (failbit);
00179 # endif
00180 return (0);
00181 }
00182 virtual int ipfx0 (void) { return ipfx (0); }
00183 virtual int ipfx1 (void)
00184 {
00185 if (good ())
00186 {
00187 if (tie () != 0)
00188 tie ()->flush ();
00189 if (good ())
00190 return 1;
00191 }
00192 # if !defined (ACE_WIN32)
00193
00194 setstate (failbit);
00195 # endif
00196 return (0);
00197 }
00198 virtual void isfx (void) { return; }
00199 virtual int opfx (void)
00200 {
00201 if (good () && tie () != 0)
00202 tie ()->flush ();
00203 return good ();
00204 }
00205 virtual void osfx (void) { if (flags () & unitbuf) flush (); }
00206 # else
00207 # if defined (__GNUC__)
00208 virtual int ipfx0 (void) { return iostream::ipfx0 (); }
00209 virtual int ipfx1 (void) { return iostream::ipfx1 (); }
00210 # else
00211 virtual int ipfx0 (void) { return iostream::ipfx (0); }
00212 virtual int ipfx1 (void) { return iostream::ipfx (1); }
00213 # endif
00214 virtual int ipfx (int need = 0) { return iostream::ipfx (need); }
00215 virtual void isfx (void) { iostream::isfx (); }
00216 virtual int opfx (void) { return iostream::opfx (); }
00217 virtual void osfx (void) { iostream::osfx (); }
00218 # endif
00219
00220
00221
00222 ACE_IOStream<STREAM> & operator>> (ACE_Time_Value *&tv);
00223
00224 protected:
00225
00226
00227 ACE_Streambuf_T<STREAM> *streambuf_;
00228
00229 private:
00230
00231
00232
00233
00234
00235
00236
00237 ACE_UNIMPLEMENTED_FUNC (ssize_t send (...))
00238 ACE_UNIMPLEMENTED_FUNC (ssize_t recv (...))
00239 ACE_UNIMPLEMENTED_FUNC (ssize_t send_n (...))
00240 ACE_UNIMPLEMENTED_FUNC (ssize_t recv_n (...))
00241 };
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256 template <class STREAM>
00257 class ACE_SOCK_Dgram_SC : public STREAM
00258 {
00259 public:
00260 ACE_SOCK_Dgram_SC (void);
00261 ACE_SOCK_Dgram_SC (STREAM &source,
00262 ACE_INET_Addr &dest);
00263 ssize_t send_n (char *buf, ssize_t len);
00264 ssize_t recv (char *buf,
00265 ssize_t len,
00266 ACE_Time_Value *tv = 0);
00267 ssize_t recv (char *buf,
00268 ssize_t len,
00269 int flags,
00270 ACE_Time_Value *tv = 0);
00271 ssize_t recv_n (char *buf,
00272 ssize_t len,
00273 int flags = 0,
00274 ACE_Time_Value *tv = 0);
00275 int get_remote_addr (ACE_INET_Addr &addr) const;
00276
00277 protected:
00278 ACE_INET_Addr peer_;
00279 };
00280
00281 ACE_END_VERSIONED_NAMESPACE_DECL
00282
00283 # if defined (__ACE_INLINE__)
00284 # include "ace/IOStream_T.inl"
00285 # endif
00286
00287 # if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
00288 # include "ace/IOStream_T.cpp"
00289 # endif
00290
00291 # if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
00292 # pragma implementation ("IOStream_T.cpp")
00293 # endif
00294 #endif
00295
00296 #include "ace/post.h"
00297 #endif