LCOV - lcov.info - /usr/include/c++/4.3/istream

LTP GCOV extension - code coverage report
Current view: | directory - usr/include/c++/4.3 - istream
Test: | lcov.info
Date: | 2008-08-14 |  | Instrumented lines: | 8
Code covered: | 0.0 % |  | Executed lines: | 0

           1                 : // Input streams -*- C++ -*-
           2                 :
           3                 : // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
           4                 : // 2006, 2007, 2008
           5                 : // Free Software Foundation, Inc.
           6                 : //
           7                 : // This file is part of the GNU ISO C++ Library.  This library is free
           8                 : // software; you can redistribute it and/or modify it under the
           9                 : // terms of the GNU General Public License as published by the
          10                 : // Free Software Foundation; either version 2, or (at your option)
          11                 : // any later version.
          12                 :
          13                 : // This library is distributed in the hope that it will be useful,
          14                 : // but WITHOUT ANY WARRANTY; without even the implied warranty of
          15                 : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
          16                 : // GNU General Public License for more details.
          17                 :
          18                 : // You should have received a copy of the GNU General Public License
          19                 : // along with this library; see the file COPYING.  If not, write to
          20                 : // the Free Software Foundation, 51 Franklin Street, Fifth Floor,
          21                 : // Boston, MA 02110-1301, USA.
          22                 :
          23                 : // As a special exception, you may use this file as part of a free software
          24                 : // library without restriction.  Specifically, if other files instantiate
          25                 : // templates or use macros or inline functions from this file, or you compile
          26                 : // this file and link it with other files to produce an executable, this
          27                 : // file does not by itself cause the resulting executable to be covered by
          28                 : // the GNU General Public License.  This exception does not however
          29                 : // invalidate any other reasons why the executable file might be covered by
          30                 : // the GNU General Public License.
          31                 :
          32                 : //
          33                 : // ISO C++ 14882: 27.6.1  Input streams
          34                 : //
          35                 :
          36                 : /** @file istream
          37                 :  *  This is a Standard C++ Library header.
          38                 :  */
          39                 :
          40                 : #ifndef _GLIBCXX_ISTREAM
          41                 : #define _GLIBCXX_ISTREAM 1
          42                 :
          43                 : #pragma GCC system_header
          44                 :
          45                 : #include <ios>
          46                 : #include <ostream>
          47                 :
          48                 : _GLIBCXX_BEGIN_NAMESPACE(std)
          49                 :
          50                 :   // [27.6.1.1] Template class basic_istream
          51                 :   /**
          52                 :    *  @brief  Controlling input.
          53                 :    *
          54                 :    *  This is the base class for all input streams.  It provides text
          55                 :    *  formatting of all builtin types, and communicates with any class
          56                 :    *  derived from basic_streambuf to do the actual input.
          57                 :   */
          58                 :   template<typename _CharT, typename _Traits>
          59                 :     class basic_istream : virtual public basic_ios<_CharT, _Traits>
          60                 :     {
          61                 :     public:
          62                 :       // Types (inherited from basic_ios (27.4.4)):
          63                 :       typedef _CharT                                    char_type;
          64                 :       typedef typename _Traits::int_type                int_type;
          65                 :       typedef typename _Traits::pos_type                pos_type;
          66                 :       typedef typename _Traits::off_type                off_type;
          67                 :       typedef _Traits                                   traits_type;
          68                 :
          69                 :       // Non-standard Types:
          70                 :       typedef basic_streambuf<_CharT, _Traits>            __streambuf_type;
          71                 :       typedef basic_ios<_CharT, _Traits>          __ios_type;
          72                 :       typedef basic_istream<_CharT, _Traits>              __istream_type;
          73                 :       typedef num_get<_CharT, istreambuf_iterator<_CharT, _Traits> >
          74                 :                                                         __num_get_type;
          75                 :       typedef ctype<_CharT>                               __ctype_type;
          76                 :
          77                 :     protected:
          78                 :       // Data Members:
          79                 :       /**
          80                 :        *  The number of characters extracted in the previous unformatted
          81                 :        *  function; see gcount().
          82                 :       */
          83                 :       streamsize                _M_gcount;
          84                 :
          85                 :     public:
          86                 :       // [27.6.1.1.1] constructor/destructor
          87                 :       /**
          88                 :        *  @brief  Base constructor.
          89                 :        *
          90                 :        *  This ctor is almost never called by the user directly, rather from
          91                 :        *  derived classes' initialization lists, which pass a pointer to
          92                 :        *  their own stream buffer.
          93                 :       */
          94                 :       explicit
          95                 :       basic_istream(__streambuf_type* __sb)
          96                 :       : _M_gcount(streamsize(0))
          97                 :       { this->init(__sb); }
          98                 :
          99                 :       /**
         100                 :        *  @brief  Base destructor.
         101                 :        *
         102                 :        *  This does very little apart from providing a virtual base dtor.
         103                 :       */
         104                 :       virtual
         105               0 :       ~basic_istream()
         106               0 :       { _M_gcount = streamsize(0); }
         107                 :
         108                 :       // [27.6.1.1.2] prefix/suffix
         109                 :       class sentry;
         110                 :       friend class sentry;
         111                 :
         112                 :       // [27.6.1.2] formatted input
         113                 :       // [27.6.1.2.3] basic_istream::operator>>
         114                 :       //@{
         115                 :       /**
         116                 :        *  @brief  Interface for manipulators.
         117                 :        *
         118                 :        *  Manipulators such as @c std::ws and @c std::dec use these
         119                 :        *  functions in constructs like "std::cin >> std::ws".  For more
         120                 :        *  information, see the iomanip header.
         121                 :       */
         122                 :       __istream_type&
         123                 :       operator>>(__istream_type& (*__pf)(__istream_type&))
         124                 :       { return __pf(*this); }
         125                 :
         126                 :       __istream_type&
         127                 :       operator>>(__ios_type& (*__pf)(__ios_type&))
         128                 :       {
         129                 :         __pf(*this);
         130                 :         return *this;
         131                 :       }
         132                 :
         133                 :       __istream_type&
         134                 :       operator>>(ios_base& (*__pf)(ios_base&))
         135                 :       {
         136                 :         __pf(*this);
         137                 :         return *this;
         138                 :       }
         139                 :       //@}
         140                 :
         141                 :       // [27.6.1.2.2] arithmetic extractors
         142                 :       /**
         143                 :        *  @name Arithmetic Extractors
         144                 :        *
         145                 :        *  All the @c operator>> functions (aka <em>formatted input
         146                 :        *  functions</em>) have some common behavior.  Each starts by
         147                 :        *  constructing a temporary object of type std::basic_istream::sentry
         148                 :        *  with the second argument (noskipws) set to false.  This has several
         149                 :        *  effects, concluding with the setting of a status flag; see the
         150                 :        *  sentry documentation for more.
         151                 :        *
         152                 :        *  If the sentry status is good, the function tries to extract
         153                 :        *  whatever data is appropriate for the type of the argument.
         154                 :        *
         155                 :        *  If an exception is thrown during extraction, ios_base::badbit
         156                 :        *  will be turned on in the stream's error state without causing an
         157                 :        *  ios_base::failure to be thrown.  The original exception will then
         158                 :        *  be rethrown.
         159                 :       */
         160                 :       //@{
         161                 :       /**
         162                 :        *  @brief  Basic arithmetic extractors
         163                 :        *  @param  A variable of builtin type.
         164                 :        *  @return  @c *this if successful
         165                 :        *
         166                 :        *  These functions use the stream's current locale (specifically, the
         167                 :        *  @c num_get facet) to parse the input data.
         168                 :       */
         169                 :       __istream_type&
         170                 :       operator>>(bool& __n)
         171                 :       { return _M_extract(__n); }
         172                 :
         173                 :       __istream_type&
         174                 :       operator>>(short& __n);
         175                 :
         176                 :       __istream_type&
         177                 :       operator>>(unsigned short& __n)
         178                 :       { return _M_extract(__n); }
         179                 :
         180                 :       __istream_type&
         181                 :       operator>>(int& __n);
         182                 :
         183                 :       __istream_type&
         184                 :       operator>>(unsigned int& __n)
         185                 :       { return _M_extract(__n); }
         186                 :
         187                 :       __istream_type&
         188                 :       operator>>(long& __n)
         189                 :       { return _M_extract(__n); }
         190                 :
         191                 :       __istream_type&
         192                 :       operator>>(unsigned long& __n)
         193                 :       { return _M_extract(__n); }
         194                 :
         195                 : #ifdef _GLIBCXX_USE_LONG_LONG
         196                 :       __istream_type&
         197                 :       operator>>(long long& __n)
         198                 :       { return _M_extract(__n); }
         199                 :
         200                 :       __istream_type&
         201                 :       operator>>(unsigned long long& __n)
         202                 :       { return _M_extract(__n); }
         203                 : #endif
         204                 :
         205                 :       __istream_type&
         206                 :       operator>>(float& __f)
         207                 :       { return _M_extract(__f); }
         208                 :
         209                 :       __istream_type&
         210                 :       operator>>(double& __f)
         211                 :       { return _M_extract(__f); }
         212                 :
         213                 :       __istream_type&
         214                 :       operator>>(long double& __f)
         215                 :       { return _M_extract(__f); }
         216                 :
         217                 :       __istream_type&
         218                 :       operator>>(void*& __p)
         219                 :       { return _M_extract(__p); }
         220                 :
         221                 :       /**
         222                 :        *  @brief  Extracting into another streambuf.
         223                 :        *  @param  sb  A pointer to a streambuf
         224                 :        *
         225                 :        *  This function behaves like one of the basic arithmetic extractors,
         226                 :        *  in that it also constructs a sentry object and has the same error
         227                 :        *  handling behavior.
         228                 :        *
         229                 :        *  If @a sb is NULL, the stream will set failbit in its error state.
         230                 :        *
         231                 :        *  Characters are extracted from this stream and inserted into the
         232                 :        *  @a sb streambuf until one of the following occurs:
         233                 :        *
         234                 :        *  - the input stream reaches end-of-file,
         235                 :        *  - insertion into the output buffer fails (in this case, the
         236                 :        *    character that would have been inserted is not extracted), or
         237                 :        *  - an exception occurs (and in this case is caught)
         238                 :        *
         239                 :        *  If the function inserts no characters, failbit is set.
         240                 :       */
         241                 :       __istream_type&
         242                 :       operator>>(__streambuf_type* __sb);
         243                 :       //@}
         244                 :
         245                 :       // [27.6.1.3] unformatted input
         246                 :       /**
         247                 :        *  @brief  Character counting
         248                 :        *  @return  The number of characters extracted by the previous
         249                 :        *           unformatted input function dispatched for this stream.
         250                 :       */
         251                 :       streamsize
         252                 :       gcount() const
         253                 :       { return _M_gcount; }
         254                 :
         255                 :       /**
         256                 :        *  @name Unformatted Input Functions
         257                 :        *
         258                 :        *  All the unformatted input functions have some common behavior.
         259                 :        *  Each starts by constructing a temporary object of type
         260                 :        *  std::basic_istream::sentry with the second argument (noskipws)
         261                 :        *  set to true.  This has several effects, concluding with the
         262                 :        *  setting of a status flag; see the sentry documentation for more.
         263                 :        *
         264                 :        *  If the sentry status is good, the function tries to extract
         265                 :        *  whatever data is appropriate for the type of the argument.
         266                 :        *
         267                 :        *  The number of characters extracted is stored for later retrieval
         268                 :        *  by gcount().
         269                 :        *
         270                 :        *  If an exception is thrown during extraction, ios_base::badbit
         271                 :        *  will be turned on in the stream's error state without causing an
         272                 :        *  ios_base::failure to be thrown.  The original exception will then
         273                 :        *  be rethrown.
         274                 :       */
         275                 :       //@{
         276                 :       /**
         277                 :        *  @brief  Simple extraction.
         278                 :        *  @return  A character, or eof().
         279                 :        *
         280                 :        *  Tries to extract a character.  If none are available, sets failbit
         281                 :        *  and returns traits::eof().
         282                 :       */
         283                 :       int_type
         284                 :       get();
         285                 :
         286                 :       /**
         287                 :        *  @brief  Simple extraction.
         288                 :        *  @param  c  The character in which to store data.
         289                 :        *  @return  *this
         290                 :        *
         291                 :        *  Tries to extract a character and store it in @a c.  If none are
         292                 :        *  available, sets failbit and returns traits::eof().
         293                 :        *
         294                 :        *  @note  This function is not overloaded on signed char and
         295                 :        *         unsigned char.
         296                 :       */
         297                 :       __istream_type&
         298                 :       get(char_type& __c);
         299                 :
         300                 :       /**
         301                 :        *  @brief  Simple multiple-character extraction.
         302                 :        *  @param  s  Pointer to an array.
         303                 :        *  @param  n  Maximum number of characters to store in @a s.
         304                 :        *  @param  delim  A "stop" character.
         305                 :        *  @return  *this
         306                 :        *
         307                 :        *  Characters are extracted and stored into @a s until one of the
         308                 :        *  following happens:
         309                 :        *
         310                 :        *  - @c n-1 characters are stored
         311                 :        *  - the input sequence reaches EOF
         312                 :        *  - the next character equals @a delim, in which case the character
         313                 :        *    is not extracted
         314                 :        *
         315                 :        * If no characters are stored, failbit is set in the stream's error
         316                 :        * state.
         317                 :        *
         318                 :        * In any case, a null character is stored into the next location in
         319                 :        * the array.
         320                 :        *
         321                 :        *  @note  This function is not overloaded on signed char and
         322                 :        *         unsigned char.
         323                 :       */
         324                 :       __istream_type&
         325                 :       get(char_type* __s, streamsize __n, char_type __delim);
         326                 :
         327                 :       /**
         328                 :        *  @brief  Simple multiple-character extraction.
         329                 :        *  @param  s  Pointer to an array.
         330                 :        *  @param  n  Maximum number of characters to store in @a s.
         331                 :        *  @return  *this
         332                 :        *
         333                 :        *  Returns @c get(s,n,widen('\n')).
         334                 :       */
         335                 :       __istream_type&
         336                 :       get(char_type* __s, streamsize __n)
         337                 :       { return this->get(__s, __n, this->widen('\n')); }
         338                 :
         339                 :       /**
         340                 :        *  @brief  Extraction into another streambuf.
         341                 :        *  @param  sb  A streambuf in which to store data.
         342                 :        *  @param  delim  A "stop" character.
         343                 :        *  @return  *this
         344                 :        *
         345                 :        *  Characters are extracted and inserted into @a sb until one of the
         346                 :        *  following happens:
         347                 :        *
         348                 :        *  - the input sequence reaches EOF
         349                 :        *  - insertion into the output buffer fails (in this case, the
         350                 :        *    character that would have been inserted is not extracted)
         351                 :        *  - the next character equals @a delim (in this case, the character
         352                 :        *    is not extracted)
         353                 :        *  - an exception occurs (and in this case is caught)
         354                 :        *
         355                 :        * If no characters are stored, failbit is set in the stream's error
         356                 :        * state.
         357                 :       */
         358                 :       __istream_type&
         359                 :       get(__streambuf_type& __sb, char_type __delim);
         360                 :
         361                 :       /**
         362                 :        *  @brief  Extraction into another streambuf.
         363                 :        *  @param  sb  A streambuf in which to store data.
         364                 :        *  @return  *this
         365                 :        *
         366                 :        *  Returns @c get(sb,widen('\n')).
         367                 :       */
         368                 :       __istream_type&
         369                 :       get(__streambuf_type& __sb)
         370                 :       { return this->get(__sb, this->widen('\n')); }
         371                 :
         372                 :       /**
         373                 :        *  @brief  String extraction.
         374                 :        *  @param  s  A character array in which to store the data.
         375                 :        *  @param  n  Maximum number of characters to extract.
         376                 :        *  @param  delim  A "stop" character.
         377                 :        *  @return  *this
         378                 :        *
         379                 :        *  Extracts and stores characters into @a s until one of the
         380                 :        *  following happens.  Note that these criteria are required to be
         381                 :        *  tested in the order listed here, to allow an input line to exactly
         382                 :        *  fill the @a s array without setting failbit.
         383                 :        *
         384                 :        *  -# the input sequence reaches end-of-file, in which case eofbit
         385                 :        *     is set in the stream error state
         386                 :        *  -# the next character equals @c delim, in which case the character
         387                 :        *     is extracted (and therefore counted in @c gcount()) but not stored
         388                 :        *  -# @c n-1 characters are stored, in which case failbit is set
         389                 :        *     in the stream error state
         390                 :        *
         391                 :        *  If no characters are extracted, failbit is set.  (An empty line of
         392                 :        *  input should therefore not cause failbit to be set.)
         393                 :        *
         394                 :        *  In any case, a null character is stored in the next location in
         395                 :        *  the array.
         396                 :       */
         397                 :       __istream_type&
         398                 :       getline(char_type* __s, streamsize __n, char_type __delim);
         399                 :
         400                 :       /**
         401                 :        *  @brief  String extraction.
         402                 :        *  @param  s  A character array in which to store the data.
         403                 :        *  @param  n  Maximum number of characters to extract.
         404                 :        *  @return  *this
         405                 :        *
         406                 :        *  Returns @c getline(s,n,widen('\n')).
         407                 :       */
         408                 :       __istream_type&
         409                 :       getline(char_type* __s, streamsize __n)
         410                 :       { return this->getline(__s, __n, this->widen('\n')); }
         411                 :
         412                 :       /**
         413                 :        *  @brief  Discarding characters
         414                 :        *  @param  n  Number of characters to discard.
         415                 :        *  @param  delim  A "stop" character.
         416                 :        *  @return  *this
         417                 :        *
         418                 :        *  Extracts characters and throws them away until one of the
         419                 :        *  following happens:
         420                 :        *  - if @a n @c != @c std::numeric_limits<int>::max(), @a n
         421                 :        *    characters are extracted
         422                 :        *  - the input sequence reaches end-of-file
         423                 :        *  - the next character equals @a delim (in this case, the character
         424                 :        *    is extracted); note that this condition will never occur if
         425                 :        *    @a delim equals @c traits::eof().
         426                 :        *
         427                 :        *  NB: Provide three overloads, instead of the single function
         428                 :        *  (with defaults) mandated by the Standard: this leads to a
         429                 :        *  better performing implementation, while still conforming to
         430                 :        *  the Standard.
         431                 :       */
         432                 :       __istream_type&
         433                 :       ignore();
         434                 :
         435                 :       __istream_type&
         436                 :       ignore(streamsize __n);
         437                 :
         438                 :       __istream_type&
         439                 :       ignore(streamsize __n, int_type __delim);
         440                 :
         441                 :       /**
         442                 :        *  @brief  Looking ahead in the stream
         443                 :        *  @return  The next character, or eof().
         444                 :        *
         445                 :        *  If, after constructing the sentry object, @c good() is false,
         446                 :        *  returns @c traits::eof().  Otherwise reads but does not extract
         447                 :        *  the next input character.
         448                 :       */
         449                 :       int_type
         450                 :       peek();
         451                 :
         452                 :       /**
         453                 :        *  @brief  Extraction without delimiters.
         454                 :        *  @param  s  A character array.
         455                 :        *  @param  n  Maximum number of characters to store.
         456                 :        *  @return  *this
         457                 :        *
         458                 :        *  If the stream state is @c good(), extracts characters and stores
         459                 :        *  them into @a s until one of the following happens:
         460                 :        *  - @a n characters are stored
         461                 :        *  - the input sequence reaches end-of-file, in which case the error
         462                 :        *    state is set to @c failbit|eofbit.
         463                 :        *
         464                 :        *  @note  This function is not overloaded on signed char and
         465                 :        *         unsigned char.
         466                 :       */
         467                 :       __istream_type&
         468                 :       read(char_type* __s, streamsize __n);
         469                 :
         470                 :       /**
         471                 :        *  @brief  Extraction until the buffer is exhausted, but no more.
         472                 :        *  @param  s  A character array.
         473                 :        *  @param  n  Maximum number of characters to store.
         474                 :        *  @return  The number of characters extracted.
         475                 :        *
         476                 :        *  Extracts characters and stores them into @a s depending on the
         477                 :        *  number of characters remaining in the streambuf's buffer,
         478                 :        *  @c rdbuf()->in_avail(), called @c A here:
         479                 :        *  - if @c A @c == @c -1, sets eofbit and extracts no characters
         480                 :        *  - if @c A @c == @c 0, extracts no characters
         481                 :        *  - if @c A @c > @c 0, extracts @c min(A,n)
         482                 :        *
         483                 :        *  The goal is to empty the current buffer, and to not request any
         484                 :        *  more from the external input sequence controlled by the streambuf.
         485                 :       */
         486                 :       streamsize
         487                 :       readsome(char_type* __s, streamsize __n);
         488                 :
         489                 :       /**
         490                 :        *  @brief  Unextracting a single character.
         491                 :        *  @param  c  The character to push back into the input stream.
         492                 :        *  @return  *this
         493                 :        *
         494                 :        *  If @c rdbuf() is not null, calls @c rdbuf()->sputbackc(c).
         495                 :        *
         496                 :        *  If @c rdbuf() is null or if @c sputbackc() fails, sets badbit in
         497                 :        *  the error state.
         498                 :        *
         499                 :        *  @note  Since no characters are extracted, the next call to
         500                 :        *         @c gcount() will return 0, as required by DR 60.
         501                 :       */
         502                 :       __istream_type&
         503                 :       putback(char_type __c);
         504                 :
         505                 :       /**
         506                 :        *  @brief  Unextracting the previous character.
         507                 :        *  @return  *this
         508                 :        *
         509                 :        *  If @c rdbuf() is not null, calls @c rdbuf()->sungetc(c).
         510                 :        *
         511                 :        *  If @c rdbuf() is null or if @c sungetc() fails, sets badbit in
         512                 :        *  the error state.
         513                 :        *
         514                 :        *  @note  Since no characters are extracted, the next call to
         515                 :        *         @c gcount() will return 0, as required by DR 60.
         516                 :       */
         517                 :       __istream_type&
         518                 :       unget();
         519                 :
         520                 :       /**
         521                 :        *  @brief  Synchronizing the stream buffer.
         522                 :        *  @return  0 on success, -1 on failure
         523                 :        *
         524                 :        *  If @c rdbuf() is a null pointer, returns -1.
         525                 :        *
         526                 :        *  Otherwise, calls @c rdbuf()->pubsync(), and if that returns -1,
         527                 :        *  sets badbit and returns -1.
         528                 :        *
         529                 :        *  Otherwise, returns 0.
         530                 :        *
         531                 :        *  @note  This function does not count the number of characters
         532                 :        *         extracted, if any, and therefore does not affect the next
         533                 :        *         call to @c gcount().
         534                 :       */
         535                 :       int
         536                 :       sync();
         537                 :
         538                 :       /**
         539                 :        *  @brief  Getting the current read position.
         540                 :        *  @return  A file position object.
         541                 :        *
         542                 :        *  If @c fail() is not false, returns @c pos_type(-1) to indicate
         543                 :        *  failure.  Otherwise returns @c rdbuf()->pubseekoff(0,cur,in).
         544                 :        *
         545                 :        *  @note  This function does not count the number of characters
         546                 :        *         extracted, if any, and therefore does not affect the next
         547                 :        *         call to @c gcount().
         548                 :       */
         549                 :       pos_type
         550                 :       tellg();
         551                 :
         552                 :       /**
         553                 :        *  @brief  Changing the current read position.
         554                 :        *  @param  pos  A file position object.
         555                 :        *  @return  *this
         556                 :        *
         557                 :        *  If @c fail() is not true, calls @c rdbuf()->pubseekpos(pos).  If
         558                 :        *  that function fails, sets failbit.
         559                 :        *
         560                 :        *  @note  This function does not count the number of characters
         561                 :        *         extracted, if any, and therefore does not affect the next
         562                 :        *         call to @c gcount().
         563                 :       */
         564                 :       __istream_type&
         565                 :       seekg(pos_type);
         566                 :
         567                 :       /**
         568                 :        *  @brief  Changing the current read position.
         569                 :        *  @param  off  A file offset object.
         570                 :        *  @param  dir  The direction in which to seek.
         571                 :        *  @return  *this
         572                 :        *
         573                 :        *  If @c fail() is not true, calls @c rdbuf()->pubseekoff(off,dir).
         574                 :        *  If that function fails, sets failbit.
         575                 :        *
         576                 :        *  @note  This function does not count the number of characters
         577                 :        *         extracted, if any, and therefore does not affect the next
         578                 :        *         call to @c gcount().
         579                 :       */
         580                 :       __istream_type&
         581                 :       seekg(off_type, ios_base::seekdir);
         582                 :       //@}
         583                 :
         584                 :     protected:
         585               0 :       basic_istream()
         586               0 :       : _M_gcount(streamsize(0))
         587               0 :       { this->init(0); }
         588                 :
         589                 :       template<typename _ValueT>
         590                 :         __istream_type&
         591                 :         _M_extract(_ValueT& __v);
         592                 :     };
         593                 :
         594                 :   // Explicit specialization declarations, defined in src/istream.cc.
         595                 :   template<>
         596                 :     basic_istream<char>&
         597                 :     basic_istream<char>::
         598                 :     getline(char_type* __s, streamsize __n, char_type __delim);
         599                 :
         600                 :   template<>
         601                 :     basic_istream<char>&
         602                 :     basic_istream<char>::
         603                 :     ignore(streamsize __n);
         604                 :
         605                 :   template<>
         606                 :     basic_istream<char>&
         607                 :     basic_istream<char>::
         608                 :     ignore(streamsize __n, int_type __delim);
         609                 :
         610                 : #ifdef _GLIBCXX_USE_WCHAR_T
         611                 :   template<>
         612                 :     basic_istream<wchar_t>&
         613                 :     basic_istream<wchar_t>::
         614                 :     getline(char_type* __s, streamsize __n, char_type __delim);
         615                 :
         616                 :   template<>
         617                 :     basic_istream<wchar_t>&
         618                 :     basic_istream<wchar_t>::
         619                 :     ignore(streamsize __n);
         620                 :
         621                 :   template<>
         622                 :     basic_istream<wchar_t>&
         623                 :     basic_istream<wchar_t>::
         624                 :     ignore(streamsize __n, int_type __delim);
         625                 : #endif
         626                 :
         627                 :   /**
         628                 :    *  @brief  Performs setup work for input streams.
         629                 :    *
         630                 :    *  Objects of this class are created before all of the standard
         631                 :    *  extractors are run.  It is responsible for "exception-safe prefix and
         632                 :    *  suffix operations," although only prefix actions are currently required
         633                 :    *  by the standard.  Additional actions may be added by the
         634                 :    *  implementation, and we list them in
         635                 :    *  http://gcc.gnu.org/onlinedocs/libstdc++/17_intro/howto.html#5
         636                 :    *  under [27.6] notes.
         637                 :   */
         638                 :   template<typename _CharT, typename _Traits>
         639                 :     class basic_istream<_CharT, _Traits>::sentry
         640                 :     {
         641                 :     public:
         642                 :       /// Easy access to dependant types.
         643                 :       typedef _Traits                                   traits_type;
         644                 :       typedef basic_streambuf<_CharT, _Traits>            __streambuf_type;
         645                 :       typedef basic_istream<_CharT, _Traits>              __istream_type;
         646                 :       typedef typename __istream_type::__ctype_type     __ctype_type;
         647                 :       typedef typename _Traits::int_type                __int_type;
         648                 :
         649                 :       /**
         650                 :        *  @brief  The constructor performs all the work.
         651                 :        *  @param  is  The input stream to guard.
         652                 :        *  @param  noskipws  Whether to consume whitespace or not.
         653                 :        *
         654                 :        *  If the stream state is good (@a is.good() is true), then the
         655                 :        *  following actions are performed, otherwise the sentry state is
         656                 :        *  false ("not okay") and failbit is set in the stream state.
         657                 :        *
         658                 :        *  The sentry's preparatory actions are:
         659                 :        *
         660                 :        *  -# if the stream is tied to an output stream, @c is.tie()->flush()
         661                 :        *     is called to synchronize the output sequence
         662                 :        *  -# if @a noskipws is false, and @c ios_base::skipws is set in
         663                 :        *     @c is.flags(), the sentry extracts and discards whitespace
         664                 :        *     characters from the stream.  The currently imbued locale is
         665                 :        *     used to determine whether each character is whitespace.
         666                 :        *
         667                 :        *  If the stream state is still good, then the sentry state becomes
         668                 :        *  true ("okay").
         669                 :       */
         670                 :       explicit
         671                 :       sentry(basic_istream<_CharT, _Traits>& __is, bool __noskipws = false);
         672                 :
         673                 :       /**
         674                 :        *  @brief  Quick status checking.
         675                 :        *  @return  The sentry state.
         676                 :        *
         677                 :        *  For ease of use, sentries may be converted to booleans.  The
         678                 :        *  return value is that of the sentry state (true == okay).
         679                 :       */
         680                 :       operator bool() const
         681                 :       { return _M_ok; }
         682                 :
         683                 :     private:
         684                 :       bool _M_ok;
         685                 :     };
         686                 :
         687                 :   // [27.6.1.2.3] character extraction templates
         688                 :   //@{
         689                 :   /**
         690                 :    *  @brief  Character extractors
         691                 :    *  @param  in  An input stream.
         692                 :    *  @param  c  A character reference.
         693                 :    *  @return  in
         694                 :    *
         695                 :    *  Behaves like one of the formatted arithmetic extractors described in
         696                 :    *  std::basic_istream.  After constructing a sentry object with good
         697                 :    *  status, this function extracts a character (if one is available) and
         698                 :    *  stores it in @a c.  Otherwise, sets failbit in the input stream.
         699                 :   */
         700                 :   template<typename _CharT, typename _Traits>
         701                 :     basic_istream<_CharT, _Traits>&
         702                 :     operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c);
         703                 :
         704                 :   template<class _Traits>
         705                 :     inline basic_istream<char, _Traits>&
         706                 :     operator>>(basic_istream<char, _Traits>& __in, unsigned char& __c)
         707                 :     { return (__in >> reinterpret_cast<char&>(__c)); }
         708                 :
         709                 :   template<class _Traits>
         710                 :     inline basic_istream<char, _Traits>&
         711                 :     operator>>(basic_istream<char, _Traits>& __in, signed char& __c)
         712                 :     { return (__in >> reinterpret_cast<char&>(__c)); }
         713                 :   //@}
         714                 :
         715                 :   //@{
         716                 :   /**
         717                 :    *  @brief  Character string extractors
         718                 :    *  @param  in  An input stream.
         719                 :    *  @param  s  A pointer to a character array.
         720                 :    *  @return  in
         721                 :    *
         722                 :    *  Behaves like one of the formatted arithmetic extractors described in
         723                 :    *  std::basic_istream.  After constructing a sentry object with good
         724                 :    *  status, this function extracts up to @c n characters and stores them
         725                 :    *  into the array starting at @a s.  @c n is defined as:
         726                 :    *
         727                 :    *  - if @c width() is greater than zero, @c n is width()
         728                 :    *  - otherwise @c n is "the number of elements of the largest array of
         729                 :    *    @c char_type that can store a terminating @c eos." [27.6.1.2.3]/6
         730                 :    *
         731                 :    *  Characters are extracted and stored until one of the following happens:
         732                 :    *  - @c n-1 characters are stored
         733                 :    *  - EOF is reached
         734                 :    *  - the next character is whitespace according to the current locale
         735                 :    *  - the next character is a null byte (i.e., @c charT() )
         736                 :    *
         737                 :    *  @c width(0) is then called for the input stream.
         738                 :    *
         739                 :    *  If no characters are extracted, sets failbit.
         740                 :   */
         741                 :   template<typename _CharT, typename _Traits>
         742                 :     basic_istream<_CharT, _Traits>&
         743                 :     operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s);
         744                 :
         745                 :   // Explicit specialization declaration, defined in src/istream.cc.
         746                 :   template<>
         747                 :     basic_istream<char>&
         748                 :     operator>>(basic_istream<char>& __in, char* __s);
         749                 :
         750                 :   template<class _Traits>
         751                 :     inline basic_istream<char, _Traits>&
         752                 :     operator>>(basic_istream<char, _Traits>& __in, unsigned char* __s)
         753                 :     { return (__in >> reinterpret_cast<char*>(__s)); }
         754                 :
         755                 :   template<class _Traits>
         756                 :     inline basic_istream<char, _Traits>&
         757                 :     operator>>(basic_istream<char, _Traits>& __in, signed char* __s)
         758                 :     { return (__in >> reinterpret_cast<char*>(__s)); }
         759                 :   //@}
         760                 :
         761                 :   // 27.6.1.5 Template class basic_iostream
         762                 :   /**
         763                 :    *  @brief  Merging istream and ostream capabilities.
         764                 :    *
         765                 :    *  This class multiply inherits from the input and output stream classes
         766                 :    *  simply to provide a single interface.
         767                 :   */
         768                 :   template<typename _CharT, typename _Traits>
         769                 :     class basic_iostream
         770                 :     : public basic_istream<_CharT, _Traits>,
         771                 :       public basic_ostream<_CharT, _Traits>
         772                 :     {
         773                 :     public:
         774                 :       // _GLIBCXX_RESOLVE_LIB_DEFECTS
         775                 :       // 271. basic_iostream missing typedefs
         776                 :       // Types (inherited):
         777                 :       typedef _CharT                                    char_type;
         778                 :       typedef typename _Traits::int_type                int_type;
         779                 :       typedef typename _Traits::pos_type                pos_type;
         780                 :       typedef typename _Traits::off_type                off_type;
         781                 :       typedef _Traits                                   traits_type;
         782                 :
         783                 :       // Non-standard Types:
         784                 :       typedef basic_istream<_CharT, _Traits>              __istream_type;
         785                 :       typedef basic_ostream<_CharT, _Traits>              __ostream_type;
         786                 :
         787                 :       /**
         788                 :        *  @brief  Constructor does nothing.
         789                 :        *
         790                 :        *  Both of the parent classes are initialized with the same
         791                 :        *  streambuf pointer passed to this constructor.
         792                 :       */
         793                 :       explicit
         794                 :       basic_iostream(basic_streambuf<_CharT, _Traits>* __sb)
         795                 :       : __istream_type(__sb), __ostream_type(__sb) { }
         796                 :
         797                 :       /**
         798                 :        *  @brief  Destructor does nothing.
         799                 :       */
         800                 :       virtual
         801               0 :       ~basic_iostream() { }
         802                 :
         803                 :     protected:
         804               0 :       basic_iostream()
         805               0 :       : __istream_type(), __ostream_type() { }
         806                 :     };
         807                 :
         808                 :   // [27.6.1.4] standard basic_istream manipulators
         809                 :   /**
         810                 :    *  @brief  Quick and easy way to eat whitespace
         811                 :    *
         812                 :    *  This manipulator extracts whitespace characters, stopping when the
         813                 :    *  next character is non-whitespace, or when the input sequence is empty.
         814                 :    *  If the sequence is empty, @c eofbit is set in the stream, but not
         815                 :    *  @c failbit.
         816                 :    *
         817                 :    *  The current locale is used to distinguish whitespace characters.
         818                 :    *
         819                 :    *  Example:
         820                 :    *  @code
         821                 :    *     MyClass   mc;
         822                 :    *
         823                 :    *     std::cin >> std::ws >> mc;
         824                 :    *  @endcode
         825                 :    *  will skip leading whitespace before calling operator>> on cin and your
         826                 :    *  object.  Note that the same effect can be achieved by creating a
         827                 :    *  std::basic_istream::sentry inside your definition of operator>>.
         828                 :   */
         829                 :   template<typename _CharT, typename _Traits>
         830                 :     basic_istream<_CharT, _Traits>&
         831                 :     ws(basic_istream<_CharT, _Traits>& __is);
         832                 :
         833                 : _GLIBCXX_END_NAMESPACE
         834                 :
         835                 : #ifndef _GLIBCXX_EXPORT_TEMPLATE
         836                 : # include <bits/istream.tcc>
         837                 : #endif
         838                 :
         839                 : #endif  /* _GLIBCXX_ISTREAM */

Generated by: LTP GCOV extension version 1.6