LCOV - code coverage report
Current view: directory - tools/gcc-4.5/include/c++/4.5.2/bits - ios_base.h (source / functions) Found Hit Coverage
Test: app.info Lines: 52 4 7.7 %
Date: 2012-06-02 Functions: 20 2 10.0 %

       1                 : // Iostreams base classes -*- C++ -*-
       2                 : 
       3                 : // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
       4                 : // 2006, 2007, 2008, 2009, 2010
       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 3, 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                 : // Under Section 7 of GPL version 3, you are granted additional
      19                 : // permissions described in the GCC Runtime Library Exception, version
      20                 : // 3.1, as published by the Free Software Foundation.
      21                 : 
      22                 : // You should have received a copy of the GNU General Public License and
      23                 : // a copy of the GCC Runtime Library Exception along with this program;
      24                 : // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
      25                 : // <http://www.gnu.org/licenses/>.
      26                 : 
      27                 : /** @file ios_base.h
      28                 :  *  This is an internal header file, included by other library headers.
      29                 :  *  You should not attempt to use it directly.
      30                 :  */
      31                 : 
      32                 : //
      33                 : // ISO C++ 14882: 27.4  Iostreams base classes
      34                 : //
      35                 : 
      36                 : #ifndef _IOS_BASE_H
      37                 : #define _IOS_BASE_H 1
      38                 : 
      39                 : #pragma GCC system_header
      40                 : 
      41                 : #include <ext/atomicity.h>
      42                 : #include <bits/localefwd.h>
      43                 : #include <bits/locale_classes.h>
      44                 : 
      45                 : #ifndef _GLIBCXX_STDIO_MACROS
      46                 : # include <cstdio>   // For SEEK_CUR, SEEK_END
      47                 : # define _IOS_BASE_SEEK_CUR SEEK_CUR
      48                 : # define _IOS_BASE_SEEK_END SEEK_END
      49                 : #else
      50                 : # define _IOS_BASE_SEEK_CUR 1
      51                 : # define _IOS_BASE_SEEK_END 2
      52                 : #endif
      53                 : 
      54                 : _GLIBCXX_BEGIN_NAMESPACE(std)
      55                 : 
      56                 :   // The following definitions of bitmask types are enums, not ints,
      57                 :   // as permitted (but not required) in the standard, in order to provide
      58                 :   // better type safety in iostream calls.  A side effect is that
      59                 :   // expressions involving them are no longer compile-time constants.
      60                 :   enum _Ios_Fmtflags 
      61                 :     { 
      62                 :       _S_boolalpha      = 1L << 0,
      63                 :       _S_dec            = 1L << 1,
      64                 :       _S_fixed          = 1L << 2,
      65                 :       _S_hex            = 1L << 3,
      66                 :       _S_internal       = 1L << 4,
      67                 :       _S_left           = 1L << 5,
      68                 :       _S_oct            = 1L << 6,
      69                 :       _S_right          = 1L << 7,
      70                 :       _S_scientific     = 1L << 8,
      71                 :       _S_showbase       = 1L << 9,
      72                 :       _S_showpoint      = 1L << 10,
      73                 :       _S_showpos        = 1L << 11,
      74                 :       _S_skipws         = 1L << 12,
      75                 :       _S_unitbuf        = 1L << 13,
      76                 :       _S_uppercase      = 1L << 14,
      77                 :       _S_adjustfield    = _S_left | _S_right | _S_internal,
      78                 :       _S_basefield      = _S_dec | _S_oct | _S_hex,
      79                 :       _S_floatfield     = _S_scientific | _S_fixed,
      80                 :       _S_ios_fmtflags_end = 1L << 16 
      81                 :     };
      82                 : 
      83                 :   inline _Ios_Fmtflags
      84               0 :   operator&(_Ios_Fmtflags __a, _Ios_Fmtflags __b)
      85               0 :   { return _Ios_Fmtflags(static_cast<int>(__a) & static_cast<int>(__b)); }
      86                 : 
      87                 :   inline _Ios_Fmtflags
      88               0 :   operator|(_Ios_Fmtflags __a, _Ios_Fmtflags __b)
      89               0 :   { return _Ios_Fmtflags(static_cast<int>(__a) | static_cast<int>(__b)); }
      90                 : 
      91                 :   inline _Ios_Fmtflags
      92                 :   operator^(_Ios_Fmtflags __a, _Ios_Fmtflags __b)
      93                 :   { return _Ios_Fmtflags(static_cast<int>(__a) ^ static_cast<int>(__b)); }
      94                 : 
      95                 :   inline _Ios_Fmtflags&
      96               0 :   operator|=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b)
      97               0 :   { return __a = __a | __b; }
      98                 : 
      99                 :   inline _Ios_Fmtflags&
     100               0 :   operator&=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b)
     101               0 :   { return __a = __a & __b; }
     102                 : 
     103                 :   inline _Ios_Fmtflags&
     104                 :   operator^=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b)
     105                 :   { return __a = __a ^ __b; }
     106                 : 
     107                 :   inline _Ios_Fmtflags
     108               0 :   operator~(_Ios_Fmtflags __a)
     109               0 :   { return _Ios_Fmtflags(~static_cast<int>(__a)); }
     110                 : 
     111                 : 
     112                 :   enum _Ios_Openmode 
     113                 :     { 
     114                 :       _S_app            = 1L << 0,
     115                 :       _S_ate            = 1L << 1,
     116                 :       _S_bin            = 1L << 2,
     117                 :       _S_in             = 1L << 3,
     118                 :       _S_out            = 1L << 4,
     119                 :       _S_trunc          = 1L << 5,
     120                 :       _S_ios_openmode_end = 1L << 16 
     121                 :     };
     122                 : 
     123                 :   inline _Ios_Openmode
     124               0 :   operator&(_Ios_Openmode __a, _Ios_Openmode __b)
     125               0 :   { return _Ios_Openmode(static_cast<int>(__a) & static_cast<int>(__b)); }
     126                 : 
     127                 :   inline _Ios_Openmode
     128              50 :   operator|(_Ios_Openmode __a, _Ios_Openmode __b)
     129              50 :   { return _Ios_Openmode(static_cast<int>(__a) | static_cast<int>(__b)); }
     130                 : 
     131                 :   inline _Ios_Openmode
     132                 :   operator^(_Ios_Openmode __a, _Ios_Openmode __b)
     133                 :   { return _Ios_Openmode(static_cast<int>(__a) ^ static_cast<int>(__b)); }
     134                 : 
     135                 :   inline _Ios_Openmode&
     136                 :   operator|=(_Ios_Openmode& __a, _Ios_Openmode __b)
     137                 :   { return __a = __a | __b; }
     138                 : 
     139                 :   inline _Ios_Openmode&
     140                 :   operator&=(_Ios_Openmode& __a, _Ios_Openmode __b)
     141                 :   { return __a = __a & __b; }
     142                 : 
     143                 :   inline _Ios_Openmode&
     144                 :   operator^=(_Ios_Openmode& __a, _Ios_Openmode __b)
     145                 :   { return __a = __a ^ __b; }
     146                 : 
     147                 :   inline _Ios_Openmode
     148                 :   operator~(_Ios_Openmode __a)
     149                 :   { return _Ios_Openmode(~static_cast<int>(__a)); }
     150                 : 
     151                 : 
     152                 :   enum _Ios_Iostate
     153                 :     { 
     154                 :       _S_goodbit                = 0,
     155                 :       _S_badbit                 = 1L << 0,
     156                 :       _S_eofbit                 = 1L << 1,
     157                 :       _S_failbit                = 1L << 2,
     158                 :       _S_ios_iostate_end = 1L << 16 
     159                 :     };
     160                 : 
     161                 :   inline _Ios_Iostate
     162               0 :   operator&(_Ios_Iostate __a, _Ios_Iostate __b)
     163               0 :   { return _Ios_Iostate(static_cast<int>(__a) & static_cast<int>(__b)); }
     164                 : 
     165                 :   inline _Ios_Iostate
     166              84 :   operator|(_Ios_Iostate __a, _Ios_Iostate __b)
     167              84 :   { return _Ios_Iostate(static_cast<int>(__a) | static_cast<int>(__b)); }
     168                 : 
     169                 :   inline _Ios_Iostate
     170                 :   operator^(_Ios_Iostate __a, _Ios_Iostate __b)
     171                 :   { return _Ios_Iostate(static_cast<int>(__a) ^ static_cast<int>(__b)); }
     172                 : 
     173                 :   inline _Ios_Iostate&
     174               0 :   operator|=(_Ios_Iostate& __a, _Ios_Iostate __b)
     175               0 :   { return __a = __a | __b; }
     176                 : 
     177                 :   inline _Ios_Iostate&
     178                 :   operator&=(_Ios_Iostate& __a, _Ios_Iostate __b)
     179                 :   { return __a = __a & __b; }
     180                 : 
     181                 :   inline _Ios_Iostate&
     182                 :   operator^=(_Ios_Iostate& __a, _Ios_Iostate __b)
     183                 :   { return __a = __a ^ __b; }
     184                 : 
     185                 :   inline _Ios_Iostate
     186                 :   operator~(_Ios_Iostate __a)
     187                 :   { return _Ios_Iostate(~static_cast<int>(__a)); }
     188                 : 
     189                 :   enum _Ios_Seekdir 
     190                 :     { 
     191                 :       _S_beg = 0,
     192                 :       _S_cur = _IOS_BASE_SEEK_CUR,
     193                 :       _S_end = _IOS_BASE_SEEK_END,
     194                 :       _S_ios_seekdir_end = 1L << 16 
     195                 :     };
     196                 : 
     197                 :   // 27.4.2  Class ios_base
     198                 :   /**
     199                 :    *  @brief  The base of the I/O class hierarchy.
     200                 :    *  @ingroup io
     201                 :    *
     202                 :    *  This class defines everything that can be defined about I/O that does
     203                 :    *  not depend on the type of characters being input or output.  Most
     204                 :    *  people will only see @c ios_base when they need to specify the full
     205                 :    *  name of the various I/O flags (e.g., the openmodes).
     206                 :   */
     207                 :   class ios_base
     208                 :   {
     209                 :   public:
     210                 : 
     211                 :     /** 
     212                 :      *  @brief These are thrown to indicate problems with io.
     213                 :      *  @ingroup exceptions
     214                 :      *
     215                 :      *  27.4.2.1.1  Class ios_base::failure
     216                 :      */
     217                 :     class failure : public exception
     218                 :     {
     219                 :     public:
     220                 :       // _GLIBCXX_RESOLVE_LIB_DEFECTS
     221                 :       // 48.  Use of non-existent exception constructor
     222                 :       explicit
     223                 :       failure(const string& __str) throw();
     224                 : 
     225                 :       // This declaration is not useless:
     226                 :       // http://gcc.gnu.org/onlinedocs/gcc-4.3.2/gcc/Vague-Linkage.html
     227                 :       virtual
     228                 :       ~failure() throw();
     229                 : 
     230                 :       virtual const char*
     231                 :       what() const throw();
     232                 : 
     233                 :     private:
     234                 :       string _M_msg;
     235                 :     };
     236                 : 
     237                 :     // 27.4.2.1.2  Type ios_base::fmtflags
     238                 :     /**
     239                 :      *  @brief This is a bitmask type.
     240                 :      *
     241                 :      *  @c @a _Ios_Fmtflags is implementation-defined, but it is valid to
     242                 :      *  perform bitwise operations on these values and expect the Right
     243                 :      *  Thing to happen.  Defined objects of type fmtflags are:
     244                 :      *  - boolalpha
     245                 :      *  - dec
     246                 :      *  - fixed
     247                 :      *  - hex
     248                 :      *  - internal
     249                 :      *  - left
     250                 :      *  - oct
     251                 :      *  - right
     252                 :      *  - scientific
     253                 :      *  - showbase
     254                 :      *  - showpoint
     255                 :      *  - showpos
     256                 :      *  - skipws
     257                 :      *  - unitbuf
     258                 :      *  - uppercase
     259                 :      *  - adjustfield
     260                 :      *  - basefield
     261                 :      *  - floatfield
     262                 :     */
     263                 :     typedef _Ios_Fmtflags fmtflags;
     264                 : 
     265                 :     /// Insert/extract @c bool in alphabetic rather than numeric format.
     266                 :     static const fmtflags boolalpha =   _S_boolalpha;
     267                 : 
     268                 :     /// Converts integer input or generates integer output in decimal base.
     269                 :     static const fmtflags dec =         _S_dec;
     270                 : 
     271                 :     /// Generate floating-point output in fixed-point notation.
     272                 :     static const fmtflags fixed =       _S_fixed;
     273                 : 
     274                 :     /// Converts integer input or generates integer output in hexadecimal base.
     275                 :     static const fmtflags hex =         _S_hex;
     276                 : 
     277                 :     /// Adds fill characters at a designated internal point in certain
     278                 :     /// generated output, or identical to @c right if no such point is
     279                 :     /// designated.
     280                 :     static const fmtflags internal =    _S_internal;
     281                 : 
     282                 :     /// Adds fill characters on the right (final positions) of certain
     283                 :     /// generated output.  (I.e., the thing you print is flush left.)
     284                 :     static const fmtflags left =        _S_left;
     285                 : 
     286                 :     /// Converts integer input or generates integer output in octal base.
     287                 :     static const fmtflags oct =         _S_oct;
     288                 : 
     289                 :     /// Adds fill characters on the left (initial positions) of certain
     290                 :     /// generated output.  (I.e., the thing you print is flush right.)
     291                 :     static const fmtflags right =       _S_right;
     292                 : 
     293                 :     /// Generates floating-point output in scientific notation.
     294                 :     static const fmtflags scientific =  _S_scientific;
     295                 : 
     296                 :     /// Generates a prefix indicating the numeric base of generated integer
     297                 :     /// output.
     298                 :     static const fmtflags showbase =    _S_showbase;
     299                 : 
     300                 :     /// Generates a decimal-point character unconditionally in generated
     301                 :     /// floating-point output.
     302                 :     static const fmtflags showpoint =   _S_showpoint;
     303                 : 
     304                 :     /// Generates a + sign in non-negative generated numeric output.
     305                 :     static const fmtflags showpos =     _S_showpos;
     306                 : 
     307                 :     /// Skips leading white space before certain input operations.
     308                 :     static const fmtflags skipws =      _S_skipws;
     309                 : 
     310                 :     /// Flushes output after each output operation.
     311                 :     static const fmtflags unitbuf =     _S_unitbuf;
     312                 : 
     313                 :     /// Replaces certain lowercase letters with their uppercase equivalents
     314                 :     /// in generated output.
     315                 :     static const fmtflags uppercase =   _S_uppercase;
     316                 : 
     317                 :     /// A mask of left|right|internal.  Useful for the 2-arg form of @c setf.
     318                 :     static const fmtflags adjustfield = _S_adjustfield;
     319                 : 
     320                 :     /// A mask of dec|oct|hex.  Useful for the 2-arg form of @c setf.
     321                 :     static const fmtflags basefield =   _S_basefield;
     322                 : 
     323                 :     /// A mask of scientific|fixed.  Useful for the 2-arg form of @c setf.
     324                 :     static const fmtflags floatfield =  _S_floatfield;
     325                 : 
     326                 :     // 27.4.2.1.3  Type ios_base::iostate
     327                 :     /**
     328                 :      *  @brief This is a bitmask type.
     329                 :      *
     330                 :      *  @c @a _Ios_Iostate is implementation-defined, but it is valid to
     331                 :      *  perform bitwise operations on these values and expect the Right
     332                 :      *  Thing to happen.  Defined objects of type iostate are:
     333                 :      *  - badbit
     334                 :      *  - eofbit
     335                 :      *  - failbit
     336                 :      *  - goodbit
     337                 :     */
     338                 :     typedef _Ios_Iostate iostate;
     339                 : 
     340                 :     /// Indicates a loss of integrity in an input or output sequence (such
     341                 :     /// as an irrecoverable read error from a file).
     342                 :     static const iostate badbit =       _S_badbit;
     343                 : 
     344                 :     /// Indicates that an input operation reached the end of an input sequence.
     345                 :     static const iostate eofbit =       _S_eofbit;
     346                 : 
     347                 :     /// Indicates that an input operation failed to read the expected
     348                 :     /// characters, or that an output operation failed to generate the
     349                 :     /// desired characters.
     350                 :     static const iostate failbit =      _S_failbit;
     351                 : 
     352                 :     /// Indicates all is well.
     353                 :     static const iostate goodbit =      _S_goodbit;
     354                 : 
     355                 :     // 27.4.2.1.4  Type ios_base::openmode
     356                 :     /**
     357                 :      *  @brief This is a bitmask type.
     358                 :      *
     359                 :      *  @c @a _Ios_Openmode is implementation-defined, but it is valid to
     360                 :      *  perform bitwise operations on these values and expect the Right
     361                 :      *  Thing to happen.  Defined objects of type openmode are:
     362                 :      *  - app
     363                 :      *  - ate
     364                 :      *  - binary
     365                 :      *  - in
     366                 :      *  - out
     367                 :      *  - trunc
     368                 :     */
     369                 :     typedef _Ios_Openmode openmode;
     370                 : 
     371                 :     /// Seek to end before each write.
     372                 :     static const openmode app =         _S_app;
     373                 : 
     374                 :     /// Open and seek to end immediately after opening.
     375                 :     static const openmode ate =         _S_ate;
     376                 : 
     377                 :     /// Perform input and output in binary mode (as opposed to text mode).
     378                 :     /// This is probably not what you think it is; see
     379                 :     /// http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt11ch27s02.html
     380                 :     static const openmode binary =      _S_bin;
     381                 : 
     382                 :     /// Open for input.  Default for @c ifstream and fstream.
     383                 :     static const openmode in =          _S_in;
     384                 : 
     385                 :     /// Open for output.  Default for @c ofstream and fstream.
     386                 :     static const openmode out =         _S_out;
     387                 : 
     388                 :     /// Open for input.  Default for @c ofstream.
     389                 :     static const openmode trunc =       _S_trunc;
     390                 : 
     391                 :     // 27.4.2.1.5  Type ios_base::seekdir
     392                 :     /**
     393                 :      *  @brief This is an enumerated type.
     394                 :      *
     395                 :      *  @c @a _Ios_Seekdir is implementation-defined.  Defined values
     396                 :      *  of type seekdir are:
     397                 :      *  - beg
     398                 :      *  - cur, equivalent to @c SEEK_CUR in the C standard library.
     399                 :      *  - end, equivalent to @c SEEK_END in the C standard library.
     400                 :     */
     401                 :     typedef _Ios_Seekdir seekdir;
     402                 : 
     403                 :     /// Request a seek relative to the beginning of the stream.
     404                 :     static const seekdir beg =          _S_beg;
     405                 : 
     406                 :     /// Request a seek relative to the current position within the sequence.
     407                 :     static const seekdir cur =          _S_cur;
     408                 : 
     409                 :     /// Request a seek relative to the current end of the sequence.
     410                 :     static const seekdir end =          _S_end;
     411                 : 
     412                 :     // Annex D.6
     413                 :     typedef int io_state;
     414                 :     typedef int open_mode;
     415                 :     typedef int seek_dir;
     416                 : 
     417                 :     typedef std::streampos streampos;
     418                 :     typedef std::streamoff streamoff;
     419                 : 
     420                 :     // Callbacks;
     421                 :     /**
     422                 :      *  @brief  The set of events that may be passed to an event callback.
     423                 :      *
     424                 :      *  erase_event is used during ~ios() and copyfmt().  imbue_event is used
     425                 :      *  during imbue().  copyfmt_event is used during copyfmt().
     426                 :     */
     427                 :     enum event
     428                 :     {
     429                 :       erase_event,
     430                 :       imbue_event,
     431                 :       copyfmt_event
     432                 :     };
     433                 : 
     434                 :     /**
     435                 :      *  @brief  The type of an event callback function.
     436                 :      *  @param  event  One of the members of the event enum.
     437                 :      *  @param  ios_base  Reference to the ios_base object.
     438                 :      *  @param  int  The integer provided when the callback was registered.
     439                 :      *
     440                 :      *  Event callbacks are user defined functions that get called during
     441                 :      *  several ios_base and basic_ios functions, specifically imbue(),
     442                 :      *  copyfmt(), and ~ios().
     443                 :     */
     444                 :     typedef void (*event_callback) (event, ios_base&, int);
     445                 : 
     446                 :     /**
     447                 :      *  @brief  Add the callback __fn with parameter __index.
     448                 :      *  @param  __fn  The function to add.
     449                 :      *  @param  __index  The integer to pass to the function when invoked.
     450                 :      *
     451                 :      *  Registers a function as an event callback with an integer parameter to
     452                 :      *  be passed to the function when invoked.  Multiple copies of the
     453                 :      *  function are allowed.  If there are multiple callbacks, they are
     454                 :      *  invoked in the order they were registered.
     455                 :     */
     456                 :     void
     457                 :     register_callback(event_callback __fn, int __index);
     458                 : 
     459                 :   protected:
     460                 :     streamsize          _M_precision;
     461                 :     streamsize          _M_width;
     462                 :     fmtflags            _M_flags;
     463                 :     iostate             _M_exception;
     464                 :     iostate             _M_streambuf_state;
     465                 : 
     466                 :     // 27.4.2.6  Members for callbacks
     467                 :     // 27.4.2.6  ios_base callbacks
     468                 :     struct _Callback_list
     469                 :     {
     470                 :       // Data Members
     471                 :       _Callback_list*           _M_next;
     472                 :       ios_base::event_callback  _M_fn;
     473                 :       int                       _M_index;
     474                 :       _Atomic_word              _M_refcount;  // 0 means one reference.
     475                 : 
     476                 :       _Callback_list(ios_base::event_callback __fn, int __index,
     477                 :                      _Callback_list* __cb)
     478                 :       : _M_next(__cb), _M_fn(__fn), _M_index(__index), _M_refcount(0) { }
     479                 : 
     480                 :       void
     481                 :       _M_add_reference() { __gnu_cxx::__atomic_add_dispatch(&_M_refcount, 1); }
     482                 : 
     483                 :       // 0 => OK to delete.
     484                 :       int
     485                 :       _M_remove_reference() 
     486                 :       { return __gnu_cxx::__exchange_and_add_dispatch(&_M_refcount, -1); }
     487                 :     };
     488                 : 
     489                 :      _Callback_list*    _M_callbacks;
     490                 : 
     491                 :     void
     492                 :     _M_call_callbacks(event __ev) throw();
     493                 : 
     494                 :     void
     495                 :     _M_dispose_callbacks(void) throw();
     496                 : 
     497                 :     // 27.4.2.5  Members for iword/pword storage
     498                 :     struct _Words
     499                 :     {
     500                 :       void*     _M_pword;
     501                 :       long      _M_iword;
     502                 :       _Words() : _M_pword(0), _M_iword(0) { }
     503                 :     };
     504                 : 
     505                 :     // Only for failed iword/pword calls.
     506                 :     _Words              _M_word_zero;
     507                 : 
     508                 :     // Guaranteed storage.
     509                 :     // The first 5 iword and pword slots are reserved for internal use.
     510                 :     enum { _S_local_word_size = 8 };
     511                 :     _Words              _M_local_word[_S_local_word_size];
     512                 : 
     513                 :     // Allocated storage.
     514                 :     int                 _M_word_size;
     515                 :     _Words*             _M_word;
     516                 : 
     517                 :     _Words&
     518                 :     _M_grow_words(int __index, bool __iword);
     519                 : 
     520                 :     // Members for locale and locale caching.
     521                 :     locale              _M_ios_locale;
     522                 : 
     523                 :     void
     524                 :     _M_init() throw();
     525                 : 
     526                 :   public:
     527                 : 
     528                 :     // 27.4.2.1.6  Class ios_base::Init
     529                 :     // Used to initialize standard streams. In theory, g++ could use
     530                 :     // -finit-priority to order this stuff correctly without going
     531                 :     // through these machinations.
     532                 :     class Init
     533                 :     {
     534                 :       friend class ios_base;
     535                 :     public:
     536                 :       Init();
     537                 :       ~Init();
     538                 : 
     539                 :     private:
     540                 :       static _Atomic_word       _S_refcount;
     541                 :       static bool               _S_synced_with_stdio;
     542                 :     };
     543                 : 
     544                 :     // [27.4.2.2] fmtflags state functions
     545                 :     /**
     546                 :      *  @brief  Access to format flags.
     547                 :      *  @return  The format control flags for both input and output.
     548                 :     */
     549                 :     fmtflags
     550               0 :     flags() const
     551               0 :     { return _M_flags; }
     552                 : 
     553                 :     /**
     554                 :      *  @brief  Setting new format flags all at once.
     555                 :      *  @param  fmtfl  The new flags to set.
     556                 :      *  @return  The previous format control flags.
     557                 :      *
     558                 :      *  This function overwrites all the format flags with @a fmtfl.
     559                 :     */
     560                 :     fmtflags
     561                 :     flags(fmtflags __fmtfl)
     562                 :     {
     563                 :       fmtflags __old = _M_flags;
     564                 :       _M_flags = __fmtfl;
     565                 :       return __old;
     566                 :     }
     567                 : 
     568                 :     /**
     569                 :      *  @brief  Setting new format flags.
     570                 :      *  @param  fmtfl  Additional flags to set.
     571                 :      *  @return  The previous format control flags.
     572                 :      *
     573                 :      *  This function sets additional flags in format control.  Flags that
     574                 :      *  were previously set remain set.
     575                 :     */
     576                 :     fmtflags
     577               0 :     setf(fmtflags __fmtfl)
     578                 :     {
     579               0 :       fmtflags __old = _M_flags;
     580               0 :       _M_flags |= __fmtfl;
     581               0 :       return __old;
     582                 :     }
     583                 : 
     584                 :     /**
     585                 :      *  @brief  Setting new format flags.
     586                 :      *  @param  fmtfl  Additional flags to set.
     587                 :      *  @param  mask  The flags mask for @a fmtfl.
     588                 :      *  @return  The previous format control flags.
     589                 :      *
     590                 :      *  This function clears @a mask in the format flags, then sets
     591                 :      *  @a fmtfl @c & @a mask.  An example mask is @c ios_base::adjustfield.
     592                 :     */
     593                 :     fmtflags
     594               0 :     setf(fmtflags __fmtfl, fmtflags __mask)
     595                 :     {
     596               0 :       fmtflags __old = _M_flags;
     597               0 :       _M_flags &= ~__mask;
     598               0 :       _M_flags |= (__fmtfl & __mask);
     599               0 :       return __old;
     600                 :     }
     601                 : 
     602                 :     /**
     603                 :      *  @brief  Clearing format flags.
     604                 :      *  @param  mask  The flags to unset.
     605                 :      *
     606                 :      *  This function clears @a mask in the format flags.
     607                 :     */
     608                 :     void
     609               0 :     unsetf(fmtflags __mask)
     610               0 :     { _M_flags &= ~__mask; }
     611                 : 
     612                 :     /**
     613                 :      *  @brief  Flags access.
     614                 :      *  @return  The precision to generate on certain output operations.
     615                 :      *
     616                 :      *  Be careful if you try to give a definition of @a precision here; see
     617                 :      *  DR 189.
     618                 :     */
     619                 :     streamsize
     620                 :     precision() const
     621                 :     { return _M_precision; }
     622                 : 
     623                 :     /**
     624                 :      *  @brief  Changing flags.
     625                 :      *  @param  prec  The new precision value.
     626                 :      *  @return  The previous value of precision().
     627                 :     */
     628                 :     streamsize
     629               0 :     precision(streamsize __prec)
     630                 :     {
     631               0 :       streamsize __old = _M_precision;
     632               0 :       _M_precision = __prec;
     633               0 :       return __old;
     634                 :     }
     635                 : 
     636                 :     /**
     637                 :      *  @brief  Flags access.
     638                 :      *  @return  The minimum field width to generate on output operations.
     639                 :      *
     640                 :      *  <em>Minimum field width</em> refers to the number of characters.
     641                 :     */
     642                 :     streamsize
     643               0 :     width() const
     644               0 :     { return _M_width; }
     645                 : 
     646                 :     /**
     647                 :      *  @brief  Changing flags.
     648                 :      *  @param  wide  The new width value.
     649                 :      *  @return  The previous value of width().
     650                 :     */
     651                 :     streamsize
     652               0 :     width(streamsize __wide)
     653                 :     {
     654               0 :       streamsize __old = _M_width;
     655               0 :       _M_width = __wide;
     656               0 :       return __old;
     657                 :     }
     658                 : 
     659                 :     // [27.4.2.4] ios_base static members
     660                 :     /**
     661                 :      *  @brief  Interaction with the standard C I/O objects.
     662                 :      *  @param  sync  Whether to synchronize or not.
     663                 :      *  @return  True if the standard streams were previously synchronized.
     664                 :      *
     665                 :      *  The synchronization referred to is @e only that between the standard
     666                 :      *  C facilities (e.g., stdout) and the standard C++ objects (e.g.,
     667                 :      *  cout).  User-declared streams are unaffected.  See
     668                 :      *  http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt11ch28s02.html
     669                 :     */
     670                 :     static bool
     671                 :     sync_with_stdio(bool __sync = true);
     672                 : 
     673                 :     // [27.4.2.3] ios_base locale functions
     674                 :     /**
     675                 :      *  @brief  Setting a new locale.
     676                 :      *  @param  loc  The new locale.
     677                 :      *  @return  The previous locale.
     678                 :      *
     679                 :      *  Sets the new locale for this stream, and then invokes each callback
     680                 :      *  with imbue_event.
     681                 :     */
     682                 :     locale
     683                 :     imbue(const locale& __loc) throw();
     684                 : 
     685                 :     /**
     686                 :      *  @brief  Locale access
     687                 :      *  @return  A copy of the current locale.
     688                 :      *
     689                 :      *  If @c imbue(loc) has previously been called, then this function
     690                 :      *  returns @c loc.  Otherwise, it returns a copy of @c std::locale(),
     691                 :      *  the global C++ locale.
     692                 :     */
     693                 :     locale
     694                 :     getloc() const
     695                 :     { return _M_ios_locale; }
     696                 : 
     697                 :     /**
     698                 :      *  @brief  Locale access
     699                 :      *  @return  A reference to the current locale.
     700                 :      *
     701                 :      *  Like getloc above, but returns a reference instead of
     702                 :      *  generating a copy.
     703                 :     */
     704                 :     const locale&
     705                 :     _M_getloc() const
     706                 :     { return _M_ios_locale; }
     707                 : 
     708                 :     // [27.4.2.5] ios_base storage functions
     709                 :     /**
     710                 :      *  @brief  Access to unique indices.
     711                 :      *  @return  An integer different from all previous calls.
     712                 :      *
     713                 :      *  This function returns a unique integer every time it is called.  It
     714                 :      *  can be used for any purpose, but is primarily intended to be a unique
     715                 :      *  index for the iword and pword functions.  The expectation is that an
     716                 :      *  application calls xalloc in order to obtain an index in the iword and
     717                 :      *  pword arrays that can be used without fear of conflict.
     718                 :      *
     719                 :      *  The implementation maintains a static variable that is incremented and
     720                 :      *  returned on each invocation.  xalloc is guaranteed to return an index
     721                 :      *  that is safe to use in the iword and pword arrays.
     722                 :     */
     723                 :     static int
     724                 :     xalloc() throw();
     725                 : 
     726                 :     /**
     727                 :      *  @brief  Access to integer array.
     728                 :      *  @param  __ix  Index into the array.
     729                 :      *  @return  A reference to an integer associated with the index.
     730                 :      *
     731                 :      *  The iword function provides access to an array of integers that can be
     732                 :      *  used for any purpose.  The array grows as required to hold the
     733                 :      *  supplied index.  All integers in the array are initialized to 0.
     734                 :      *
     735                 :      *  The implementation reserves several indices.  You should use xalloc to
     736                 :      *  obtain an index that is safe to use.  Also note that since the array
     737                 :      *  can grow dynamically, it is not safe to hold onto the reference.
     738                 :     */
     739                 :     long&
     740                 :     iword(int __ix)
     741                 :     {
     742                 :       _Words& __word = (__ix < _M_word_size)
     743                 :                         ? _M_word[__ix] : _M_grow_words(__ix, true);
     744                 :       return __word._M_iword;
     745                 :     }
     746                 : 
     747                 :     /**
     748                 :      *  @brief  Access to void pointer array.
     749                 :      *  @param  __ix  Index into the array.
     750                 :      *  @return  A reference to a void* associated with the index.
     751                 :      *
     752                 :      *  The pword function provides access to an array of pointers that can be
     753                 :      *  used for any purpose.  The array grows as required to hold the
     754                 :      *  supplied index.  All pointers in the array are initialized to 0.
     755                 :      *
     756                 :      *  The implementation reserves several indices.  You should use xalloc to
     757                 :      *  obtain an index that is safe to use.  Also note that since the array
     758                 :      *  can grow dynamically, it is not safe to hold onto the reference.
     759                 :     */
     760                 :     void*&
     761                 :     pword(int __ix)
     762                 :     {
     763                 :       _Words& __word = (__ix < _M_word_size)
     764                 :                         ? _M_word[__ix] : _M_grow_words(__ix, false);
     765                 :       return __word._M_pword;
     766                 :     }
     767                 : 
     768                 :     // Destructor
     769                 :     /**
     770                 :      *  Invokes each callback with erase_event.  Destroys local storage.
     771                 :      *
     772                 :      *  Note that the ios_base object for the standard streams never gets
     773                 :      *  destroyed.  As a result, any callbacks registered with the standard
     774                 :      *  streams will not get invoked with erase_event (unless copyfmt is
     775                 :      *  used).
     776                 :     */
     777                 :     virtual ~ios_base();
     778                 : 
     779                 :   protected:
     780                 :     ios_base() throw ();
     781                 : 
     782                 :   // _GLIBCXX_RESOLVE_LIB_DEFECTS
     783                 :   // 50.  Copy constructor and assignment operator of ios_base
     784                 :   private:
     785                 :     ios_base(const ios_base&);
     786                 : 
     787                 :     ios_base&
     788                 :     operator=(const ios_base&);
     789                 :   };
     790                 : 
     791                 :   // [27.4.5.1] fmtflags manipulators
     792                 :   /// Calls base.setf(ios_base::boolalpha).
     793                 :   inline ios_base&
     794                 :   boolalpha(ios_base& __base)
     795                 :   {
     796                 :     __base.setf(ios_base::boolalpha);
     797                 :     return __base;
     798                 :   }
     799                 : 
     800                 :   /// Calls base.unsetf(ios_base::boolalpha).
     801                 :   inline ios_base&
     802                 :   noboolalpha(ios_base& __base)
     803                 :   {
     804                 :     __base.unsetf(ios_base::boolalpha);
     805                 :     return __base;
     806                 :   }
     807                 : 
     808                 :   /// Calls base.setf(ios_base::showbase).
     809                 :   inline ios_base&
     810                 :   showbase(ios_base& __base)
     811                 :   {
     812                 :     __base.setf(ios_base::showbase);
     813                 :     return __base;
     814                 :   }
     815                 : 
     816                 :   /// Calls base.unsetf(ios_base::showbase).
     817                 :   inline ios_base&
     818                 :   noshowbase(ios_base& __base)
     819                 :   {
     820                 :     __base.unsetf(ios_base::showbase);
     821                 :     return __base;
     822                 :   }
     823                 : 
     824                 :   /// Calls base.setf(ios_base::showpoint).
     825                 :   inline ios_base&
     826               0 :   showpoint(ios_base& __base)
     827                 :   {
     828               0 :     __base.setf(ios_base::showpoint);
     829               0 :     return __base;
     830                 :   }
     831                 : 
     832                 :   /// Calls base.unsetf(ios_base::showpoint).
     833                 :   inline ios_base&
     834                 :   noshowpoint(ios_base& __base)
     835                 :   {
     836                 :     __base.unsetf(ios_base::showpoint);
     837                 :     return __base;
     838                 :   }
     839                 : 
     840                 :   /// Calls base.setf(ios_base::showpos).
     841                 :   inline ios_base&
     842                 :   showpos(ios_base& __base)
     843                 :   {
     844                 :     __base.setf(ios_base::showpos);
     845                 :     return __base;
     846                 :   }
     847                 : 
     848                 :   /// Calls base.unsetf(ios_base::showpos).
     849                 :   inline ios_base&
     850                 :   noshowpos(ios_base& __base)
     851                 :   {
     852                 :     __base.unsetf(ios_base::showpos);
     853                 :     return __base;
     854                 :   }
     855                 : 
     856                 :   /// Calls base.setf(ios_base::skipws).
     857                 :   inline ios_base&
     858                 :   skipws(ios_base& __base)
     859                 :   {
     860                 :     __base.setf(ios_base::skipws);
     861                 :     return __base;
     862                 :   }
     863                 : 
     864                 :   /// Calls base.unsetf(ios_base::skipws).
     865                 :   inline ios_base&
     866                 :   noskipws(ios_base& __base)
     867                 :   {
     868                 :     __base.unsetf(ios_base::skipws);
     869                 :     return __base;
     870                 :   }
     871                 : 
     872                 :   /// Calls base.setf(ios_base::uppercase).
     873                 :   inline ios_base&
     874                 :   uppercase(ios_base& __base)
     875                 :   {
     876                 :     __base.setf(ios_base::uppercase);
     877                 :     return __base;
     878                 :   }
     879                 : 
     880                 :   /// Calls base.unsetf(ios_base::uppercase).
     881                 :   inline ios_base&
     882                 :   nouppercase(ios_base& __base)
     883                 :   {
     884                 :     __base.unsetf(ios_base::uppercase);
     885                 :     return __base;
     886                 :   }
     887                 : 
     888                 :   /// Calls base.setf(ios_base::unitbuf).
     889                 :   inline ios_base&
     890                 :   unitbuf(ios_base& __base)
     891                 :   {
     892                 :      __base.setf(ios_base::unitbuf);
     893                 :      return __base;
     894                 :   }
     895                 : 
     896                 :   /// Calls base.unsetf(ios_base::unitbuf).
     897                 :   inline ios_base&
     898                 :   nounitbuf(ios_base& __base)
     899                 :   {
     900                 :      __base.unsetf(ios_base::unitbuf);
     901                 :      return __base;
     902                 :   }
     903                 : 
     904                 :   // [27.4.5.2] adjustfield manipulators
     905                 :   /// Calls base.setf(ios_base::internal, ios_base::adjustfield).
     906                 :   inline ios_base&
     907                 :   internal(ios_base& __base)
     908                 :   {
     909                 :      __base.setf(ios_base::internal, ios_base::adjustfield);
     910                 :      return __base;
     911                 :   }
     912                 : 
     913                 :   /// Calls base.setf(ios_base::left, ios_base::adjustfield).
     914                 :   inline ios_base&
     915                 :   left(ios_base& __base)
     916                 :   {
     917                 :     __base.setf(ios_base::left, ios_base::adjustfield);
     918                 :     return __base;
     919                 :   }
     920                 : 
     921                 :   /// Calls base.setf(ios_base::right, ios_base::adjustfield).
     922                 :   inline ios_base&
     923                 :   right(ios_base& __base)
     924                 :   {
     925                 :     __base.setf(ios_base::right, ios_base::adjustfield);
     926                 :     return __base;
     927                 :   }
     928                 : 
     929                 :   // [27.4.5.3] basefield manipulators
     930                 :   /// Calls base.setf(ios_base::dec, ios_base::basefield).
     931                 :   inline ios_base&
     932                 :   dec(ios_base& __base)
     933                 :   {
     934                 :     __base.setf(ios_base::dec, ios_base::basefield);
     935                 :     return __base;
     936                 :   }
     937                 : 
     938                 :   /// Calls base.setf(ios_base::hex, ios_base::basefield).
     939                 :   inline ios_base&
     940               0 :   hex(ios_base& __base)
     941                 :   {
     942               0 :     __base.setf(ios_base::hex, ios_base::basefield);
     943               0 :     return __base;
     944                 :   }
     945                 : 
     946                 :   /// Calls base.setf(ios_base::oct, ios_base::basefield).
     947                 :   inline ios_base&
     948                 :   oct(ios_base& __base)
     949                 :   {
     950                 :     __base.setf(ios_base::oct, ios_base::basefield);
     951                 :     return __base;
     952                 :   }
     953                 : 
     954                 :   // [27.4.5.4] floatfield manipulators
     955                 :   /// Calls base.setf(ios_base::fixed, ios_base::floatfield).
     956                 :   inline ios_base&
     957               0 :   fixed(ios_base& __base)
     958                 :   {
     959               0 :     __base.setf(ios_base::fixed, ios_base::floatfield);
     960               0 :     return __base;
     961                 :   }
     962                 : 
     963                 :   /// Calls base.setf(ios_base::scientific, ios_base::floatfield).
     964                 :   inline ios_base&
     965                 :   scientific(ios_base& __base)
     966                 :   {
     967                 :     __base.setf(ios_base::scientific, ios_base::floatfield);
     968                 :     return __base;
     969                 :   }
     970                 : 
     971                 : _GLIBCXX_END_NAMESPACE
     972                 : 
     973                 : #undef _IOS_BASE_SEEK_CUR
     974                 : #undef _IOS_BASE_SEEK_END
     975                 : 
     976                 : #endif /* _IOS_BASE_H */
     977                 : 

Generated by: LCOV version 1.7