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
00039 #ifndef _CPP_ISTREAM
00040 #define _CPP_ISTREAM 1
00041
00042 #pragma GCC system_header
00043
00044 #include <ios>
00045 #include <limits>
00046
00047 namespace std
00048 {
00049
00050 template<typename _CharT, typename _Traits>
00051 class basic_istream : 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_istream<_CharT, _Traits> __istream_type;
00065 typedef istreambuf_iterator<_CharT, _Traits> __istreambuf_iter;
00066 typedef num_get<_CharT, __istreambuf_iter> __numget_type;
00067 typedef ctype<_CharT> __ctype_type;
00068
00069 protected:
00070
00071 streamsize _M_gcount;
00072
00073 public:
00074
00075 explicit
00076 basic_istream(__streambuf_type* __sb)
00077 {
00078 this->init(__sb);
00079 _M_gcount = streamsize(0);
00080 }
00081
00082 virtual
00083 ~basic_istream()
00084 { _M_gcount = streamsize(0); }
00085
00086
00087 class sentry;
00088 friend class sentry;
00089
00090
00091
00092 __istream_type&
00093 operator>>(__istream_type& (*__pf)(__istream_type&));
00094
00095 __istream_type&
00096 operator>>(__ios_type& (*__pf)(__ios_type&));
00097
00098 __istream_type&
00099 operator>>(ios_base& (*__pf)(ios_base&));
00100
00101
00102 __istream_type&
00103 operator>>(bool& __n);
00104
00105 __istream_type&
00106 operator>>(short& __n);
00107
00108 __istream_type&
00109 operator>>(unsigned short& __n);
00110
00111 __istream_type&
00112 operator>>(int& __n);
00113
00114 __istream_type&
00115 operator>>(unsigned int& __n);
00116
00117 __istream_type&
00118 operator>>(long& __n);
00119
00120 __istream_type&
00121 operator>>(unsigned long& __n);
00122
00123 #ifdef _GLIBCPP_USE_LONG_LONG
00124 __istream_type&
00125 operator>>(long long& __n);
00126
00127 __istream_type&
00128 operator>>(unsigned long long& __n);
00129 #endif
00130
00131 __istream_type&
00132 operator>>(float& __f);
00133
00134 __istream_type&
00135 operator>>(double& __f);
00136
00137 __istream_type&
00138 operator>>(long double& __f);
00139
00140 __istream_type&
00141 operator>>(void*& __p);
00142
00143 __istream_type&
00144 operator>>(__streambuf_type* __sb);
00145
00146
00147 inline streamsize
00148 gcount(void) const
00149 { return _M_gcount; }
00150
00151 int_type
00152 get(void);
00153
00154 __istream_type&
00155 get(char_type& __c);
00156
00157 __istream_type&
00158 get(char_type* __s, streamsize __n, char_type __delim);
00159
00160 inline __istream_type&
00161 get(char_type* __s, streamsize __n)
00162 { return this->get(__s, __n, this->widen('\n')); }
00163
00164 __istream_type&
00165 get(__streambuf_type& __sb, char_type __delim);
00166
00167 inline __istream_type&
00168 get(__streambuf_type& __sb)
00169 { return this->get(__sb, this->widen('\n')); }
00170
00171 __istream_type&
00172 getline(char_type* __s, streamsize __n, char_type __delim);
00173
00174 inline __istream_type&
00175 getline(char_type* __s, streamsize __n)
00176 { return this->getline(__s, __n, this->widen('\n')); }
00177
00178 __istream_type&
00179 ignore(streamsize __n = 1, int_type __delim = traits_type::eof());
00180
00181 int_type
00182 peek(void);
00183
00184 __istream_type&
00185 read(char_type* __s, streamsize __n);
00186
00187 streamsize
00188 readsome(char_type* __s, streamsize __n);
00189
00190 __istream_type&
00191 putback(char_type __c);
00192
00193 __istream_type&
00194 unget(void);
00195
00196 int
00197 sync(void);
00198
00199 pos_type
00200 tellg(void);
00201
00202 __istream_type&
00203 seekg(pos_type);
00204
00205 __istream_type&
00206 seekg(off_type, ios_base::seekdir);
00207 };
00208
00209 template<typename _CharT, typename _Traits>
00210 class basic_istream<_CharT, _Traits>::sentry
00211 {
00212 public:
00213 typedef _Traits traits_type;
00214 typedef basic_streambuf<_CharT, _Traits> __streambuf_type;
00215 typedef basic_istream<_CharT, _Traits> __istream_type;
00216 typedef typename __istream_type::__ctype_type __ctype_type;
00217 typedef typename _Traits::int_type __int_type;
00218
00219 explicit
00220 sentry(basic_istream<_CharT, _Traits>& __is, bool __noskipws = false);
00221
00222 operator bool() { return _M_ok; }
00223
00224 private:
00225 bool _M_ok;
00226 };
00227
00228
00229 template<typename _CharT, typename _Traits>
00230 basic_istream<_CharT, _Traits>&
00231 operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c);
00232
00233 template<class _Traits>
00234 basic_istream<char, _Traits>&
00235 operator>>(basic_istream<char, _Traits>& __in, unsigned char& __c)
00236 { return (__in >> reinterpret_cast<char&>(__c)); }
00237
00238 template<class _Traits>
00239 basic_istream<char, _Traits>&
00240 operator>>(basic_istream<char, _Traits>& __in, signed char& __c)
00241 { return (__in >> reinterpret_cast<char&>(__c)); }
00242
00243 template<typename _CharT, typename _Traits>
00244 basic_istream<_CharT, _Traits>&
00245 operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s);
00246
00247 template<class _Traits>
00248 basic_istream<char,_Traits>&
00249 operator>>(basic_istream<char,_Traits>& __in, unsigned char* __s)
00250 { return (__in >> reinterpret_cast<char*>(__s)); }
00251
00252 template<class _Traits>
00253 basic_istream<char,_Traits>&
00254 operator>>(basic_istream<char,_Traits>& __in, signed char* __s)
00255 { return (__in >> reinterpret_cast<char*>(__s)); }
00256
00257
00258 template<typename _CharT, typename _Traits>
00259 class basic_iostream
00260 : public basic_istream<_CharT, _Traits>,
00261 public basic_ostream<_CharT, _Traits>
00262 {
00263 public:
00264
00265 typedef basic_istream<_CharT, _Traits> __istream_type;
00266 typedef basic_ostream<_CharT, _Traits> __ostream_type;
00267
00268 explicit
00269 basic_iostream(basic_streambuf<_CharT, _Traits>* __sb)
00270 : __istream_type(__sb), __ostream_type(__sb)
00271 { }
00272
00273 virtual
00274 ~basic_iostream() { }
00275 };
00276
00277
00278 template<typename _CharT, typename _Traits>
00279 basic_istream<_CharT, _Traits>&
00280 ws(basic_istream<_CharT, _Traits>& __is);
00281 }
00282
00283 #ifdef _GLIBCPP_NO_TEMPLATE_EXPORT
00284 # define export
00285 #endif
00286 #ifdef _GLIBCPP_FULLY_COMPLIANT_HEADERS
00287 # include <bits/istream.tcc>
00288 #endif
00289
00290 #endif