istream

Go to the documentation of this file.
00001 // Input streams -*- C++ -*- 00002 00003 // Copyright (C) 1997, 1998, 1999, 2001, 2002, 2003 00004 // Free Software Foundation, Inc. 00005 // 00006 // This file is part of the GNU ISO C++ Library. This library is free 00007 // software; you can redistribute it and/or modify it under the 00008 // terms of the GNU General Public License as published by the 00009 // Free Software Foundation; either version 2, or (at your option) 00010 // any later version. 00011 00012 // This library is distributed in the hope that it will be useful, 00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 // GNU General Public License for more details. 00016 00017 // You should have received a copy of the GNU General Public License along 00018 // with this library; see the file COPYING. If not, write to the Free 00019 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, 00020 // USA. 00021 00022 // As a special exception, you may use this file as part of a free software 00023 // library without restriction. Specifically, if other files instantiate 00024 // templates or use macros or inline functions from this file, or you compile 00025 // this file and link it with other files to produce an executable, this 00026 // file does not by itself cause the resulting executable to be covered by 00027 // the GNU General Public License. This exception does not however 00028 // invalidate any other reasons why the executable file might be covered by 00029 // the GNU General Public License. 00030 00031 // 00032 // ISO C++ 14882: 27.6.1 Input streams 00033 // 00034 00035 /** @file istream 00036 * This is a Standard C++ Library header. You should @c #include this header 00037 * in your programs, rather than any of the "st[dl]_*.h" implementation files. 00038 */ 00039 00040 #ifndef _GLIBCXX_ISTREAM 00041 #define _GLIBCXX_ISTREAM 1 00042 00043 #pragma GCC system_header 00044 00045 #include <ios> 00046 #include <limits> // For numeric_limits 00047 00048 namespace std 00049 { 00050 // [27.6.1.1] Template class basic_istream 00051 /** 00052 * @brief Controlling input. 00053 * 00054 * This is the base class for all input streams. It provides text 00055 * formatting of all builtin types, and communicates with any class 00056 * derived from basic_streambuf to do the actual input. 00057 */ 00058 template<typename _CharT, typename _Traits> 00059 class basic_istream : virtual public basic_ios<_CharT, _Traits> 00060 { 00061 public: 00062 // Types (inherited from basic_ios (27.4.4)): 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 // Non-standard Types: 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 // Data Members: 00087 /** 00088 * @if maint 00089 * The number of characters extracted in the previous unformatted 00090 * function; see gcount(). 00091 * @endif 00092 */ 00093 streamsize _M_gcount; 00094 00095 public: 00096 // [27.6.1.1.1] constructor/destructor 00097 /** 00098 * @brief Base constructor. 00099 * 00100 * This ctor is almost never called by the user directly, rather from 00101 * derived classes' initialization lists, which pass a pointer to 00102 * their own stream buffer. 00103 */ 00104 explicit 00105 basic_istream(__streambuf_type* __sb): _M_gcount(streamsize(0)) 00106 { this->init(__sb); } 00107 00108 /** 00109 * @brief Base destructor. 00110 * 00111 * This does very little apart from providing a virtual base dtor. 00112 */ 00113 virtual 00114 ~basic_istream() 00115 { _M_gcount = streamsize(0); } 00116 00117 // [27.6.1.1.2] prefix/suffix 00118 class sentry; 00119 friend class sentry; 00120 00121 // [27.6.1.2] formatted input 00122 // [27.6.1.2.3] basic_istream::operator>> 00123 //@{ 00124 /** 00125 * @brief Interface for manipulators. 00126 * 00127 * Manuipulators such as @c std::ws and @c std::dec use these 00128 * functions in constructs like "std::cin >> std::ws". For more 00129 * information, see the iomanip header. 00130 */ 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&)); 00139 //@} 00140 00141 // [27.6.1.2.2] arithmetic extractors 00142 /** 00143 * @name Arithmetic Extractors 00144 * 00145 * All the @c operator>> functions (aka <em>formatted input 00146 * functions</em>) have some common behavior. Each starts by 00147 * constructing a temporary object of type std::basic_istream::sentry 00148 * with the second argument (noskipws) set to false. This has several 00149 * effects, concluding with the setting of a status flag; see the 00150 * sentry documentation for more. 00151 * 00152 * If the sentry status is good, the function tries to extract 00153 * whatever data is appropriate for the type of the argument. 00154 * 00155 * If an exception is thrown during extraction, ios_base::badbit 00156 * will be turned on in the stream's error state without causing an 00157 * ios_base::failure to be thrown. The original exception will then 00158 * be rethrown. 00159 */ 00160 //@{ 00161 /** 00162 * @brief Basic arithmetic extractors 00163 * @param A variable of builtin type. 00164 * @return @c *this if successful 00165 * 00166 * These functions use the stream's current locale (specifically, the 00167 * @c num_get facet) to parse the input data. 00168 */ 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 00210 /** 00211 * @brief Extracting into another streambuf. 00212 * @param sb A pointer to a streambuf 00213 * 00214 * This function behaves like one of the basic arithmetic extractors, 00215 * in that it also constructs a sentry object and has the same error 00216 * handling behavior. 00217 * 00218 * If @a sb is NULL, the stream will set failbit in its error state. 00219 * 00220 * Characters are extracted from this stream and inserted into the 00221 * @a sb streambuf until one of the following occurs: 00222 * 00223 * - the input stream reaches end-of-file, 00224 * - insertion into the output buffer fails (in this case, the 00225 * character that would have been inserted is not extracted), or 00226 * - an exception occurs (and in this case is caught) 00227 * 00228 * If the function inserts no characters, failbit is set. 00229 */ 00230 __istream_type& 00231 operator>>(__streambuf_type* __sb); 00232 //@} 00233 00234 // [27.6.1.3] unformatted input 00235 /** 00236 * @brief Character counting 00237 * @return The number of characters extracted by the previous 00238 * unformatted input function dispatched for this stream. 00239 */ 00240 inline streamsize 00241 gcount() const 00242 { return _M_gcount; } 00243 00244 /** 00245 * @name Unformatted Input Functions 00246 * 00247 * All the unformatted input functions have some common behavior. 00248 * Each starts by constructing a temporary object of type 00249 * std::basic_istream::sentry with the second argument (noskipws) 00250 * set to true. This has several effects, concluding with the 00251 * setting of a status flag; see the sentry documentation for more. 00252 * 00253 * If the sentry status is good, the function tries to extract 00254 * whatever data is appropriate for the type of the argument. 00255 * 00256 * The number of characters extracted is stored for later retrieval 00257 * by gcount(). 00258 * 00259 * If an exception is thrown during extraction, ios_base::badbit 00260 * will be turned on in the stream's error state without causing an 00261 * ios_base::failure to be thrown. The original exception will then 00262 * be rethrown. 00263 */ 00264 //@{ 00265 /** 00266 * @brief Simple extraction. 00267 * @return A character, or eof(). 00268 * 00269 * Tries to extract a character. If none are available, sets failbit 00270 * and returns traits::eof(). 00271 */ 00272 int_type 00273 get(); 00274 00275 /** 00276 * @brief Simple extraction. 00277 * @param c The character in which to store data. 00278 * @return *this 00279 * 00280 * Tries to extract a character and store it in @a c. If none are 00281 * available, sets failbit and returns traits::eof(). 00282 * 00283 * @note This function is not overloaded on signed char and 00284 * unsigned char. 00285 */ 00286 __istream_type& 00287 get(char_type& __c); 00288 00289 /** 00290 * @brief Simple multiple-character extraction. 00291 * @param s Pointer to an array. 00292 * @param n Maximum number of characters to store in @a s. 00293 * @param delim A "stop" character. 00294 * @return *this 00295 * 00296 * Characters are extracted and stored into @a s until one of the 00297 * following happens: 00298 * 00299 * - @c n-1 characters are stored 00300 * - the input sequence reaches EOF 00301 * - the next character equals @a delim, in which case the character 00302 * is not extracted 00303 * 00304 * If no characters are stored, failbit is set in the stream's error 00305 * state. 00306 * 00307 * In any case, a null character is stored into the next location in 00308 * the array. 00309 * 00310 * @note This function is not overloaded on signed char and 00311 * unsigned char. 00312 */ 00313 __istream_type& 00314 get(char_type* __s, streamsize __n, char_type __delim); 00315 00316 /** 00317 * @brief Simple multiple-character extraction. 00318 * @param s Pointer to an array. 00319 * @param n Maximum number of characters to store in @a s. 00320 * @return *this 00321 * 00322 * Returns @c get(s,n,widen('\n')). 00323 */ 00324 inline __istream_type& 00325 get(char_type* __s, streamsize __n) 00326 { return this->get(__s, __n, this->widen('\n')); } 00327 00328 /** 00329 * @brief Extraction into another streambuf. 00330 * @param sb A streambuf in which to store data. 00331 * @param delim A "stop" character. 00332 * @return *this 00333 * 00334 * Characters are extracted and inserted into @a sb until one of the 00335 * following happens: 00336 * 00337 * - the input sequence reaches EOF 00338 * - insertion into the output buffer fails (in this case, the 00339 * character that would have been inserted is not extracted) 00340 * - the next character equals @a delim (in this case, the character 00341 * is not extracted) 00342 * - an exception occurs (and in this case is caught) 00343 * 00344 * If no characters are stored, failbit is set in the stream's error 00345 * state. 00346 */ 00347 __istream_type& 00348 get(__streambuf_type& __sb, char_type __delim); 00349 00350 /** 00351 * @brief Extraction into another streambuf. 00352 * @param sb A streambuf in which to store data. 00353 * @return *this 00354 * 00355 * Returns @c get(sb,widen('\n')). 00356 */ 00357 inline __istream_type& 00358 get(__streambuf_type& __sb) 00359 { return this->get(__sb, this->widen('\n')); } 00360 00361 /** 00362 * @brief String extraction. 00363 * @param s A character array in which to store the data. 00364 * @param n Maximum number of characters to extract. 00365 * @param delim A "stop" character. 00366 * @return *this 00367 * 00368 * Extracts and stores characters into @a s until one of the 00369 * following happens. Note that these criteria are required to be 00370 * tested in the order listed here, to allow an input line to exactly 00371 * fill the @a s array without setting failbit. 00372 * 00373 * -# the input sequence reaches end-of-file, in which case eofbit 00374 * is set in the stream error state 00375 * -# the next character equals @c delim, in which case the character 00376 * is extracted (and therefore counted in @c gcount()) but not stored 00377 * -# @c n-1 characters are stored, in which case failbit is set 00378 * in the stream error state 00379 * 00380 * If no characters are extracted, failbit is set. (An empty line of 00381 * input should therefore not cause failbit to be set.) 00382 * 00383 * In any case, a null character is stored in the next location in 00384 * the array. 00385 */ 00386 __istream_type& 00387 getline(char_type* __s, streamsize __n, char_type __delim); 00388 00389 /** 00390 * @brief String extraction. 00391 * @param s A character array in which to store the data. 00392 * @param n Maximum number of characters to extract. 00393 * @return *this 00394 * 00395 * Returns @c getline(s,n,widen('\n')). 00396 */ 00397 inline __istream_type& 00398 getline(char_type* __s, streamsize __n) 00399 { return this->getline(__s, __n, this->widen('\n')); } 00400 00401 /** 00402 * @brief Discarding characters 00403 * @param n Number of characters to discard. 00404 * @param delim A "stop" character. 00405 * @return *this 00406 * 00407 * Extracts characters and throws them away until one of the 00408 * following happens: 00409 * - if @a n @c != @c std::numeric_limits<int>::max(), @a n 00410 * characters are extracted 00411 * - the input sequence reaches end-of-file 00412 * - the next character equals @a delim (in this case, the character 00413 * is extracted); note that this condition will never occur if 00414 * @a delim equals @c traits::eof(). 00415 */ 00416 __istream_type& 00417 ignore(streamsize __n = 1, int_type __delim = traits_type::eof()); 00418 00419 /** 00420 * @brief Looking ahead in the stream 00421 * @return The next character, or eof(). 00422 * 00423 * If, after constructing the sentry object, @c good() is false, 00424 * returns @c traits::eof(). Otherwise reads but does not extract 00425 * the next input character. 00426 */ 00427 int_type 00428 peek(); 00429 00430 /** 00431 * @brief Extraction without delimiters. 00432 * @param s A character array. 00433 * @param n Maximum number of characters to store. 00434 * @return *this 00435 * 00436 * If the stream state is @c good(), extracts characters and stores 00437 * them into @a s until one of the following happens: 00438 * - @a n characters are stored 00439 * - the input sequence reaches end-of-file, in which case the error 00440 * state is set to @c failbit|eofbit. 00441 * 00442 * @note This function is not overloaded on signed char and 00443 * unsigned char. 00444 */ 00445 __istream_type& 00446 read(char_type* __s, streamsize __n); 00447 00448 /** 00449 * @brief Extraction until the buffer is exhausted, but no more. 00450 * @param s A character array. 00451 * @param n Maximum number of characters to store. 00452 * @return The number of characters extracted. 00453 * 00454 * Extracts characters and stores them into @a s depending on the 00455 * number of characters remaining in the streambuf's buffer, 00456 * @c rdbuf()->in_avail(), called @c A here: 00457 * - if @c A @c == @c -1, sets eofbit and extracts no characters 00458 * - if @c A @c == @c 0, extracts no characters 00459 * - if @c A @c > @c 0, extracts @c min(A,n) 00460 * 00461 * The goal is to empty the current buffer, and to not request any 00462 * more from the external input sequence controlled by the streambuf. 00463 */ 00464 streamsize 00465 readsome(char_type* __s, streamsize __n); 00466 00467 /** 00468 * @brief Unextracting a single character. 00469 * @param c The character to push back into the input stream. 00470 * @return *this 00471 * 00472 * If @c rdbuf() is not null, calls @c rdbuf()->sputbackc(c). 00473 * 00474 * If @c rdbuf() is null or if @c sputbackc() fails, sets badbit in 00475 * the error state. 00476 * 00477 * @note Since no characters are extracted, the next call to 00478 * @c gcount() will return 0, as required by DR 60. 00479 */ 00480 __istream_type& 00481 putback(char_type __c); 00482 00483 /** 00484 * @brief Unextracting the previous character. 00485 * @return *this 00486 * 00487 * If @c rdbuf() is not null, calls @c rdbuf()->sungetc(c). 00488 * 00489 * If @c rdbuf() is null or if @c sungetc() fails, sets badbit in 00490 * the error state. 00491 * 00492 * @note Since no characters are extracted, the next call to 00493 * @c gcount() will return 0, as required by DR 60. 00494 */ 00495 __istream_type& 00496 unget(); 00497 00498 /** 00499 * @brief Synchronizing the stream buffer. 00500 * @return 0 on success, -1 on failure 00501 * 00502 * If @c rdbuf() is a null pointer, returns -1. 00503 * 00504 * Otherwise, calls @c rdbuf()->pubsync(), and if that returns -1, 00505 * sets badbit and returns -1. 00506 * 00507 * Otherwise, returns 0. 00508 * 00509 * @note This function does not count the number of characters 00510 * extracted, if any, and therefore does not affect the next 00511 * call to @c gcount(). 00512 */ 00513 int 00514 sync(); 00515 00516 /** 00517 * @brief Getting the current read position. 00518 * @return A file position object. 00519 * 00520 * If @c fail() is not false, returns @c pos_type(-1) to indicate 00521 * failure. Otherwise returns @c rdbuf()->pubseekoff(0,cur,in). 00522 * 00523 * @note This function does not count the number of characters 00524 * extracted, if any, and therefore does not affect the next 00525 * call to @c gcount(). 00526 */ 00527 pos_type 00528 tellg(); 00529 00530 /** 00531 * @brief Changing the current read position. 00532 * @param pos A file position object. 00533 * @return *this 00534 * 00535 * If @c fail() is not true, calls @c rdbuf()->pubseekpos(pos). If 00536 * that function fails, sets failbit. 00537 * 00538 * @note This function does not count the number of characters 00539 * extracted, if any, and therefore does not affect the next 00540 * call to @c gcount(). 00541 */ 00542 __istream_type& 00543 seekg(pos_type); 00544 00545 /** 00546 * @brief Changing the current read position. 00547 * @param off A file offset object. 00548 * @param dir The direction in which to seek. 00549 * @return *this 00550 * 00551 * If @c fail() is not true, calls @c rdbuf()->pubseekoff(off,dir). 00552 * If that function fails, sets failbit. 00553 * 00554 * @note This function does not count the number of characters 00555 * extracted, if any, and therefore does not affect the next 00556 * call to @c gcount(). 00557 */ 00558 __istream_type& 00559 seekg(off_type, ios_base::seekdir); 00560 //@} 00561 00562 protected: 00563 explicit 00564 basic_istream(): _M_gcount(streamsize(0)) { } 00565 }; 00566 00567 /** 00568 * @brief Performs setup work for input streams. 00569 * 00570 * Objects of this class are created before all of the standard 00571 * extractors are run. It is responsible for "exception-safe prefix and 00572 * suffix operations," although only prefix actions are currently required 00573 * by the standard. Additional actions may be added by the 00574 * implementation, and we list them in 00575 * http://gcc.gnu.org/onlinedocs/libstdc++/17_intro/howto.html#5 00576 * under [27.6] notes. 00577 */ 00578 template<typename _CharT, typename _Traits> 00579 class basic_istream<_CharT, _Traits>::sentry 00580 { 00581 public: 00582 /// Easy access to dependant types. 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 00589 /** 00590 * @brief The constructor performs all the work. 00591 * @param is The input stream to guard. 00592 * @param noskipws Whether to consume whitespace or not. 00593 * 00594 * If the stream state is good (@a is.good() is true), then the 00595 * following actions are performed, otherwise the sentry state is 00596 * false ("not okay") and failbit is set in the stream state. 00597 * 00598 * The sentry's preparatory actions are: 00599 * 00600 * -# if the stream is tied to an output stream, @c is.tie()->flush() 00601 * is called to synchronize the output sequence 00602 * -# if @a noskipws is false, and @c ios_base::skipws is set in 00603 * @c is.flags(), the sentry extracts and discards whitespace 00604 * characters from the stream. The currently imbued locale is 00605 * used to determine whether each character is whitespace. 00606 * 00607 * If the stream state is still good, then the sentry state becomes 00608 * true ("okay"). 00609 */ 00610 explicit 00611 sentry(basic_istream<_CharT, _Traits>& __is, bool __noskipws = false); 00612 00613 /** 00614 * @brief Quick status checking. 00615 * @return The sentry state. 00616 * 00617 * For ease of use, sentries may be converted to booleans. The 00618 * return value is that of the sentry state (true == okay). 00619 */ 00620 operator bool() const { return _M_ok; } 00621 00622 private: 00623 bool _M_ok; 00624 }; 00625 00626 // [27.6.1.2.3] character extraction templates 00627 //@{ 00628 /** 00629 * @brief Character extractors 00630 * @param in An input stream. 00631 * @param c A character reference. 00632 * @return in 00633 * 00634 * Behaves like one of the formatted arithmetic extractors described in 00635 * std::basic_istream. After constructing a sentry object with good 00636 * status, this function extracts a character (if one is available) and 00637 * stores it in @a c. Otherwise, sets failbit in the input stream. 00638 */ 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)); } 00652 //@} 00653 00654 //@{ 00655 /** 00656 * @brief Character string extractors 00657 * @param in An input stream. 00658 * @param s A pointer to a character array. 00659 * @return in 00660 * 00661 * Behaves like one of the formatted arithmetic extractors described in 00662 * std::basic_istream. After constructing a sentry object with good 00663 * status, this function extracts up to @c n characters and stores them 00664 * into the array starting at @a s. @c n is defined as: 00665 * 00666 * - if @c width() is greater than zero, @c n is width() 00667 * - otherwise @c n is "the number of elements of the largest array of 00668 * @c char_type that can store a terminating @c eos." [27.6.1.2.3]/6 00669 * 00670 * Characters are extracted and stored until one of the following happens: 00671 * - @c n-1 characters are stored 00672 * - EOF is reached 00673 * - the next character is whitespace according to the current locale 00674 * - the next character is a null byte (i.e., @c charT() ) 00675 * 00676 * @c width(0) is then called for the input stream. 00677 * 00678 * If no characters are extracted, sets failbit. 00679 */ 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)); } 00693 //@} 00694 00695 // 27.6.1.5 Template class basic_iostream 00696 /** 00697 * @brief Merging istream and ostream capabilities. 00698 * 00699 * This class multiply inherits from the input and output stream classes 00700 * simply to provide a single interface. 00701 */ 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 // _GLIBCXX_RESOLVE_LIB_DEFECTS 00709 // 271. basic_iostream missing typedefs 00710 // Types (inherited): 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 // Non-standard Types: 00718 typedef basic_istream<_CharT, _Traits> __istream_type; 00719 typedef basic_ostream<_CharT, _Traits> __ostream_type; 00720 00721 /** 00722 * @brief Constructor does nothing. 00723 * 00724 * Both of the parent classes are initialized with the same 00725 * streambuf pointer passed to this constructor. 00726 */ 00727 explicit 00728 basic_iostream(basic_streambuf<_CharT, _Traits>* __sb) 00729 : __istream_type(), __ostream_type() 00730 { this->init(__sb); } 00731 00732 /** 00733 * @brief Destructor does nothing. 00734 */ 00735 virtual 00736 ~basic_iostream() { } 00737 00738 protected: 00739 explicit 00740 basic_iostream() : __istream_type(), __ostream_type() 00741 { } 00742 }; 00743 00744 // [27.6.1.4] standard basic_istream manipulators 00745 /** 00746 * @brief Quick and easy way to eat whitespace 00747 * 00748 * This manipulator extracts whitespace characters, stopping when the 00749 * next character is non-whitespace, or when the input sequence is empty. 00750 * If the sequence is empty, @c eofbit is set in the stream, but not 00751 * @c failbit. 00752 * 00753 * The current locale is used to distinguish whitespace characters. 00754 * 00755 * Example: 00756 * @code 00757 * MyClass mc; 00758 * 00759 * std::cin >> std::ws >> mc; 00760 * @endcode 00761 * will skip leading whitespace before calling operator>> on cin and your 00762 * object. Note that the same effect can be achieved by creating a 00763 * std::basic_istream::sentry inside your definition of operator>>. 00764 */ 00765 template<typename _CharT, typename _Traits> 00766 basic_istream<_CharT, _Traits>& 00767 ws(basic_istream<_CharT, _Traits>& __is); 00768 } // namespace std 00769 00770 #ifndef _GLIBCXX_EXPORT_TEMPLATE 00771 # include <bits/istream.tcc> 00772 #endif 00773 00774 #endif /* _GLIBCXX_ISTREAM */

Generated on Wed Jun 9 11:18:36 2004 for libstdc++-v3 Source by doxygen 1.3.7