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
00039 #ifndef _GLIBCXX_OSTREAM
00040 #define _GLIBCXX_OSTREAM 1
00041
00042 #pragma GCC system_header
00043
00044 #include <ios>
00045
00046 namespace std
00047 {
00048
00056 template<typename _CharT, typename _Traits>
00057 class basic_ostream : virtual public basic_ios<_CharT, _Traits>
00058 {
00059 public:
00060
00061 typedef _CharT char_type;
00062 typedef typename _Traits::int_type int_type;
00063 typedef typename _Traits::pos_type pos_type;
00064 typedef typename _Traits::off_type off_type;
00065 typedef _Traits traits_type;
00066
00067
00068 typedef basic_streambuf<_CharT, _Traits> __streambuf_type;
00069 typedef basic_ios<_CharT, _Traits> __ios_type;
00070 typedef basic_ostream<_CharT, _Traits> __ostream_type;
00071 typedef num_put<_CharT, ostreambuf_iterator<_CharT, _Traits> >
00072 __num_put_type;
00073 typedef ctype<_CharT> __ctype_type;
00074
00075 template<typename _CharT2, typename _Traits2>
00076 friend basic_ostream<_CharT2, _Traits2>&
00077 operator<<(basic_ostream<_CharT2, _Traits2>&, _CharT2);
00078
00079 template<typename _Traits2>
00080 friend basic_ostream<char, _Traits2>&
00081 operator<<(basic_ostream<char, _Traits2>&, char);
00082
00083 template<typename _CharT2, typename _Traits2>
00084 friend basic_ostream<_CharT2, _Traits2>&
00085 operator<<(basic_ostream<_CharT2, _Traits2>&, const _CharT2*);
00086
00087 template<typename _Traits2>
00088 friend basic_ostream<char, _Traits2>&
00089 operator<<(basic_ostream<char, _Traits2>&, const char*);
00090
00091 template<typename _CharT2, typename _Traits2>
00092 friend basic_ostream<_CharT2, _Traits2>&
00093 operator<<(basic_ostream<_CharT2, _Traits2>&, const char*);
00094
00095
00103 explicit
00104 basic_ostream(__streambuf_type* __sb)
00105 { this->init(__sb); }
00106
00112 virtual
00113 ~basic_ostream() { }
00114
00115
00116 class sentry;
00117 friend class sentry;
00118
00119
00120
00122
00129 inline __ostream_type&
00130 operator<<(__ostream_type& (*__pf)(__ostream_type&));
00131
00132 inline __ostream_type&
00133 operator<<(__ios_type& (*__pf)(__ios_type&));
00134
00135 inline __ostream_type&
00136 operator<<(ios_base& (*__pf) (ios_base&));
00138
00139
00166 __ostream_type&
00167 operator<<(long __n);
00168
00169 __ostream_type&
00170 operator<<(unsigned long __n);
00171
00172 __ostream_type&
00173 operator<<(bool __n);
00174
00175 __ostream_type&
00176 operator<<(short __n);
00177
00178 __ostream_type&
00179 operator<<(unsigned short __n);
00180
00181 __ostream_type&
00182 operator<<(int __n);
00183
00184 __ostream_type&
00185 operator<<(unsigned int __n);
00186
00187 #ifdef _GLIBCXX_USE_LONG_LONG
00188 __ostream_type&
00189 operator<<(long long __n);
00190
00191 __ostream_type&
00192 operator<<(unsigned long long __n);
00193 #endif
00194
00195 __ostream_type&
00196 operator<<(double __f);
00197
00198 __ostream_type&
00199 operator<<(float __f);
00200
00201 __ostream_type&
00202 operator<<(long double __f);
00203
00204 __ostream_type&
00205 operator<<(const void* __p);
00206
00228 __ostream_type&
00229 operator<<(__streambuf_type* __sb);
00231
00232
00261 __ostream_type&
00262 put(char_type __c);
00263
00264
00265 void
00266 _M_write(const char_type* __s, streamsize __n)
00267 {
00268 streamsize __put = this->rdbuf()->sputn(__s, __n);
00269 if (__put != __n)
00270 this->setstate(ios_base::badbit);
00271 }
00272
00289 __ostream_type&
00290 write(const char_type* __s, streamsize __n);
00292
00302 __ostream_type&
00303 flush();
00304
00305
00313 pos_type
00314 tellp();
00315
00324 __ostream_type&
00325 seekp(pos_type);
00326
00336 __ostream_type&
00337 seekp(off_type, ios_base::seekdir);
00338
00339 protected:
00340 explicit
00341 basic_ostream() { }
00342 };
00343
00354 template <typename _CharT, typename _Traits>
00355 class basic_ostream<_CharT, _Traits>::sentry
00356 {
00357
00358 bool _M_ok;
00359 basic_ostream<_CharT,_Traits>& _M_os;
00360
00361 public:
00373 explicit
00374 sentry(basic_ostream<_CharT,_Traits>& __os);
00375
00383 ~sentry()
00384 {
00385
00386 if (_M_os.flags() & ios_base::unitbuf && !uncaught_exception())
00387 {
00388
00389 if (_M_os.rdbuf() && _M_os.rdbuf()->pubsync() == -1)
00390 _M_os.setstate(ios_base::badbit);
00391 }
00392 }
00393
00401 operator bool() const
00402 { return _M_ok; }
00403 };
00404
00405
00407
00422 template<typename _CharT, typename _Traits>
00423 basic_ostream<_CharT, _Traits>&
00424 operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c);
00425
00426 template<typename _CharT, typename _Traits>
00427 basic_ostream<_CharT, _Traits>&
00428 operator<<(basic_ostream<_CharT, _Traits>& __out, char __c)
00429 { return (__out << __out.widen(__c)); }
00430
00431
00432 template <class _Traits>
00433 basic_ostream<char, _Traits>&
00434 operator<<(basic_ostream<char, _Traits>& __out, char __c);
00435
00436
00437 template<class _Traits>
00438 basic_ostream<char, _Traits>&
00439 operator<<(basic_ostream<char, _Traits>& __out, signed char __c)
00440 { return (__out << static_cast<char>(__c)); }
00441
00442 template<class _Traits>
00443 basic_ostream<char, _Traits>&
00444 operator<<(basic_ostream<char, _Traits>& __out, unsigned char __c)
00445 { return (__out << static_cast<char>(__c)); }
00447
00449
00462 template<typename _CharT, typename _Traits>
00463 basic_ostream<_CharT, _Traits>&
00464 operator<<(basic_ostream<_CharT, _Traits>& __out, const _CharT* __s);
00465
00466 template<typename _CharT, typename _Traits>
00467 basic_ostream<_CharT, _Traits> &
00468 operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s);
00469
00470
00471 template<class _Traits>
00472 basic_ostream<char, _Traits>&
00473 operator<<(basic_ostream<char, _Traits>& __out, const char* __s);
00474
00475
00476 template<class _Traits>
00477 basic_ostream<char, _Traits>&
00478 operator<<(basic_ostream<char, _Traits>& __out, const signed char* __s)
00479 { return (__out << reinterpret_cast<const char*>(__s)); }
00480
00481 template<class _Traits>
00482 basic_ostream<char, _Traits> &
00483 operator<<(basic_ostream<char, _Traits>& __out, const unsigned char* __s)
00484 { return (__out << reinterpret_cast<const char*>(__s)); }
00486
00487
00496 template<typename _CharT, typename _Traits>
00497 basic_ostream<_CharT, _Traits>&
00498 endl(basic_ostream<_CharT, _Traits>& __os)
00499 { return flush(__os.put(__os.widen('\n'))); }
00500
00507 template<typename _CharT, typename _Traits>
00508 basic_ostream<_CharT, _Traits>&
00509 ends(basic_ostream<_CharT, _Traits>& __os)
00510 { return __os.put(_CharT()); }
00511
00517 template<typename _CharT, typename _Traits>
00518 basic_ostream<_CharT, _Traits>&
00519 flush(basic_ostream<_CharT, _Traits>& __os)
00520 { return __os.flush(); }
00521
00522 }
00523
00524 #ifndef _GLIBCXX_EXPORT_TEMPLATE
00525 # include <bits/ostream.tcc>
00526 #endif
00527
00528 #endif