LCOV - lcov.info - /usr/include/c++/4.3/bits/ios_base.h

LTP GCOV extension - code coverage report
Current view: | directory - usr/include/c++/4.3/bits - ios_base.h
Test: | lcov.info
Date: | 2008-08-14 |  | Instrumented lines: | 30
Code covered: | 66.7 % |  | Executed lines: | 20

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

Generated by: LTP GCOV extension version 1.6