LCOV - code coverage report
Current view: top level - usr/include/c++/4.9/bits - ios_base.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 8 0.0 %
Date: 2016-09-12 13:07:23 Functions: 0 4 0.0 %

          Line data    Source code
       1             : // Iostreams base classes -*- C++ -*-
       2             : 
       3             : // Copyright (C) 1997-2014 Free Software Foundation, Inc.
       4             : //
       5             : // This file is part of the GNU ISO C++ Library.  This library is free
       6             : // software; you can redistribute it and/or modify it under the
       7             : // terms of the GNU General Public License as published by the
       8             : // Free Software Foundation; either version 3, or (at your option)
       9             : // any later version.
      10             : 
      11             : // This library is distributed in the hope that it will be useful,
      12             : // but WITHOUT ANY WARRANTY; without even the implied warranty of
      13             : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14             : // GNU General Public License for more details.
      15             : 
      16             : // Under Section 7 of GPL version 3, you are granted additional
      17             : // permissions described in the GCC Runtime Library Exception, version
      18             : // 3.1, as published by the Free Software Foundation.
      19             : 
      20             : // You should have received a copy of the GNU General Public License and
      21             : // a copy of the GCC Runtime Library Exception along with this program;
      22             : // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
      23             : // <http://www.gnu.org/licenses/>.
      24             : 
      25             : /** @file bits/ios_base.h
      26             :  *  This is an internal header file, included by other library headers.
      27             :  *  Do not attempt to use it directly. @headername{ios}
      28             :  */
      29             : 
      30             : //
      31             : // ISO C++ 14882: 27.4  Iostreams base classes
      32             : //
      33             : 
      34             : #ifndef _IOS_BASE_H
      35             : #define _IOS_BASE_H 1
      36             : 
      37             : #pragma GCC system_header
      38             : 
      39             : #include <ext/atomicity.h>
      40             : #include <bits/localefwd.h>
      41             : #include <bits/locale_classes.h>
      42             : 
      43             : namespace std _GLIBCXX_VISIBILITY(default)
      44             : {
      45             : _GLIBCXX_BEGIN_NAMESPACE_VERSION
      46             : 
      47             :   // The following definitions of bitmask types are enums, not ints,
      48             :   // as permitted (but not required) in the standard, in order to provide
      49             :   // better type safety in iostream calls.  A side effect is that
      50             :   // expressions involving them are no longer compile-time constants.
      51             :   enum _Ios_Fmtflags 
      52             :     { 
      53             :       _S_boolalpha      = 1L << 0,
      54             :       _S_dec            = 1L << 1,
      55             :       _S_fixed          = 1L << 2,
      56             :       _S_hex            = 1L << 3,
      57             :       _S_internal       = 1L << 4,
      58             :       _S_left           = 1L << 5,
      59             :       _S_oct            = 1L << 6,
      60             :       _S_right          = 1L << 7,
      61             :       _S_scientific     = 1L << 8,
      62             :       _S_showbase       = 1L << 9,
      63             :       _S_showpoint      = 1L << 10,
      64             :       _S_showpos        = 1L << 11,
      65             :       _S_skipws         = 1L << 12,
      66             :       _S_unitbuf        = 1L << 13,
      67             :       _S_uppercase      = 1L << 14,
      68             :       _S_adjustfield    = _S_left | _S_right | _S_internal,
      69             :       _S_basefield      = _S_dec | _S_oct | _S_hex,
      70             :       _S_floatfield     = _S_scientific | _S_fixed,
      71             :       _S_ios_fmtflags_end = 1L << 16 
      72             :     };
      73             : 
      74             :   inline _GLIBCXX_CONSTEXPR _Ios_Fmtflags
      75             :   operator&(_Ios_Fmtflags __a, _Ios_Fmtflags __b)
      76             :   { return _Ios_Fmtflags(static_cast<int>(__a) & static_cast<int>(__b)); }
      77             : 
      78             :   inline _GLIBCXX_CONSTEXPR _Ios_Fmtflags
      79             :   operator|(_Ios_Fmtflags __a, _Ios_Fmtflags __b)
      80             :   { return _Ios_Fmtflags(static_cast<int>(__a) | static_cast<int>(__b)); }
      81             : 
      82             :   inline _GLIBCXX_CONSTEXPR _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 _GLIBCXX_CONSTEXPR _Ios_Fmtflags
      87             :   operator~(_Ios_Fmtflags __a)
      88             :   { return _Ios_Fmtflags(~static_cast<int>(__a)); }
      89             : 
      90             :   inline const _Ios_Fmtflags&
      91             :   operator|=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b)
      92             :   { return __a = __a | __b; }
      93             : 
      94             :   inline const _Ios_Fmtflags&
      95             :   operator&=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b)
      96             :   { return __a = __a & __b; }
      97             : 
      98             :   inline const _Ios_Fmtflags&
      99             :   operator^=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b)
     100             :   { return __a = __a ^ __b; }
     101             : 
     102             : 
     103             :   enum _Ios_Openmode 
     104             :     { 
     105             :       _S_app            = 1L << 0,
     106             :       _S_ate            = 1L << 1,
     107             :       _S_bin            = 1L << 2,
     108             :       _S_in             = 1L << 3,
     109             :       _S_out            = 1L << 4,
     110             :       _S_trunc          = 1L << 5,
     111             :       _S_ios_openmode_end = 1L << 16 
     112             :     };
     113             : 
     114             :   inline _GLIBCXX_CONSTEXPR _Ios_Openmode
     115           0 :   operator&(_Ios_Openmode __a, _Ios_Openmode __b)
     116           0 :   { return _Ios_Openmode(static_cast<int>(__a) & static_cast<int>(__b)); }
     117             : 
     118             :   inline _GLIBCXX_CONSTEXPR _Ios_Openmode
     119           0 :   operator|(_Ios_Openmode __a, _Ios_Openmode __b)
     120           0 :   { return _Ios_Openmode(static_cast<int>(__a) | static_cast<int>(__b)); }
     121             : 
     122             :   inline _GLIBCXX_CONSTEXPR _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 _GLIBCXX_CONSTEXPR _Ios_Openmode
     127             :   operator~(_Ios_Openmode __a)
     128             :   { return _Ios_Openmode(~static_cast<int>(__a)); }
     129             : 
     130             :   inline const _Ios_Openmode&
     131             :   operator|=(_Ios_Openmode& __a, _Ios_Openmode __b)
     132             :   { return __a = __a | __b; }
     133             : 
     134             :   inline const _Ios_Openmode&
     135             :   operator&=(_Ios_Openmode& __a, _Ios_Openmode __b)
     136             :   { return __a = __a & __b; }
     137             : 
     138             :   inline const _Ios_Openmode&
     139             :   operator^=(_Ios_Openmode& __a, _Ios_Openmode __b)
     140             :   { return __a = __a ^ __b; }
     141             : 
     142             : 
     143             :   enum _Ios_Iostate
     144             :     { 
     145             :       _S_goodbit                = 0,
     146             :       _S_badbit                 = 1L << 0,
     147             :       _S_eofbit                 = 1L << 1,
     148             :       _S_failbit                = 1L << 2,
     149             :       _S_ios_iostate_end = 1L << 16 
     150             :     };
     151             : 
     152             :   inline _GLIBCXX_CONSTEXPR _Ios_Iostate
     153           0 :   operator&(_Ios_Iostate __a, _Ios_Iostate __b)
     154           0 :   { return _Ios_Iostate(static_cast<int>(__a) & static_cast<int>(__b)); }
     155             : 
     156             :   inline _GLIBCXX_CONSTEXPR _Ios_Iostate
     157           0 :   operator|(_Ios_Iostate __a, _Ios_Iostate __b)
     158           0 :   { return _Ios_Iostate(static_cast<int>(__a) | static_cast<int>(__b)); }
     159             : 
     160             :   inline _GLIBCXX_CONSTEXPR _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 _GLIBCXX_CONSTEXPR _Ios_Iostate
     165             :   operator~(_Ios_Iostate __a)
     166             :   { return _Ios_Iostate(~static_cast<int>(__a)); }
     167             : 
     168             :   inline const _Ios_Iostate&
     169             :   operator|=(_Ios_Iostate& __a, _Ios_Iostate __b)
     170             :   { return __a = __a | __b; }
     171             : 
     172             :   inline const _Ios_Iostate&
     173             :   operator&=(_Ios_Iostate& __a, _Ios_Iostate __b)
     174             :   { return __a = __a & __b; }
     175             : 
     176             :   inline const  _Ios_Iostate&
     177             :   operator^=(_Ios_Iostate& __a, _Ios_Iostate __b)
     178             :   { return __a = __a ^ __b; }
     179             : 
     180             : 
     181             :   enum _Ios_Seekdir 
     182             :     { 
     183             :       _S_beg = 0,
     184             :       _S_cur = _GLIBCXX_STDIO_SEEK_CUR,
     185             :       _S_end = _GLIBCXX_STDIO_SEEK_END,
     186             :       _S_ios_seekdir_end = 1L << 16 
     187             :     };
     188             : 
     189             :   // 27.4.2  Class ios_base
     190             :   /**
     191             :    *  @brief  The base of the I/O class hierarchy.
     192             :    *  @ingroup io
     193             :    *
     194             :    *  This class defines everything that can be defined about I/O that does
     195             :    *  not depend on the type of characters being input or output.  Most
     196             :    *  people will only see @c ios_base when they need to specify the full
     197             :    *  name of the various I/O flags (e.g., the openmodes).
     198             :   */
     199             :   class ios_base
     200             :   {
     201             :   public:
     202             : 
     203             :     /** 
     204             :      *  @brief These are thrown to indicate problems with io.
     205             :      *  @ingroup exceptions
     206             :      *
     207             :      *  27.4.2.1.1  Class ios_base::failure
     208             :      */
     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-4.3.2/gcc/Vague-Linkage.html
     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 @a _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 @a _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 @a _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++/manual/bk01pt11ch27s02.html
     372             :     static const openmode binary =      _S_bin;
     373             : 
     374             :     /// Open for input.  Default for @c ifstream and fstream.
     375             :     static const openmode in =          _S_in;
     376             : 
     377             :     /// Open for output.  Default for @c ofstream and fstream.
     378             :     static const openmode out =         _S_out;
     379             : 
     380             :     /// Open for input.  Default for @c ofstream.
     381             :     static const openmode trunc =       _S_trunc;
     382             : 
     383             :     // 27.4.2.1.5  Type ios_base::seekdir
     384             :     /**
     385             :      *  @brief This is an enumerated type.
     386             :      *
     387             :      *  @c @a _Ios_Seekdir is implementation-defined.  Defined values
     388             :      *  of type seekdir are:
     389             :      *  - beg
     390             :      *  - cur, equivalent to @c SEEK_CUR in the C standard library.
     391             :      *  - end, equivalent to @c SEEK_END in the C standard library.
     392             :     */
     393             :     typedef _Ios_Seekdir seekdir;
     394             : 
     395             :     /// Request a seek relative to the beginning of the stream.
     396             :     static const seekdir beg =          _S_beg;
     397             : 
     398             :     /// Request a seek relative to the current position within the sequence.
     399             :     static const seekdir cur =          _S_cur;
     400             : 
     401             :     /// Request a seek relative to the current end of the sequence.
     402             :     static const seekdir end =          _S_end;
     403             : 
     404             :     // Annex D.6
     405             :     typedef int io_state;
     406             :     typedef int open_mode;
     407             :     typedef int seek_dir;
     408             : 
     409             :     typedef std::streampos streampos;
     410             :     typedef std::streamoff streamoff;
     411             : 
     412             :     // Callbacks;
     413             :     /**
     414             :      *  @brief  The set of events that may be passed to an event callback.
     415             :      *
     416             :      *  erase_event is used during ~ios() and copyfmt().  imbue_event is used
     417             :      *  during imbue().  copyfmt_event is used during copyfmt().
     418             :     */
     419             :     enum event
     420             :     {
     421             :       erase_event,
     422             :       imbue_event,
     423             :       copyfmt_event
     424             :     };
     425             : 
     426             :     /**
     427             :      *  @brief  The type of an event callback function.
     428             :      *  @param  __e  One of the members of the event enum.
     429             :      *  @param  __b  Reference to the ios_base object.
     430             :      *  @param  __i  The integer provided when the callback was registered.
     431             :      *
     432             :      *  Event callbacks are user defined functions that get called during
     433             :      *  several ios_base and basic_ios functions, specifically imbue(),
     434             :      *  copyfmt(), and ~ios().
     435             :     */
     436             :     typedef void (*event_callback) (event __e, ios_base& __b, int __i);
     437             : 
     438             :     /**
     439             :      *  @brief  Add the callback __fn with parameter __index.
     440             :      *  @param  __fn  The function to add.
     441             :      *  @param  __index  The integer to pass to the function when invoked.
     442             :      *
     443             :      *  Registers a function as an event callback with an integer parameter to
     444             :      *  be passed to the function when invoked.  Multiple copies of the
     445             :      *  function are allowed.  If there are multiple callbacks, they are
     446             :      *  invoked in the order they were registered.
     447             :     */
     448             :     void
     449             :     register_callback(event_callback __fn, int __index);
     450             : 
     451             :   protected:
     452             :     streamsize          _M_precision;
     453             :     streamsize          _M_width;
     454             :     fmtflags            _M_flags;
     455             :     iostate             _M_exception;
     456             :     iostate             _M_streambuf_state;
     457             : 
     458             :     // 27.4.2.6  Members for callbacks
     459             :     // 27.4.2.6  ios_base callbacks
     460             :     struct _Callback_list
     461             :     {
     462             :       // Data Members
     463             :       _Callback_list*           _M_next;
     464             :       ios_base::event_callback  _M_fn;
     465             :       int                       _M_index;
     466             :       _Atomic_word              _M_refcount;  // 0 means one reference.
     467             : 
     468             :       _Callback_list(ios_base::event_callback __fn, int __index,
     469             :                      _Callback_list* __cb)
     470             :       : _M_next(__cb), _M_fn(__fn), _M_index(__index), _M_refcount(0) { }
     471             : 
     472             :       void
     473             :       _M_add_reference() { __gnu_cxx::__atomic_add_dispatch(&_M_refcount, 1); }
     474             : 
     475             :       // 0 => OK to delete.
     476             :       int
     477             :       _M_remove_reference() 
     478             :       {
     479             :         // Be race-detector-friendly.  For more info see bits/c++config.
     480             :         _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&_M_refcount);
     481             :         int __res = __gnu_cxx::__exchange_and_add_dispatch(&_M_refcount, -1);
     482             :         if (__res == 0)
     483             :           {
     484             :             _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&_M_refcount);
     485             :           }
     486             :         return __res;
     487             :       }
     488             :     };
     489             : 
     490             :      _Callback_list*    _M_callbacks;
     491             : 
     492             :     void
     493             :     _M_call_callbacks(event __ev) throw();
     494             : 
     495             :     void
     496             :     _M_dispose_callbacks(void) throw();
     497             : 
     498             :     // 27.4.2.5  Members for iword/pword storage
     499             :     struct _Words
     500             :     {
     501             :       void*     _M_pword;
     502             :       long      _M_iword;
     503             :       _Words() : _M_pword(0), _M_iword(0) { }
     504             :     };
     505             : 
     506             :     // Only for failed iword/pword calls.
     507             :     _Words              _M_word_zero;
     508             : 
     509             :     // Guaranteed storage.
     510             :     // The first 5 iword and pword slots are reserved for internal use.
     511             :     enum { _S_local_word_size = 8 };
     512             :     _Words              _M_local_word[_S_local_word_size];
     513             : 
     514             :     // Allocated storage.
     515             :     int                 _M_word_size;
     516             :     _Words*             _M_word;
     517             : 
     518             :     _Words&
     519             :     _M_grow_words(int __index, bool __iword);
     520             : 
     521             :     // Members for locale and locale caching.
     522             :     locale              _M_ios_locale;
     523             : 
     524             :     void
     525             :     _M_init() throw();
     526             : 
     527             :   public:
     528             : 
     529             :     // 27.4.2.1.6  Class ios_base::Init
     530             :     // Used to initialize standard streams. In theory, g++ could use
     531             :     // -finit-priority to order this stuff correctly without going
     532             :     // through these machinations.
     533             :     class Init
     534             :     {
     535             :       friend class ios_base;
     536             :     public:
     537             :       Init();
     538             :       ~Init();
     539             : 
     540             :     private:
     541             :       static _Atomic_word       _S_refcount;
     542             :       static bool               _S_synced_with_stdio;
     543             :     };
     544             : 
     545             :     // [27.4.2.2] fmtflags state functions
     546             :     /**
     547             :      *  @brief  Access to format flags.
     548             :      *  @return  The format control flags for both input and output.
     549             :     */
     550             :     fmtflags
     551             :     flags() const
     552             :     { return _M_flags; }
     553             : 
     554             :     /**
     555             :      *  @brief  Setting new format flags all at once.
     556             :      *  @param  __fmtfl  The new flags to set.
     557             :      *  @return  The previous format control flags.
     558             :      *
     559             :      *  This function overwrites all the format flags with @a __fmtfl.
     560             :     */
     561             :     fmtflags
     562             :     flags(fmtflags __fmtfl)
     563             :     {
     564             :       fmtflags __old = _M_flags;
     565             :       _M_flags = __fmtfl;
     566             :       return __old;
     567             :     }
     568             : 
     569             :     /**
     570             :      *  @brief  Setting new format flags.
     571             :      *  @param  __fmtfl  Additional flags to set.
     572             :      *  @return  The previous format control flags.
     573             :      *
     574             :      *  This function sets additional flags in format control.  Flags that
     575             :      *  were previously set remain set.
     576             :     */
     577             :     fmtflags
     578             :     setf(fmtflags __fmtfl)
     579             :     {
     580             :       fmtflags __old = _M_flags;
     581             :       _M_flags |= __fmtfl;
     582             :       return __old;
     583             :     }
     584             : 
     585             :     /**
     586             :      *  @brief  Setting new format flags.
     587             :      *  @param  __fmtfl  Additional flags to set.
     588             :      *  @param  __mask  The flags mask for @a fmtfl.
     589             :      *  @return  The previous format control flags.
     590             :      *
     591             :      *  This function clears @a mask in the format flags, then sets
     592             :      *  @a fmtfl @c & @a mask.  An example mask is @c ios_base::adjustfield.
     593             :     */
     594             :     fmtflags
     595             :     setf(fmtflags __fmtfl, fmtflags __mask)
     596             :     {
     597             :       fmtflags __old = _M_flags;
     598             :       _M_flags &= ~__mask;
     599             :       _M_flags |= (__fmtfl & __mask);
     600             :       return __old;
     601             :     }
     602             : 
     603             :     /**
     604             :      *  @brief  Clearing format flags.
     605             :      *  @param  __mask  The flags to unset.
     606             :      *
     607             :      *  This function clears @a __mask in the format flags.
     608             :     */
     609             :     void
     610             :     unsetf(fmtflags __mask)
     611             :     { _M_flags &= ~__mask; }
     612             : 
     613             :     /**
     614             :      *  @brief  Flags access.
     615             :      *  @return  The precision to generate on certain output operations.
     616             :      *
     617             :      *  Be careful if you try to give a definition of @a precision here; see
     618             :      *  DR 189.
     619             :     */
     620             :     streamsize
     621             :     precision() const
     622             :     { return _M_precision; }
     623             : 
     624             :     /**
     625             :      *  @brief  Changing flags.
     626             :      *  @param  __prec  The new precision value.
     627             :      *  @return  The previous value of precision().
     628             :     */
     629             :     streamsize
     630             :     precision(streamsize __prec)
     631             :     {
     632             :       streamsize __old = _M_precision;
     633             :       _M_precision = __prec;
     634             :       return __old;
     635             :     }
     636             : 
     637             :     /**
     638             :      *  @brief  Flags access.
     639             :      *  @return  The minimum field width to generate on output operations.
     640             :      *
     641             :      *  <em>Minimum field width</em> refers to the number of characters.
     642             :     */
     643             :     streamsize
     644             :     width() const
     645             :     { return _M_width; }
     646             : 
     647             :     /**
     648             :      *  @brief  Changing flags.
     649             :      *  @param  __wide  The new width value.
     650             :      *  @return  The previous value of width().
     651             :     */
     652             :     streamsize
     653             :     width(streamsize __wide)
     654             :     {
     655             :       streamsize __old = _M_width;
     656             :       _M_width = __wide;
     657             :       return __old;
     658             :     }
     659             : 
     660             :     // [27.4.2.4] ios_base static members
     661             :     /**
     662             :      *  @brief  Interaction with the standard C I/O objects.
     663             :      *  @param  __sync  Whether to synchronize or not.
     664             :      *  @return  True if the standard streams were previously synchronized.
     665             :      *
     666             :      *  The synchronization referred to is @e only that between the standard
     667             :      *  C facilities (e.g., stdout) and the standard C++ objects (e.g.,
     668             :      *  cout).  User-declared streams are unaffected.  See
     669             :      *  http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt11ch28s02.html
     670             :     */
     671             :     static bool
     672             :     sync_with_stdio(bool __sync = true);
     673             : 
     674             :     // [27.4.2.3] ios_base locale functions
     675             :     /**
     676             :      *  @brief  Setting a new locale.
     677             :      *  @param  __loc  The new locale.
     678             :      *  @return  The previous locale.
     679             :      *
     680             :      *  Sets the new locale for this stream, and then invokes each callback
     681             :      *  with imbue_event.
     682             :     */
     683             :     locale
     684             :     imbue(const locale& __loc) throw();
     685             : 
     686             :     /**
     687             :      *  @brief  Locale access
     688             :      *  @return  A copy of the current locale.
     689             :      *
     690             :      *  If @c imbue(loc) has previously been called, then this function
     691             :      *  returns @c loc.  Otherwise, it returns a copy of @c std::locale(),
     692             :      *  the global C++ locale.
     693             :     */
     694             :     locale
     695             :     getloc() const
     696             :     { return _M_ios_locale; }
     697             : 
     698             :     /**
     699             :      *  @brief  Locale access
     700             :      *  @return  A reference to the current locale.
     701             :      *
     702             :      *  Like getloc above, but returns a reference instead of
     703             :      *  generating a copy.
     704             :     */
     705             :     const locale&
     706             :     _M_getloc() const
     707             :     { return _M_ios_locale; }
     708             : 
     709             :     // [27.4.2.5] ios_base storage functions
     710             :     /**
     711             :      *  @brief  Access to unique indices.
     712             :      *  @return  An integer different from all previous calls.
     713             :      *
     714             :      *  This function returns a unique integer every time it is called.  It
     715             :      *  can be used for any purpose, but is primarily intended to be a unique
     716             :      *  index for the iword and pword functions.  The expectation is that an
     717             :      *  application calls xalloc in order to obtain an index in the iword and
     718             :      *  pword arrays that can be used without fear of conflict.
     719             :      *
     720             :      *  The implementation maintains a static variable that is incremented and
     721             :      *  returned on each invocation.  xalloc is guaranteed to return an index
     722             :      *  that is safe to use in the iword and pword arrays.
     723             :     */
     724             :     static int
     725             :     xalloc() throw();
     726             : 
     727             :     /**
     728             :      *  @brief  Access to integer array.
     729             :      *  @param  __ix  Index into the array.
     730             :      *  @return  A reference to an integer associated with the index.
     731             :      *
     732             :      *  The iword function provides access to an array of integers that can be
     733             :      *  used for any purpose.  The array grows as required to hold the
     734             :      *  supplied index.  All integers in the array are initialized to 0.
     735             :      *
     736             :      *  The implementation reserves several indices.  You should use xalloc to
     737             :      *  obtain an index that is safe to use.  Also note that since the array
     738             :      *  can grow dynamically, it is not safe to hold onto the reference.
     739             :     */
     740             :     long&
     741             :     iword(int __ix)
     742             :     {
     743             :       _Words& __word = (__ix < _M_word_size)
     744             :                         ? _M_word[__ix] : _M_grow_words(__ix, true);
     745             :       return __word._M_iword;
     746             :     }
     747             : 
     748             :     /**
     749             :      *  @brief  Access to void pointer array.
     750             :      *  @param  __ix  Index into the array.
     751             :      *  @return  A reference to a void* associated with the index.
     752             :      *
     753             :      *  The pword function provides access to an array of pointers that can be
     754             :      *  used for any purpose.  The array grows as required to hold the
     755             :      *  supplied index.  All pointers in the array are initialized to 0.
     756             :      *
     757             :      *  The implementation reserves several indices.  You should use xalloc to
     758             :      *  obtain an index that is safe to use.  Also note that since the array
     759             :      *  can grow dynamically, it is not safe to hold onto the reference.
     760             :     */
     761             :     void*&
     762             :     pword(int __ix)
     763             :     {
     764             :       _Words& __word = (__ix < _M_word_size)
     765             :                         ? _M_word[__ix] : _M_grow_words(__ix, false);
     766             :       return __word._M_pword;
     767             :     }
     768             : 
     769             :     // Destructor
     770             :     /**
     771             :      *  Invokes each callback with erase_event.  Destroys local storage.
     772             :      *
     773             :      *  Note that the ios_base object for the standard streams never gets
     774             :      *  destroyed.  As a result, any callbacks registered with the standard
     775             :      *  streams will not get invoked with erase_event (unless copyfmt is
     776             :      *  used).
     777             :     */
     778             :     virtual ~ios_base();
     779             : 
     780             :   protected:
     781             :     ios_base() throw ();
     782             : 
     783             :   // _GLIBCXX_RESOLVE_LIB_DEFECTS
     784             :   // 50.  Copy constructor and assignment operator of ios_base
     785             :   private:
     786             :     ios_base(const ios_base&);
     787             : 
     788             :     ios_base&
     789             :     operator=(const ios_base&);
     790             :   };
     791             : 
     792             :   // [27.4.5.1] fmtflags manipulators
     793             :   /// Calls base.setf(ios_base::boolalpha).
     794             :   inline ios_base&
     795             :   boolalpha(ios_base& __base)
     796             :   {
     797             :     __base.setf(ios_base::boolalpha);
     798             :     return __base;
     799             :   }
     800             : 
     801             :   /// Calls base.unsetf(ios_base::boolalpha).
     802             :   inline ios_base&
     803             :   noboolalpha(ios_base& __base)
     804             :   {
     805             :     __base.unsetf(ios_base::boolalpha);
     806             :     return __base;
     807             :   }
     808             : 
     809             :   /// Calls base.setf(ios_base::showbase).
     810             :   inline ios_base&
     811             :   showbase(ios_base& __base)
     812             :   {
     813             :     __base.setf(ios_base::showbase);
     814             :     return __base;
     815             :   }
     816             : 
     817             :   /// Calls base.unsetf(ios_base::showbase).
     818             :   inline ios_base&
     819             :   noshowbase(ios_base& __base)
     820             :   {
     821             :     __base.unsetf(ios_base::showbase);
     822             :     return __base;
     823             :   }
     824             : 
     825             :   /// Calls base.setf(ios_base::showpoint).
     826             :   inline ios_base&
     827             :   showpoint(ios_base& __base)
     828             :   {
     829             :     __base.setf(ios_base::showpoint);
     830             :     return __base;
     831             :   }
     832             : 
     833             :   /// Calls base.unsetf(ios_base::showpoint).
     834             :   inline ios_base&
     835             :   noshowpoint(ios_base& __base)
     836             :   {
     837             :     __base.unsetf(ios_base::showpoint);
     838             :     return __base;
     839             :   }
     840             : 
     841             :   /// Calls base.setf(ios_base::showpos).
     842             :   inline ios_base&
     843             :   showpos(ios_base& __base)
     844             :   {
     845             :     __base.setf(ios_base::showpos);
     846             :     return __base;
     847             :   }
     848             : 
     849             :   /// Calls base.unsetf(ios_base::showpos).
     850             :   inline ios_base&
     851             :   noshowpos(ios_base& __base)
     852             :   {
     853             :     __base.unsetf(ios_base::showpos);
     854             :     return __base;
     855             :   }
     856             : 
     857             :   /// Calls base.setf(ios_base::skipws).
     858             :   inline ios_base&
     859             :   skipws(ios_base& __base)
     860             :   {
     861             :     __base.setf(ios_base::skipws);
     862             :     return __base;
     863             :   }
     864             : 
     865             :   /// Calls base.unsetf(ios_base::skipws).
     866             :   inline ios_base&
     867             :   noskipws(ios_base& __base)
     868             :   {
     869             :     __base.unsetf(ios_base::skipws);
     870             :     return __base;
     871             :   }
     872             : 
     873             :   /// Calls base.setf(ios_base::uppercase).
     874             :   inline ios_base&
     875             :   uppercase(ios_base& __base)
     876             :   {
     877             :     __base.setf(ios_base::uppercase);
     878             :     return __base;
     879             :   }
     880             : 
     881             :   /// Calls base.unsetf(ios_base::uppercase).
     882             :   inline ios_base&
     883             :   nouppercase(ios_base& __base)
     884             :   {
     885             :     __base.unsetf(ios_base::uppercase);
     886             :     return __base;
     887             :   }
     888             : 
     889             :   /// Calls base.setf(ios_base::unitbuf).
     890             :   inline ios_base&
     891             :   unitbuf(ios_base& __base)
     892             :   {
     893             :      __base.setf(ios_base::unitbuf);
     894             :      return __base;
     895             :   }
     896             : 
     897             :   /// Calls base.unsetf(ios_base::unitbuf).
     898             :   inline ios_base&
     899             :   nounitbuf(ios_base& __base)
     900             :   {
     901             :      __base.unsetf(ios_base::unitbuf);
     902             :      return __base;
     903             :   }
     904             : 
     905             :   // [27.4.5.2] adjustfield manipulators
     906             :   /// Calls base.setf(ios_base::internal, ios_base::adjustfield).
     907             :   inline ios_base&
     908             :   internal(ios_base& __base)
     909             :   {
     910             :      __base.setf(ios_base::internal, ios_base::adjustfield);
     911             :      return __base;
     912             :   }
     913             : 
     914             :   /// Calls base.setf(ios_base::left, ios_base::adjustfield).
     915             :   inline ios_base&
     916             :   left(ios_base& __base)
     917             :   {
     918             :     __base.setf(ios_base::left, ios_base::adjustfield);
     919             :     return __base;
     920             :   }
     921             : 
     922             :   /// Calls base.setf(ios_base::right, ios_base::adjustfield).
     923             :   inline ios_base&
     924             :   right(ios_base& __base)
     925             :   {
     926             :     __base.setf(ios_base::right, ios_base::adjustfield);
     927             :     return __base;
     928             :   }
     929             : 
     930             :   // [27.4.5.3] basefield manipulators
     931             :   /// Calls base.setf(ios_base::dec, ios_base::basefield).
     932             :   inline ios_base&
     933             :   dec(ios_base& __base)
     934             :   {
     935             :     __base.setf(ios_base::dec, ios_base::basefield);
     936             :     return __base;
     937             :   }
     938             : 
     939             :   /// Calls base.setf(ios_base::hex, ios_base::basefield).
     940             :   inline ios_base&
     941             :   hex(ios_base& __base)
     942             :   {
     943             :     __base.setf(ios_base::hex, ios_base::basefield);
     944             :     return __base;
     945             :   }
     946             : 
     947             :   /// Calls base.setf(ios_base::oct, ios_base::basefield).
     948             :   inline ios_base&
     949             :   oct(ios_base& __base)
     950             :   {
     951             :     __base.setf(ios_base::oct, ios_base::basefield);
     952             :     return __base;
     953             :   }
     954             : 
     955             :   // [27.4.5.4] floatfield manipulators
     956             :   /// Calls base.setf(ios_base::fixed, ios_base::floatfield).
     957             :   inline ios_base&
     958             :   fixed(ios_base& __base)
     959             :   {
     960             :     __base.setf(ios_base::fixed, ios_base::floatfield);
     961             :     return __base;
     962             :   }
     963             : 
     964             :   /// Calls base.setf(ios_base::scientific, ios_base::floatfield).
     965             :   inline ios_base&
     966             :   scientific(ios_base& __base)
     967             :   {
     968             :     __base.setf(ios_base::scientific, ios_base::floatfield);
     969             :     return __base;
     970             :   }
     971             : 
     972             : _GLIBCXX_END_NAMESPACE_VERSION
     973             : } // namespace
     974             : 
     975             : #endif /* _IOS_BASE_H */

Generated by: LCOV version 1.11