1 // Input streams -*- C++ -*-
3 // Copyright (C) 1997-1999, 2001 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING. If not, write to the Free
18 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
21 // As a special exception, you may use this file as part of a free software
22 // library without restriction. Specifically, if other files instantiate
23 // templates or use macros or inline functions from this file, or you compile
24 // this file and link it with other files to produce an executable, this
25 // file does not by itself cause the resulting executable to be covered by
26 // the GNU General Public License. This exception does not however
27 // invalidate any other reasons why the executable file might be covered by
28 // the GNU General Public License.
31 // ISO C++ 14882: 27.6.1 Input streams
35 #define _CPP_ISTREAM 1
37 #pragma GCC system_header
39 #include <bits/std_ios.h>
40 #include <bits/std_limits.h> // For numeric_limits
44 // 27.6.1.1 Template class basic_istream
45 template<typename _CharT, typename _Traits>
46 class basic_istream : virtual public basic_ios<_CharT, _Traits>
49 // Types (inherited from basic_ios (27.4.4)):
50 typedef _CharT char_type;
51 typedef typename _Traits::int_type int_type;
52 typedef typename _Traits::pos_type pos_type;
53 typedef typename _Traits::off_type off_type;
54 typedef _Traits traits_type;
56 // Non-standard Types:
57 typedef basic_streambuf<_CharT, _Traits> __streambuf_type;
58 typedef basic_ios<_CharT, _Traits> __ios_type;
59 typedef basic_istream<_CharT, _Traits> __istream_type;
60 typedef istreambuf_iterator<_CharT, _Traits> __istreambuf_iter;
61 typedef num_get<_CharT, __istreambuf_iter> __numget_type;
62 typedef ctype<_CharT> __ctype_type;
69 // 27.6.1.1.1 Constructor/destructor:
71 basic_istream(__streambuf_type* __sb)
74 _M_gcount = streamsize(0);
79 { _M_gcount = streamsize(0); }
81 // 27.6.1.1.2 Prefix/suffix:
85 // 27.6.1.2 Formatted input:
86 // 27.6.1.2.3 basic_istream::operator>>
88 operator>>(__istream_type& (*__pf)(__istream_type&));
91 operator>>(__ios_type& (*__pf)(__ios_type&));
94 operator>>(ios_base& (*__pf)(ios_base&));
96 // 27.6.1.2.2 Arithmetic Extractors
98 operator>>(bool& __n);
101 operator>>(short& __n);
104 operator>>(unsigned short& __n);
107 operator>>(int& __n);
110 operator>>(unsigned int& __n);
113 operator>>(long& __n);
116 operator>>(unsigned long& __n);
118 #ifdef _GLIBCPP_USE_LONG_LONG
120 operator>>(long long& __n);
123 operator>>(unsigned long long& __n);
127 operator>>(float& __f);
130 operator>>(double& __f);
133 operator>>(long double& __f);
136 operator>>(void*& __p);
139 operator>>(__streambuf_type* __sb);
141 // 27.6.1.3 Unformatted input:
144 { return _M_gcount; }
153 get(char_type* __s, streamsize __n, char_type __delim);
155 inline __istream_type&
156 get(char_type* __s, streamsize __n)
157 { return get(__s, __n, this->widen('\n')); }
160 get(__streambuf_type& __sb, char_type __delim);
162 inline __istream_type&
163 get(__streambuf_type& __sb)
164 { return get(__sb, this->widen('\n')); }
167 getline(char_type* __s, streamsize __n, char_type __delim);
169 inline __istream_type&
170 getline(char_type* __s, streamsize __n)
171 { return getline(__s, __n, this->widen('\n')); }
174 ignore(streamsize __n = 1, int_type __delim = traits_type::eof());
180 read(char_type* __s, streamsize __n);
183 readsome(char_type* __s, streamsize __n);
186 putback(char_type __c);
201 seekg(off_type, ios_base::seekdir);
204 #ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
207 operator=(const __istream_type&);
209 basic_istream(const __istream_type&);
213 template<typename _CharT, typename _Traits>
214 class basic_istream<_CharT, _Traits>::sentry
217 typedef _Traits traits_type;
218 typedef basic_streambuf<_CharT, _Traits> __streambuf_type;
219 typedef basic_istream<_CharT, _Traits> __istream_type;
220 typedef __istream_type::__ctype_type __ctype_type;
221 typedef typename _Traits::int_type __int_type;
224 sentry(basic_istream<_CharT, _Traits>& __is, bool __noskipws = false);
226 operator bool() { return _M_ok; }
232 // 27.6.1.2.3 Character extraction templates
233 template<typename _CharT, typename _Traits>
234 basic_istream<_CharT, _Traits>&
235 operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c);
237 template<class _Traits>
238 basic_istream<char, _Traits>&
239 operator>>(basic_istream<char, _Traits>& __in, unsigned char& __c)
240 { return (__in >> reinterpret_cast<char&>(__c)); }
242 template<class _Traits>
243 basic_istream<char, _Traits>&
244 operator>>(basic_istream<char, _Traits>& __in, signed char& __c)
245 { return (__in >> reinterpret_cast<char&>(__c)); }
247 template<typename _CharT, typename _Traits>
248 basic_istream<_CharT, _Traits>&
249 operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s);
251 template<class _Traits>
252 basic_istream<char,_Traits>&
253 operator>>(basic_istream<char,_Traits>& __in, unsigned char* __s)
254 { return (__in >> reinterpret_cast<char*>(__s)); }
256 template<class _Traits>
257 basic_istream<char,_Traits>&
258 operator>>(basic_istream<char,_Traits>& __in, signed char* __s)
259 { return (__in >> reinterpret_cast<char*>(__s)); }
261 // 27.6.1.5 Template class basic_iostream
262 template<typename _CharT, typename _Traits>
264 : public basic_istream<_CharT, _Traits>,
265 public basic_ostream<_CharT, _Traits>
268 // Non-standard Types:
269 typedef basic_istream<_CharT, _Traits> __istream_type;
270 typedef basic_ostream<_CharT, _Traits> __ostream_type;
273 basic_iostream(basic_streambuf<_CharT, _Traits>* __sb)
274 : __istream_type(__sb), __ostream_type(__sb)
278 ~basic_iostream() { }
281 // 27.6.1.4 Standard basic_istream manipulators
282 template<typename _CharT, typename _Traits>
283 basic_istream<_CharT, _Traits>&
284 ws(basic_istream<_CharT, _Traits>& __is);
287 #ifdef _GLIBCPP_NO_TEMPLATE_EXPORT
289 #ifdef _GLIBCPP_FULLY_COMPLIANT_HEADERS
290 # include <bits/istream.tcc>
294 #endif /* _CPP_ISTREAM */