Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4680 | right-hear | 1 | // Input streams -*- C++ -*- |
2 | |||
3 | // Copyright (C) 1997-1999, 2001 Free Software Foundation, Inc. |
||
4 | // |
||
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) |
||
9 | // any later version. |
||
10 | |||
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. |
||
15 | |||
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, |
||
19 | // USA. |
||
20 | |||
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. |
||
29 | |||
30 | // |
||
31 | // ISO C++ 14882: 27.6.1 Input streams |
||
32 | // |
||
33 | |||
34 | #ifndef _CPP_ISTREAM |
||
35 | #define _CPP_ISTREAM 1 |
||
36 | |||
37 | #pragma GCC system_header |
||
38 | |||
39 | #include |
||
40 | #include |
||
41 | |||
42 | namespace std |
||
43 | { |
||
44 | // 27.6.1.1 Template class basic_istream |
||
45 | template |
||
46 | class basic_istream : virtual public basic_ios<_CharT, _Traits> |
||
47 | { |
||
48 | public: |
||
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; |
||
55 | |||
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; |
||
63 | |||
64 | protected: |
||
65 | // Data Members: |
||
66 | streamsize _M_gcount; |
||
67 | |||
68 | public: |
||
69 | // 27.6.1.1.1 Constructor/destructor: |
||
70 | explicit |
||
71 | basic_istream(__streambuf_type* __sb) |
||
72 | { |
||
73 | this->init(__sb); |
||
74 | _M_gcount = streamsize(0); |
||
75 | } |
||
76 | |||
77 | virtual |
||
78 | ~basic_istream() |
||
79 | { _M_gcount = streamsize(0); } |
||
80 | |||
81 | // 27.6.1.1.2 Prefix/suffix: |
||
82 | class sentry; |
||
83 | friend class sentry; |
||
84 | |||
85 | // 27.6.1.2 Formatted input: |
||
86 | // 27.6.1.2.3 basic_istream::operator>> |
||
87 | __istream_type& |
||
88 | operator>>(__istream_type& (*__pf)(__istream_type&)); |
||
89 | |||
90 | __istream_type& |
||
91 | operator>>(__ios_type& (*__pf)(__ios_type&)); |
||
92 | |||
93 | __istream_type& |
||
94 | operator>>(ios_base& (*__pf)(ios_base&)); |
||
95 | |||
96 | // 27.6.1.2.2 Arithmetic Extractors |
||
97 | __istream_type& |
||
98 | operator>>(bool& __n); |
||
99 | |||
100 | __istream_type& |
||
101 | operator>>(short& __n); |
||
102 | |||
103 | __istream_type& |
||
104 | operator>>(unsigned short& __n); |
||
105 | |||
106 | __istream_type& |
||
107 | operator>>(int& __n); |
||
108 | |||
109 | __istream_type& |
||
110 | operator>>(unsigned int& __n); |
||
111 | |||
112 | __istream_type& |
||
113 | operator>>(long& __n); |
||
114 | |||
115 | __istream_type& |
||
116 | operator>>(unsigned long& __n); |
||
117 | |||
118 | #ifdef _GLIBCPP_USE_LONG_LONG |
||
119 | __istream_type& |
||
120 | operator>>(long long& __n); |
||
121 | |||
122 | __istream_type& |
||
123 | operator>>(unsigned long long& __n); |
||
124 | #endif |
||
125 | |||
126 | __istream_type& |
||
127 | operator>>(float& __f); |
||
128 | |||
129 | __istream_type& |
||
130 | operator>>(double& __f); |
||
131 | |||
132 | __istream_type& |
||
133 | operator>>(long double& __f); |
||
134 | |||
135 | __istream_type& |
||
136 | operator>>(void*& __p); |
||
137 | |||
138 | __istream_type& |
||
139 | operator>>(__streambuf_type* __sb); |
||
140 | |||
141 | // 27.6.1.3 Unformatted input: |
||
142 | inline streamsize |
||
143 | gcount(void) const |
||
144 | { return _M_gcount; } |
||
145 | |||
146 | int_type |
||
147 | get(void); |
||
148 | |||
149 | __istream_type& |
||
150 | get(char_type& __c); |
||
151 | |||
152 | __istream_type& |
||
153 | get(char_type* __s, streamsize __n, char_type __delim); |
||
154 | |||
155 | inline __istream_type& |
||
156 | get(char_type* __s, streamsize __n) |
||
157 | { return get(__s, __n, this->widen('\n')); } |
||
158 | |||
159 | __istream_type& |
||
160 | get(__streambuf_type& __sb, char_type __delim); |
||
161 | |||
162 | inline __istream_type& |
||
163 | get(__streambuf_type& __sb) |
||
164 | { return get(__sb, this->widen('\n')); } |
||
165 | |||
166 | __istream_type& |
||
167 | getline(char_type* __s, streamsize __n, char_type __delim); |
||
168 | |||
169 | inline __istream_type& |
||
170 | getline(char_type* __s, streamsize __n) |
||
171 | { return getline(__s, __n, this->widen('\n')); } |
||
172 | |||
173 | __istream_type& |
||
174 | ignore(streamsize __n = 1, int_type __delim = traits_type::eof()); |
||
175 | |||
176 | int_type |
||
177 | peek(void); |
||
178 | |||
179 | __istream_type& |
||
180 | read(char_type* __s, streamsize __n); |
||
181 | |||
182 | streamsize |
||
183 | readsome(char_type* __s, streamsize __n); |
||
184 | |||
185 | __istream_type& |
||
186 | putback(char_type __c); |
||
187 | |||
188 | __istream_type& |
||
189 | unget(void); |
||
190 | |||
191 | int |
||
192 | sync(void); |
||
193 | |||
194 | pos_type |
||
195 | tellg(void); |
||
196 | |||
197 | __istream_type& |
||
198 | seekg(pos_type); |
||
199 | |||
200 | __istream_type& |
||
201 | seekg(off_type, ios_base::seekdir); |
||
202 | |||
203 | private: |
||
204 | #ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS |
||
205 | // Not defined. |
||
206 | __istream_type& |
||
207 | operator=(const __istream_type&); |
||
208 | |||
209 | basic_istream(const __istream_type&); |
||
210 | #endif |
||
211 | }; |
||
212 | |||
213 | template |
||
214 | class basic_istream<_CharT, _Traits>::sentry |
||
215 | { |
||
216 | public: |
||
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; |
||
222 | |||
223 | explicit |
||
224 | sentry(basic_istream<_CharT, _Traits>& __is, bool __noskipws = false); |
||
225 | |||
226 | operator bool() { return _M_ok; } |
||
227 | |||
228 | private: |
||
229 | bool _M_ok; |
||
230 | }; |
||
231 | |||
232 | // 27.6.1.2.3 Character extraction templates |
||
233 | template |
||
234 | basic_istream<_CharT, _Traits>& |
||
235 | operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c); |
||
236 | |||
237 | template |
||
238 | basic_istream |
||
239 | operator>>(basic_istream |
||
240 | { return (__in >> reinterpret_cast |
||
241 | |||
242 | template |
||
243 | basic_istream |
||
244 | operator>>(basic_istream |
||
245 | { return (__in >> reinterpret_cast |
||
246 | |||
247 | template |
||
248 | basic_istream<_CharT, _Traits>& |
||
249 | operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s); |
||
250 | |||
251 | template |
||
252 | basic_istream |
||
253 | operator>>(basic_istream |
||
254 | { return (__in >> reinterpret_cast |
||
255 | |||
256 | template |
||
257 | basic_istream |
||
258 | operator>>(basic_istream |
||
259 | { return (__in >> reinterpret_cast |
||
260 | |||
261 | // 27.6.1.5 Template class basic_iostream |
||
262 | template |
||
263 | class basic_iostream |
||
264 | : public basic_istream<_CharT, _Traits>, |
||
265 | public basic_ostream<_CharT, _Traits> |
||
266 | { |
||
267 | public: |
||
268 | // Non-standard Types: |
||
269 | typedef basic_istream<_CharT, _Traits> __istream_type; |
||
270 | typedef basic_ostream<_CharT, _Traits> __ostream_type; |
||
271 | |||
272 | explicit |
||
273 | basic_iostream(basic_streambuf<_CharT, _Traits>* __sb) |
||
274 | : __istream_type(__sb), __ostream_type(__sb) |
||
275 | { } |
||
276 | |||
277 | virtual |
||
278 | ~basic_iostream() { } |
||
279 | }; |
||
280 | |||
281 | // 27.6.1.4 Standard basic_istream manipulators |
||
282 | template |
||
283 | basic_istream<_CharT, _Traits>& |
||
284 | ws(basic_istream<_CharT, _Traits>& __is); |
||
285 | } // namespace std |
||
286 | |||
287 | #ifdef _GLIBCPP_NO_TEMPLATE_EXPORT |
||
288 | # define export |
||
289 | #ifdef _GLIBCPP_FULLY_COMPLIANT_HEADERS |
||
290 | # include |
||
291 | #endif |
||
292 | #endif |
||
293 | |||
294 | #endif /* _CPP_ISTREAM */ |
||
295 |