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 _GLIBCXX_ISTREAM
00041 #define _GLIBCXX_ISTREAM 1
00042
00043 #pragma GCC system_header
00044
00045 #include <ios>
00046 #include <limits>
00047
00048 namespace std
00049 {
00050
00058 template<typename _CharT, typename _Traits>
00059 class basic_istream : virtual public basic_ios<_CharT, _Traits>
00060 {
00061 public:
00062
00063 typedef _CharT char_type;
00064 typedef typename _Traits::int_type int_type;
00065 typedef typename _Traits::pos_type pos_type;
00066 typedef typename _Traits::off_type off_type;
00067 typedef _Traits traits_type;
00068
00069
00070 typedef basic_streambuf<_CharT, _Traits> __streambuf_type;
00071 typedef basic_ios<_CharT, _Traits> __ios_type;
00072 typedef basic_istream<_CharT, _Traits> __istream_type;
00073 typedef num_get<_CharT, istreambuf_iterator<_CharT, _Traits> >
00074 __num_get_type;
00075 typedef ctype<_CharT> __ctype_type;
00076
00077 template<typename _CharT2, typename _Traits2>
00078 friend basic_istream<_CharT2, _Traits2>&
00079 operator>>(basic_istream<_CharT2, _Traits2>&, _CharT2&);
00080
00081 template<typename _CharT2, typename _Traits2>
00082 friend basic_istream<_CharT2, _Traits2>&
00083 operator>>(basic_istream<_CharT2, _Traits2>&, _CharT2*);
00084
00085 protected:
00086
00093 streamsize _M_gcount;
00094
00095 public:
00096
00104 explicit
00105 basic_istream(__streambuf_type* __sb): _M_gcount(streamsize(0))
00106 { this->init(__sb); }
00107
00113 virtual
00114 ~basic_istream()
00115 { _M_gcount = streamsize(0); }
00116
00117
00118 class sentry;
00119 friend class sentry;
00120
00121
00122
00124
00131 inline __istream_type&
00132 operator>>(__istream_type& (*__pf)(__istream_type&));
00133
00134 inline __istream_type&
00135 operator>>(__ios_type& (*__pf)(__ios_type&));
00136
00137 inline __istream_type&
00138 operator>>(ios_base& (*__pf)(ios_base&));
00140
00141
00169 __istream_type&
00170 operator>>(bool& __n);
00171
00172 __istream_type&
00173 operator>>(short& __n);
00174
00175 __istream_type&
00176 operator>>(unsigned short& __n);
00177
00178 __istream_type&
00179 operator>>(int& __n);
00180
00181 __istream_type&
00182 operator>>(unsigned int& __n);
00183
00184 __istream_type&
00185 operator>>(long& __n);
00186
00187 __istream_type&
00188 operator>>(unsigned long& __n);
00189
00190 #ifdef _GLIBCXX_USE_LONG_LONG
00191 __istream_type&
00192 operator>>(long long& __n);
00193
00194 __istream_type&
00195 operator>>(unsigned long long& __n);
00196 #endif
00197
00198 __istream_type&
00199 operator>>(float& __f);
00200
00201 __istream_type&
00202 operator>>(double& __f);
00203
00204 __istream_type&
00205 operator>>(long double& __f);
00206
00207 __istream_type&
00208 operator>>(void*& __p);
00209
00230 __istream_type&
00231 operator>>(__streambuf_type* __sb);
00233
00234
00240 inline streamsize
00241 gcount() const
00242 { return _M_gcount; }
00243
00272 int_type
00273 get();
00274
00286 __istream_type&
00287 get(char_type& __c);
00288
00313 __istream_type&
00314 get(char_type* __s, streamsize __n, char_type __delim);
00315
00324 inline __istream_type&
00325 get(char_type* __s, streamsize __n)
00326 { return this->get(__s, __n, this->widen('\n')); }
00327
00347 __istream_type&
00348 get(__streambuf_type& __sb, char_type __delim);
00349
00357 inline __istream_type&
00358 get(__streambuf_type& __sb)
00359 { return this->get(__sb, this->widen('\n')); }
00360
00386 __istream_type&
00387 getline(char_type* __s, streamsize __n, char_type __delim);
00388
00397 inline __istream_type&
00398 getline(char_type* __s, streamsize __n)
00399 { return this->getline(__s, __n, this->widen('\n')); }
00400
00416 __istream_type&
00417 ignore(streamsize __n = 1, int_type __delim = traits_type::eof());
00418
00427 int_type
00428 peek();
00429
00445 __istream_type&
00446 read(char_type* __s, streamsize __n);
00447
00464 streamsize
00465 readsome(char_type* __s, streamsize __n);
00466
00480 __istream_type&
00481 putback(char_type __c);
00482
00495 __istream_type&
00496 unget();
00497
00513 int
00514 sync();
00515
00527 pos_type
00528 tellg();
00529
00542 __istream_type&
00543 seekg(pos_type);
00544
00558 __istream_type&
00559 seekg(off_type, ios_base::seekdir);
00561
00562 protected:
00563 explicit
00564 basic_istream(): _M_gcount(streamsize(0)) { }
00565 };
00566
00578 template<typename _CharT, typename _Traits>
00579 class basic_istream<_CharT, _Traits>::sentry
00580 {
00581 public:
00583 typedef _Traits traits_type;
00584 typedef basic_streambuf<_CharT, _Traits> __streambuf_type;
00585 typedef basic_istream<_CharT, _Traits> __istream_type;
00586 typedef typename __istream_type::__ctype_type __ctype_type;
00587 typedef typename _Traits::int_type __int_type;
00588
00610 explicit
00611 sentry(basic_istream<_CharT, _Traits>& __is, bool __noskipws = false);
00612
00620 operator bool() const { return _M_ok; }
00621
00622 private:
00623 bool _M_ok;
00624 };
00625
00626
00628
00639 template<typename _CharT, typename _Traits>
00640 basic_istream<_CharT, _Traits>&
00641 operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c);
00642
00643 template<class _Traits>
00644 basic_istream<char, _Traits>&
00645 operator>>(basic_istream<char, _Traits>& __in, unsigned char& __c)
00646 { return (__in >> reinterpret_cast<char&>(__c)); }
00647
00648 template<class _Traits>
00649 basic_istream<char, _Traits>&
00650 operator>>(basic_istream<char, _Traits>& __in, signed char& __c)
00651 { return (__in >> reinterpret_cast<char&>(__c)); }
00653
00655
00680 template<typename _CharT, typename _Traits>
00681 basic_istream<_CharT, _Traits>&
00682 operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s);
00683
00684 template<class _Traits>
00685 basic_istream<char,_Traits>&
00686 operator>>(basic_istream<char,_Traits>& __in, unsigned char* __s)
00687 { return (__in >> reinterpret_cast<char*>(__s)); }
00688
00689 template<class _Traits>
00690 basic_istream<char,_Traits>&
00691 operator>>(basic_istream<char,_Traits>& __in, signed char* __s)
00692 { return (__in >> reinterpret_cast<char*>(__s)); }
00694
00695
00702 template<typename _CharT, typename _Traits>
00703 class basic_iostream
00704 : public basic_istream<_CharT, _Traits>,
00705 public basic_ostream<_CharT, _Traits>
00706 {
00707 public:
00708
00709
00710
00711 typedef _CharT char_type;
00712 typedef typename _Traits::int_type int_type;
00713 typedef typename _Traits::pos_type pos_type;
00714 typedef typename _Traits::off_type off_type;
00715 typedef _Traits traits_type;
00716
00717
00718 typedef basic_istream<_CharT, _Traits> __istream_type;
00719 typedef basic_ostream<_CharT, _Traits> __ostream_type;
00720
00727 explicit
00728 basic_iostream(basic_streambuf<_CharT, _Traits>* __sb)
00729 : __istream_type(), __ostream_type()
00730 { this->init(__sb); }
00731
00735 virtual
00736 ~basic_iostream() { }
00737
00738 protected:
00739 explicit
00740 basic_iostream() : __istream_type(), __ostream_type()
00741 { }
00742 };
00743
00744
00765 template<typename _CharT, typename _Traits>
00766 basic_istream<_CharT, _Traits>&
00767 ws(basic_istream<_CharT, _Traits>& __is);
00768 }
00769
00770 #ifndef _GLIBCXX_EXPORT_TEMPLATE
00771 # include <bits/istream.tcc>
00772 #endif
00773
00774 #endif