LTP GCOV extension - code coverage report
Current view: directory - usr/local/include/c++/4.0.2/bits - ios_base.h
Test: YAORB-0.2.info
Date: 2006-02-27 Instrumented lines: 1
Code covered: 100.0 % Executed lines: 1

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

Generated by: LTP GCOV extension version 1.4