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