00001
00002
00003 #ifndef ACE_IOSTREAM_T_C
00004 #define ACE_IOSTREAM_T_C
00005
00006 #include "ace/IOStream_T.h"
00007
00008 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00009 # pragma once
00010 #endif
00011
00012 ACE_RCSID(ace, IOStream_T, "$Id: IOStream_T.cpp,v 1.1.1.3 2001/12/04 14:33:02 chad Exp $")
00013
00014 #if !defined (ACE_LACKS_ACE_IOSTREAM)
00015
00016 #if defined (ACE_HAS_MINIMUM_IOSTREAMH_INCLUSION) && defined (__GNUG__)
00017 # if !defined (ACE_IOSTREAM_T_H)
00018
00019
00020
00021
00022
00023
00024
00025
00026 int ACE_IOStream_global_of_builtin_type_to_avoid_munch_problems = 0;
00027 # endif
00028 #endif
00029
00030 #if !defined (__ACE_INLINE__)
00031 #include "ace/IOStream_T.i"
00032 #endif
00033
00034
00035
00036
00037
00038 template <class STREAM>
00039 ACE_Streambuf_T<STREAM>::ACE_Streambuf_T (STREAM *peer,
00040 u_int streambuf_size,
00041 int io_mode)
00042 : ACE_Streambuf (streambuf_size, io_mode),
00043 peer_ (peer)
00044 {
00045
00046
00047
00048
00049
00050
00051
00052 #if !defined (ACE_LACKS_UNBUFFERED_STREAMBUF)
00053 this->unbuffered (0);
00054 #endif
00055
00056
00057
00058
00059 #if !defined (ACE_LACKS_LINEBUFFERED_STREAMBUF)
00060 this->linebuffered (0);
00061 #endif
00062 }
00063
00064
00065
00066
00067
00068 template <class STREAM>
00069 ACE_IOStream<STREAM>::ACE_IOStream (STREAM &stream,
00070 u_int streambuf_size)
00071 : iostream (0),
00072 STREAM (stream)
00073 {
00074 ACE_NEW (streambuf_,
00075 ACE_Streambuf_T<STREAM> ((STREAM *) this,
00076 streambuf_size));
00077 iostream::init (this->streambuf_);
00078 }
00079
00080 template <class STREAM>
00081 ACE_IOStream<STREAM>::ACE_IOStream (u_int streambuf_size)
00082 : iostream (0)
00083 {
00084 ACE_NEW (this->streambuf_,
00085 ACE_Streambuf_T<STREAM> ((STREAM *) this,
00086 streambuf_size));
00087 iostream::init (this->streambuf_);
00088 }
00089
00090
00091
00092
00093 template <class STREAM>
00094 ACE_IOStream<STREAM>::~ACE_IOStream (void)
00095 {
00096 delete this->streambuf_;
00097 }
00098
00099
00100
00101
00102 template <class STREAM> int
00103 ACE_IOStream<STREAM>::close (void)
00104 {
00105 return STREAM::close ();
00106 }
00107
00108 template <class STREAM> ACE_IOStream<STREAM> &
00109 ACE_IOStream<STREAM>::operator>> (ACE_Time_Value *&tv)
00110 {
00111 ACE_Time_Value *old_tv = this->streambuf_->recv_timeout (tv);
00112 tv = old_tv;
00113 return *this;
00114 }
00115
00116 #if defined (ACE_HAS_STRING_CLASS)
00117
00118
00119
00120
00121
00122 template <class STREAM> ACE_IOStream<STREAM> &
00123 ACE_IOStream<STREAM>::operator>> (ACE_IOStream_String &v)
00124 {
00125 if (ipfx0 ())
00126 {
00127 char c;
00128 this->get (c);
00129
00130 for (v = c;
00131 this->get (c) && !isspace (c);
00132 v += c)
00133 continue;
00134 }
00135
00136 isfx ();
00137
00138 return *this;
00139 }
00140
00141 template <class STREAM> ACE_IOStream<STREAM> &
00142 ACE_IOStream<STREAM>::operator<< (ACE_IOStream_String &v)
00143 {
00144 if (opfx ())
00145 {
00146 #if defined (ACE_WIN32) && defined (_MSC_VER)
00147 for (int i = 0; i < v.GetLength (); ++i)
00148 #else
00149 for (u_int i = 0; i < (u_int) v.length (); ++i)
00150 #endif
00151 this->put (v[i]);
00152 }
00153
00154 osfx ();
00155
00156 return *this;
00157 }
00158
00159
00160
00161
00162 template <class STREAM> STREAM &
00163 operator>> (STREAM &stream,
00164 ACE_Quoted_String &str)
00165 {
00166 char c;
00167
00168 if (!(stream >> c))
00169
00170 return stream;
00171
00172 str = "";
00173
00174
00175 if (c != '"')
00176 for (str = c; stream.get (c) && !isspace (c); str += c)
00177 continue;
00178 else
00179 for (; stream.get (c) && c != '"'; str += c)
00180 if (c == '\\')
00181 {
00182 stream.get (c);
00183 if (c != '"')
00184 str += '\\';
00185 }
00186
00187 return stream;
00188 }
00189
00190 template <class STREAM> STREAM &
00191 operator<< (STREAM &stream,
00192 ACE_Quoted_String &str)
00193 {
00194 stream.put ('"');
00195
00196 for (u_int i = 0; i < str.length (); ++i)
00197 {
00198 if (str[i] == '"')
00199 stream.put ('\\');
00200 stream.put (str[i]);
00201 }
00202
00203 stream.put ('"');
00204
00205 return stream;
00206 }
00207
00208 #endif
00209 #endif
00210 #endif