istream

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

Generated on Thu Feb 10 23:22:55 2005 for libstdc++-v3 Source by  doxygen 1.4.0