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_ISTREAM
00040 #define _GLIBCXX_ISTREAM 1
00041
00042 #pragma GCC system_header
00043
00044 #include <ios>
00045 #include <limits>
00046
00047 namespace std
00048 {
00049
00057 template<typename _CharT, typename _Traits>
00058 class basic_istream : virtual public basic_ios<_CharT, _Traits>
00059 {
00060 public:
00061
00062 typedef _CharT char_type;
00063 typedef typename _Traits::int_type int_type;
00064 typedef typename _Traits::pos_type pos_type;
00065 typedef typename _Traits::off_type off_type;
00066 typedef _Traits traits_type;
00067
00068
00069 typedef basic_streambuf<_CharT, _Traits> __streambuf_type;
00070 typedef basic_ios<_CharT, _Traits> __ios_type;
00071 typedef basic_istream<_CharT, _Traits> __istream_type;
00072 typedef num_get<_CharT, istreambuf_iterator<_CharT, _Traits> >
00073 __num_get_type;
00074 typedef ctype<_CharT> __ctype_type;
00075
00076 template<typename _CharT2, typename _Traits2>
00077 friend basic_istream<_CharT2, _Traits2>&
00078 operator>>(basic_istream<_CharT2, _Traits2>&, _CharT2&);
00079
00080 template<typename _CharT2, typename _Traits2>
00081 friend basic_istream<_CharT2, _Traits2>&
00082 operator>>(basic_istream<_CharT2, _Traits2>&, _CharT2*);
00083
00084 protected:
00085
00092 streamsize _M_gcount;
00093
00094 public:
00095
00103 explicit
00104 basic_istream(__streambuf_type* __sb): _M_gcount(streamsize(0))
00105 { this->init(__sb); }
00106
00112 virtual
00113 ~basic_istream()
00114 { _M_gcount = streamsize(0); }
00115
00116
00117 class sentry;
00118 friend class sentry;
00119
00120
00121
00123
00130 inline __istream_type&
00131 operator>>(__istream_type& (*__pf)(__istream_type&));
00132
00133 inline __istream_type&
00134 operator>>(__ios_type& (*__pf)(__ios_type&));
00135
00136 inline __istream_type&
00137 operator>>(ios_base& (*__pf)(ios_base&));
00139
00140
00168 __istream_type&
00169 operator>>(bool& __n);
00170
00171 __istream_type&
00172 operator>>(short& __n);
00173
00174 __istream_type&
00175 operator>>(unsigned short& __n);
00176
00177 __istream_type&
00178 operator>>(int& __n);
00179
00180 __istream_type&
00181 operator>>(unsigned int& __n);
00182
00183 __istream_type&
00184 operator>>(long& __n);
00185
00186 __istream_type&
00187 operator>>(unsigned long& __n);
00188
00189 #ifdef _GLIBCXX_USE_LONG_LONG
00190 __istream_type&
00191 operator>>(long long& __n);
00192
00193 __istream_type&
00194 operator>>(unsigned long long& __n);
00195 #endif
00196
00197 __istream_type&
00198 operator>>(float& __f);
00199
00200 __istream_type&
00201 operator>>(double& __f);
00202
00203 __istream_type&
00204 operator>>(long double& __f);
00205
00206 __istream_type&
00207 operator>>(void*& __p);
00208
00229 __istream_type&
00230 operator>>(__streambuf_type* __sb);
00232
00233
00239 inline streamsize
00240 gcount() const
00241 { return _M_gcount; }
00242
00271 int_type
00272 get();
00273
00285 __istream_type&
00286 get(char_type& __c);
00287
00312 __istream_type&
00313 get(char_type* __s, streamsize __n, char_type __delim);
00314
00323 inline __istream_type&
00324 get(char_type* __s, streamsize __n)
00325 { return this->get(__s, __n, this->widen('\n')); }
00326
00346 __istream_type&
00347 get(__streambuf_type& __sb, char_type __delim);
00348
00356 inline __istream_type&
00357 get(__streambuf_type& __sb)
00358 { return this->get(__sb, this->widen('\n')); }
00359
00385 __istream_type&
00386 getline(char_type* __s, streamsize __n, char_type __delim);
00387
00396 inline __istream_type&
00397 getline(char_type* __s, streamsize __n)
00398 { return this->getline(__s, __n, this->widen('\n')); }
00399
00420 __istream_type&
00421 ignore();
00422
00423 __istream_type&
00424 ignore(streamsize __n);
00425
00426 __istream_type&
00427 ignore(streamsize __n, int_type __delim);
00428
00437 int_type
00438 peek();
00439
00455 __istream_type&
00456 read(char_type* __s, streamsize __n);
00457
00474 streamsize
00475 readsome(char_type* __s, streamsize __n);
00476
00490 __istream_type&
00491 putback(char_type __c);
00492
00505 __istream_type&
00506 unget();
00507
00523 int
00524 sync();
00525
00537 pos_type
00538 tellg();
00539
00552 __istream_type&
00553 seekg(pos_type);
00554
00568 __istream_type&
00569 seekg(off_type, ios_base::seekdir);
00571
00572 protected:
00573 explicit
00574 basic_istream(): _M_gcount(streamsize(0)) { }
00575 };
00576
00577
00578 template<>
00579 basic_istream<char>&
00580 basic_istream<char>::
00581 getline(char_type* __s, streamsize __n, char_type __delim);
00582
00583 template<>
00584 basic_istream<char>&
00585 basic_istream<char>::
00586 ignore(streamsize __n);
00587
00588 template<>
00589 basic_istream<char>&
00590 basic_istream<char>::
00591 ignore(streamsize __n, int_type __delim);
00592
00593 #ifdef _GLIBCXX_USE_WCHAR_T
00594 template<>
00595 basic_istream<wchar_t>&
00596 basic_istream<wchar_t>::
00597 getline(char_type* __s, streamsize __n, char_type __delim);
00598
00599 template<>
00600 basic_istream<wchar_t>&
00601 basic_istream<wchar_t>::
00602 ignore(streamsize __n);
00603
00604 template<>
00605 basic_istream<wchar_t>&
00606 basic_istream<wchar_t>::
00607 ignore(streamsize __n, int_type __delim);
00608 #endif
00609
00621 template<typename _CharT, typename _Traits>
00622 class basic_istream<_CharT, _Traits>::sentry
00623 {
00624 public:
00626 typedef _Traits traits_type;
00627 typedef basic_streambuf<_CharT, _Traits> __streambuf_type;
00628 typedef basic_istream<_CharT, _Traits> __istream_type;
00629 typedef typename __istream_type::__ctype_type __ctype_type;
00630 typedef typename _Traits::int_type __int_type;
00631
00653 explicit
00654 sentry(basic_istream<_CharT, _Traits>& __is, bool __noskipws = false);
00655
00663 operator bool() const { return _M_ok; }
00664
00665 private:
00666 bool _M_ok;
00667 };
00668
00669
00671
00682 template<typename _CharT, typename _Traits>
00683 basic_istream<_CharT, _Traits>&
00684 operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c);
00685
00686 template<class _Traits>
00687 basic_istream<char, _Traits>&
00688 operator>>(basic_istream<char, _Traits>& __in, unsigned char& __c)
00689 { return (__in >> reinterpret_cast<char&>(__c)); }
00690
00691 template<class _Traits>
00692 basic_istream<char, _Traits>&
00693 operator>>(basic_istream<char, _Traits>& __in, signed char& __c)
00694 { return (__in >> reinterpret_cast<char&>(__c)); }
00696
00698
00723 template<typename _CharT, typename _Traits>
00724 basic_istream<_CharT, _Traits>&
00725 operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s);
00726
00727
00728 template<>
00729 basic_istream<char>&
00730 operator>>(basic_istream<char>& __in, char* __s);
00731
00732 template<class _Traits>
00733 basic_istream<char, _Traits>&
00734 operator>>(basic_istream<char, _Traits>& __in, unsigned char* __s)
00735 { return (__in >> reinterpret_cast<char*>(__s)); }
00736
00737 template<class _Traits>
00738 basic_istream<char, _Traits>&
00739 operator>>(basic_istream<char, _Traits>& __in, signed char* __s)
00740 { return (__in >> reinterpret_cast<char*>(__s)); }
00742
00743
00750 template<typename _CharT, typename _Traits>
00751 class basic_iostream
00752 : public basic_istream<_CharT, _Traits>,
00753 public basic_ostream<_CharT, _Traits>
00754 {
00755 public:
00756
00757
00758
00759 typedef _CharT char_type;
00760 typedef typename _Traits::int_type int_type;
00761 typedef typename _Traits::pos_type pos_type;
00762 typedef typename _Traits::off_type off_type;
00763 typedef _Traits traits_type;
00764
00765
00766 typedef basic_istream<_CharT, _Traits> __istream_type;
00767 typedef basic_ostream<_CharT, _Traits> __ostream_type;
00768
00775 explicit
00776 basic_iostream(basic_streambuf<_CharT, _Traits>* __sb)
00777 : __istream_type(), __ostream_type()
00778 { this->init(__sb); }
00779
00783 virtual
00784 ~basic_iostream() { }
00785
00786 protected:
00787 explicit
00788 basic_iostream() : __istream_type(), __ostream_type()
00789 { }
00790 };
00791
00792
00813 template<typename _CharT, typename _Traits>
00814 basic_istream<_CharT, _Traits>&
00815 ws(basic_istream<_CharT, _Traits>& __is);
00816 }
00817
00818 #ifndef _GLIBCXX_EXPORT_TEMPLATE
00819 # include <bits/istream.tcc>
00820 #endif
00821
00822 #endif