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
00026
00027
00028
00029
00030
00031
00032
00033
00034 #ifndef _CPP_OSTREAM
00035 #define _CPP_OSTREAM 1
00036
00037 #pragma GCC system_header
00038
00039 #include <bits/std_ios.h>
00040
00041 namespace std
00042 {
00043
00044 template<typename _CharT, typename _Traits>
00045 class basic_ostream : virtual public basic_ios<_CharT, _Traits>
00046 {
00047 public:
00048
00049
00050 typedef _CharT char_type;
00051 typedef typename _Traits::int_type int_type;
00052 typedef typename _Traits::pos_type pos_type;
00053 typedef typename _Traits::off_type off_type;
00054 typedef _Traits traits_type;
00055
00056
00057 typedef basic_streambuf<_CharT, _Traits> __streambuf_type;
00058 typedef basic_ios<_CharT, _Traits> __ios_type;
00059 typedef basic_ostream<_CharT, _Traits> __ostream_type;
00060 typedef ostreambuf_iterator<_CharT> __ostreambuf_iter;
00061 typedef num_put<_CharT, __ostreambuf_iter> __numput_type;
00062 typedef ctype<_CharT> __ctype_type;
00063
00064
00065 explicit
00066 basic_ostream(__streambuf_type* __sb)
00067 { this->init(__sb); }
00068
00069 virtual
00070 ~basic_ostream()
00071 { _M_fnumput = NULL; }
00072
00073
00074 class sentry;
00075 friend class sentry;
00076
00077
00078
00079 __ostream_type&
00080 operator<<(__ostream_type& (*__pf)(__ostream_type&));
00081
00082 __ostream_type&
00083 operator<<(__ios_type& (*__pf)(__ios_type&));
00084
00085 __ostream_type&
00086 operator<<(ios_base& (*__pf) (ios_base&));
00087
00088
00089 __ostream_type&
00090 operator<<(long __n);
00091
00092 __ostream_type&
00093 operator<<(unsigned long __n);
00094
00095 __ostream_type&
00096 operator<<(bool __n);
00097
00098 __ostream_type&
00099 operator<<(short __n)
00100 {
00101 ios_base::fmtflags __fmt = this->flags() & ios_base::basefield;
00102 if (__fmt & ios_base::oct || __fmt & ios_base::hex)
00103 return this->operator<<(static_cast<unsigned long>
00104 (static_cast<unsigned short>(__n)));
00105 else
00106 return this->operator<<(static_cast<long>(__n));
00107 }
00108
00109 __ostream_type&
00110 operator<<(unsigned short __n)
00111 { return this->operator<<(static_cast<unsigned long>(__n)); }
00112
00113 __ostream_type&
00114 operator<<(int __n)
00115 {
00116 ios_base::fmtflags __fmt = this->flags() & ios_base::basefield;
00117 if (__fmt & ios_base::oct || __fmt & ios_base::hex)
00118 return this->operator<<(static_cast<unsigned long>
00119 (static_cast<unsigned int>(__n)));
00120 else
00121 return this->operator<<(static_cast<long>(__n));
00122 }
00123
00124 __ostream_type&
00125 operator<<(unsigned int __n)
00126 { return this->operator<<(static_cast<unsigned long>(__n)); }
00127
00128 #ifdef _GLIBCPP_USE_LONG_LONG
00129 __ostream_type&
00130 operator<<(long long __n);
00131
00132 __ostream_type&
00133 operator<<(unsigned long long __n);
00134 #endif
00135
00136 __ostream_type&
00137 operator<<(double __f);
00138
00139 __ostream_type&
00140 operator<<(float __f)
00141 { return this->operator<<(static_cast<double>(__f)); }
00142
00143 __ostream_type&
00144 operator<<(long double __f);
00145
00146 __ostream_type&
00147 operator<<(const void* __p);
00148
00149 __ostream_type&
00150 operator<<(__streambuf_type* __sb);
00151
00152
00153 __ostream_type&
00154 put(char_type __c);
00155
00156 __ostream_type&
00157 write(const char_type* __s, streamsize __n);
00158
00159 __ostream_type&
00160 flush();
00161
00162
00163 pos_type
00164 tellp();
00165
00166 __ostream_type&
00167 seekp(pos_type);
00168
00169 __ostream_type&
00170 seekp(off_type, ios_base::seekdir);
00171
00172 private:
00173 #ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
00174
00175 __ostream_type&
00176 operator=(const __ostream_type&);
00177
00178 basic_ostream(const __ostream_type&);
00179 #endif
00180 };
00181
00182
00183 template <typename _CharT, typename _Traits>
00184 class basic_ostream<_CharT, _Traits>::sentry
00185 {
00186
00187 bool _M_ok;
00188 basic_ostream<_CharT,_Traits>& _M_os;
00189
00190 public:
00191 explicit
00192 sentry(basic_ostream<_CharT,_Traits>& __os);
00193
00194 ~sentry()
00195 {
00196
00197 if (_M_os.flags() & ios_base::unitbuf && !uncaught_exception())
00198 {
00199
00200 if (_M_os.rdbuf() && _M_os.rdbuf()->pubsync() == -1)
00201 _M_os.setstate(ios_base::badbit);
00202 }
00203 }
00204
00205 operator bool()
00206 { return _M_ok; }
00207 };
00208
00209 template<typename _CharT, typename _Traits>
00210 basic_ostream<_CharT, _Traits>&
00211 operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c);
00212
00213 template<typename _CharT, typename _Traits>
00214 basic_ostream<_CharT, _Traits>&
00215 operator<<(basic_ostream<_CharT, _Traits>& __out, char __c)
00216 { return (__out << __out.widen(__c)); }
00217
00218
00219 template <class _Traits>
00220 basic_ostream<char, _Traits>&
00221 operator<<(basic_ostream<char, _Traits>& __out, char __c);
00222
00223
00224 template<class _Traits>
00225 basic_ostream<char, _Traits>&
00226 operator<<(basic_ostream<char, _Traits>& __out, signed char __c)
00227 { return (__out << static_cast<char>(__c)); }
00228
00229 template<class _Traits>
00230 basic_ostream<char, _Traits>&
00231 operator<<(basic_ostream<char, _Traits>& __out, unsigned char __c)
00232 { return (__out << static_cast<char>(__c)); }
00233
00234 template<typename _CharT, typename _Traits>
00235 basic_ostream<_CharT, _Traits>&
00236 operator<<(basic_ostream<_CharT, _Traits>& __out, const _CharT* __s);
00237
00238 template<typename _CharT, typename _Traits>
00239 basic_ostream<_CharT, _Traits> &
00240 operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s);
00241
00242
00243 template<class _Traits>
00244 basic_ostream<char, _Traits>&
00245 operator<<(basic_ostream<char, _Traits>& __out, const char* __s);
00246
00247
00248 template<class _Traits>
00249 basic_ostream<char, _Traits>&
00250 operator<<(basic_ostream<char, _Traits>& __out, const signed char* __s)
00251 { return (__out << reinterpret_cast<const char*>(__s)); }
00252
00253 template<class _Traits>
00254 basic_ostream<char, _Traits> &
00255 operator<<(basic_ostream<char, _Traits>& __out, const unsigned char* __s)
00256 { return (__out << reinterpret_cast<const char*>(__s)); }
00257
00258
00259 template<typename _CharT, typename _Traits>
00260 basic_ostream<_CharT, _Traits>&
00261 endl(basic_ostream<_CharT, _Traits>& __os)
00262 { return flush(__os.put(__os.widen('\n'))); }
00263
00264 template<typename _CharT, typename _Traits>
00265 basic_ostream<_CharT, _Traits>&
00266 ends(basic_ostream<_CharT, _Traits>& __os)
00267 { return __os.put(_CharT()); }
00268
00269 template<typename _CharT, typename _Traits>
00270 basic_ostream<_CharT, _Traits>&
00271 flush(basic_ostream<_CharT, _Traits>& __os)
00272 { return __os.flush(); }
00273
00274 }
00275
00276 #ifdef _GLIBCPP_NO_TEMPLATE_EXPORT
00277 # define export
00278 #ifdef _GLIBCPP_FULLY_COMPLIANT_HEADERS
00279 # include <bits/ostream.tcc>
00280 #endif
00281 #endif
00282
00283 #endif
00284