# ios_base.h

Go to the documentation of this file.

    00001 // Iostreams base classes -*- C++ -*-
    00002
    00003 // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
    00004 // Free Software Foundation, Inc.
    00005 //
    00006 // This file is part of the GNU ISO C++ Library.  This library is free
    00007 // software; you can redistribute it and/or modify it under the
    00008 // terms of the GNU General Public License as published by the
    00009 // Free Software Foundation; either version 2, or (at your option)
    00010 // any later version.
    00011
    00012 // This library is distributed in the hope that it will be useful,
    00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
    00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00015 // GNU General Public License for more details.
    00016
    00017 // You should have received a copy of the GNU General Public License along
    00018 // with this library; see the file COPYING.  If not, write to the Free
    00019 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
    00020 // USA.
    00021
    00022 // As a special exception, you may use this file as part of a free software
    00023 // library without restriction.  Specifically, if other files instantiate
    00024 // templates or use macros or inline functions from this file, or you compile
    00025 // this file and link it with other files to produce an executable, this
    00026 // file does not by itself cause the resulting executable to be covered by
    00027 // the GNU General Public License.  This exception does not however
    00028 // invalidate any other reasons why the executable file might be covered by
    00029 // the GNU General Public License.
    00030
    00031 /** @file ios_base.h
    00032  *  This is an internal header file, included by other library headers.
    00033  *  You should not attempt to use it directly.
    00034  */
    00035
    00036 //
    00037 // ISO C++ 14882: 27.4  Iostreams base classes
    00038 //
    00039
    00040 #ifndef _IOS_BASE_H
    00041 #define _IOS_BASE_H 1
    00042
    00043 #pragma GCC system_header
    00044
    00045 #include <ext/atomicity.h>
    00046 #include <bits/localefwd.h>
    00047 #include <bits/locale_classes.h>
    00048
    00049 _GLIBCXX_BEGIN_NAMESPACE(std)
    00050
    00051   // The following definitions of bitmask types are enums, not ints,
    00052   // as permitted (but not required) in the standard, in order to provide
    00053   // better type safety in iostream calls.  A side effect is that
    00054   // expressions involving them are no longer compile-time constants.
    00055   enum _Ios_Fmtflags
    00056     {
    00057       _S_boolalpha  = 1L << 0,
    00058       _S_dec        = 1L << 1,
    00059       _S_fixed      = 1L << 2,
    00060       _S_hex        = 1L << 3,
    00061       _S_internal   = 1L << 4,
    00062       _S_left       = 1L << 5,
    00063       _S_oct        = 1L << 6,
    00064       _S_right      = 1L << 7,
    00065       _S_scientific     = 1L << 8,
    00066       _S_showbase   = 1L << 9,
    00067       _S_showpoint  = 1L << 10,
    00068       _S_showpos    = 1L << 11,
    00069       _S_skipws     = 1L << 12,
    00070       _S_unitbuf    = 1L << 13,
    00071       _S_uppercase  = 1L << 14,
    00072       _S_adjustfield    = _S_left | _S_right | _S_internal,
    00073       _S_basefield  = _S_dec | _S_oct | _S_hex,
    00074       _S_floatfield     = _S_scientific | _S_fixed,
    00075       _S_ios_fmtflags_end = 1L << 16
    00076     };
    00077
    00078   inline _Ios_Fmtflags
    00079   operator&(_Ios_Fmtflags __a, _Ios_Fmtflags __b)
    00080   { return _Ios_Fmtflags(static_cast<int>(__a) & static_cast<int>(__b)); }
    00081
    00082   inline _Ios_Fmtflags
    00083   operator|(_Ios_Fmtflags __a, _Ios_Fmtflags __b)
    00084   { return _Ios_Fmtflags(static_cast<int>(__a) | static_cast<int>(__b)); }
    00085
    00086   inline _Ios_Fmtflags
    00087   operator^(_Ios_Fmtflags __a, _Ios_Fmtflags __b)
    00088   { return _Ios_Fmtflags(static_cast<int>(__a) ^ static_cast<int>(__b)); }
    00089
    00090   inline _Ios_Fmtflags&
    00091   operator|=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b)
    00092   { return __a = __a | __b; }
    00093
    00094   inline _Ios_Fmtflags&
    00095   operator&=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b)
    00096   { return __a = __a & __b; }
    00097
    00098   inline _Ios_Fmtflags&
    00099   operator^=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b)
    00100   { return __a = __a ^ __b; }
    00101
    00102   inline _Ios_Fmtflags
    00103   operator~(_Ios_Fmtflags __a)
    00104   { return _Ios_Fmtflags(~static_cast<int>(__a)); }
    00105
    00106
    00107   enum _Ios_Openmode
    00108     {
    00109       _S_app        = 1L << 0,
    00110       _S_ate        = 1L << 1,
    00111       _S_bin        = 1L << 2,
    00112       _S_in         = 1L << 3,
    00113       _S_out        = 1L << 4,
    00114       _S_trunc      = 1L << 5,
    00115       _S_ios_openmode_end = 1L << 16
    00116     };
    00117
    00118   inline _Ios_Openmode
    00119   operator&(_Ios_Openmode __a, _Ios_Openmode __b)
    00120   { return _Ios_Openmode(static_cast<int>(__a) & static_cast<int>(__b)); }
    00121
    00122   inline _Ios_Openmode
    00123   operator|(_Ios_Openmode __a, _Ios_Openmode __b)
    00124   { return _Ios_Openmode(static_cast<int>(__a) | static_cast<int>(__b)); }
    00125
    00126   inline _Ios_Openmode
    00127   operator^(_Ios_Openmode __a, _Ios_Openmode __b)
    00128   { return _Ios_Openmode(static_cast<int>(__a) ^ static_cast<int>(__b)); }
    00129
    00130   inline _Ios_Openmode&
    00131   operator|=(_Ios_Openmode& __a, _Ios_Openmode __b)
    00132   { return __a = __a | __b; }
    00133
    00134   inline _Ios_Openmode&
    00135   operator&=(_Ios_Openmode& __a, _Ios_Openmode __b)
    00136   { return __a = __a & __b; }
    00137
    00138   inline _Ios_Openmode&
    00139   operator^=(_Ios_Openmode& __a, _Ios_Openmode __b)
    00140   { return __a = __a ^ __b; }
    00141
    00142   inline _Ios_Openmode
    00143   operator~(_Ios_Openmode __a)
    00144   { return _Ios_Openmode(~static_cast<int>(__a)); }
    00145
    00146
    00147   enum _Ios_Iostate
    00148     {
    00149       _S_goodbit        = 0,
    00150       _S_badbit         = 1L << 0,
    00151       _S_eofbit         = 1L << 1,
    00152       _S_failbit        = 1L << 2,
    00153       _S_ios_iostate_end = 1L << 16
    00154     };
    00155
    00156   inline _Ios_Iostate
    00157   operator&(_Ios_Iostate __a, _Ios_Iostate __b)
    00158   { return _Ios_Iostate(static_cast<int>(__a) & static_cast<int>(__b)); }
    00159
    00160   inline _Ios_Iostate
    00161   operator|(_Ios_Iostate __a, _Ios_Iostate __b)
    00162   { return _Ios_Iostate(static_cast<int>(__a) | static_cast<int>(__b)); }
    00163
    00164   inline _Ios_Iostate
    00165   operator^(_Ios_Iostate __a, _Ios_Iostate __b)
    00166   { return _Ios_Iostate(static_cast<int>(__a) ^ static_cast<int>(__b)); }
    00167
    00168   inline _Ios_Iostate&
    00169   operator|=(_Ios_Iostate& __a, _Ios_Iostate __b)
    00170   { return __a = __a | __b; }
    00171
    00172   inline _Ios_Iostate&
    00173   operator&=(_Ios_Iostate& __a, _Ios_Iostate __b)
    00174   { return __a = __a & __b; }
    00175
    00176   inline _Ios_Iostate&
    00177   operator^=(_Ios_Iostate& __a, _Ios_Iostate __b)
    00178   { return __a = __a ^ __b; }
    00179
    00180   inline _Ios_Iostate
    00181   operator~(_Ios_Iostate __a)
    00182   { return _Ios_Iostate(~static_cast<int>(__a)); }
    00183
    00184   enum _Ios_Seekdir
    00185     {
    00186       _S_beg = 0,
    00187       _S_cur = SEEK_CUR,
    00188       _S_end = SEEK_END,
    00189       _S_ios_seekdir_end = 1L << 16
    00190     };
    00191
    00192   // 27.4.2  Class ios_base
    00193   /**
    00194    *  @brief  The base of the I/O class hierarchy.
    00195    *
    00196    *  This class defines everything that can be defined about I/O that does
    00197    *  not depend on the type of characters being input or output.  Most
    00198    *  people will only see @c ios_base when they need to specify the full
    00199    *  name of the various I/O flags (e.g., the openmodes).
    00200   */
    00201   class ios_base
    00202   {
    00203   public:
    00204
    00205     // 27.4.2.1.1  Class ios_base::failure
    00206     /// These are thrown to indicate problems.  Doc me.
    00207     class failure : public exception
    00208     {
    00209     public:
    00210       // _GLIBCXX_RESOLVE_LIB_DEFECTS
    00211       // 48.  Use of non-existent exception constructor
    00212       explicit
    00213       failure(const string& __str) throw();
    00214
    00215       // This declaration is not useless:
    00216       // http://gcc.gnu.org/onlinedocs/gcc-3.0.2/gcc_6.html#SEC118
    00217       virtual
    00218       ~failure() throw();
    00219
    00220       virtual const char*
    00221       what() const throw();
    00222
    00223     private:
    00224       string _M_msg;
    00225     };
    00226
    00227     // 27.4.2.1.2  Type ios_base::fmtflags
    00228     /**
    00229      *  @brief This is a bitmask type.
    00230      *
    00231      *  @c "_Ios_Fmtflags" is implementation-defined, but it is valid to
    00232      *  perform bitwise operations on these values and expect the Right
    00233      *  Thing to happen.  Defined objects of type fmtflags are:
    00234      *  - boolalpha
    00235      *  - dec
    00236      *  - fixed
    00237      *  - hex
    00238      *  - internal
    00239      *  - left
    00240      *  - oct
    00241      *  - right
    00242      *  - scientific
    00243      *  - showbase
    00244      *  - showpoint
    00245      *  - showpos
    00246      *  - skipws
    00247      *  - unitbuf
    00248      *  - uppercase
    00249      *  - adjustfield
    00250      *  - basefield
    00251      *  - floatfield
    00252     */
    00253     typedef _Ios_Fmtflags fmtflags;
    00254
    00255     /// Insert/extract @c bool in alphabetic rather than numeric format.
    00256     static const fmtflags boolalpha =   _S_boolalpha;
    00257
    00258     /// Converts integer input or generates integer output in decimal base.
    00259     static const fmtflags dec =         _S_dec;
    00260
    00261     /// Generate floating-point output in fixed-point notation.
    00262     static const fmtflags fixed =       _S_fixed;
    00263
    00264     /// Converts integer input or generates integer output in hexadecimal base.
    00265     static const fmtflags hex =         _S_hex;
    00266
    00267     /// Adds fill characters at a designated internal point in certain
    00268     /// generated output, or identical to @c right if no such point is
    00269     /// designated.
    00270     static const fmtflags internal =    _S_internal;
    00271
    00272     /// Adds fill characters on the right (final positions) of certain
    00273     /// generated output.  (I.e., the thing you print is flush left.)
    00274     static const fmtflags left =        _S_left;
    00275
    00276     /// Converts integer input or generates integer output in octal base.
    00277     static const fmtflags oct =         _S_oct;
    00278
    00279     /// Adds fill characters on the left (initial positions) of certain
    00280     /// generated output.  (I.e., the thing you print is flush right.)
    00281     static const fmtflags right =       _S_right;
    00282
    00283     /// Generates floating-point output in scientific notation.
    00284     static const fmtflags scientific =  _S_scientific;
    00285
    00286     /// Generates a prefix indicating the numeric base of generated integer
    00287     /// output.
    00288     static const fmtflags showbase =    _S_showbase;
    00289
    00290     /// Generates a decimal-point character unconditionally in generated
    00291     /// floating-point output.
    00292     static const fmtflags showpoint =   _S_showpoint;
    00293
    00294     /// Generates a + sign in non-negative generated numeric output.
    00295     static const fmtflags showpos =     _S_showpos;
    00296
    00297     /// Skips leading white space before certain input operations.
    00298     static const fmtflags skipws =      _S_skipws;
    00299
    00300     /// Flushes output after each output operation.
    00301     static const fmtflags unitbuf =     _S_unitbuf;
    00302
    00303     /// Replaces certain lowercase letters with their uppercase equivalents
    00304     /// in generated output.
    00305     static const fmtflags uppercase =   _S_uppercase;
    00306
    00307     /// A mask of left|right|internal.  Useful for the 2-arg form of @c setf.
    00308     static const fmtflags adjustfield = _S_adjustfield;
    00309
    00310     /// A mask of dec|oct|hex.  Useful for the 2-arg form of @c setf.
    00311     static const fmtflags basefield =   _S_basefield;
    00312
    00313     /// A mask of scientific|fixed.  Useful for the 2-arg form of @c setf.
    00314     static const fmtflags floatfield =  _S_floatfield;
    00315
    00316     // 27.4.2.1.3  Type ios_base::iostate
    00317     /**
    00318      *  @brief This is a bitmask type.
    00319      *
    00320      *  @c "_Ios_Iostate" is implementation-defined, but it is valid to
    00321      *  perform bitwise operations on these values and expect the Right
    00322      *  Thing to happen.  Defined objects of type iostate are:
    00323      *  - badbit
    00324      *  - eofbit
    00325      *  - failbit
    00326      *  - goodbit
    00327     */
    00328     typedef _Ios_Iostate iostate;
    00329
    00330     /// Indicates a loss of integrity in an input or output sequence (such
    00331     /// as an irrecoverable read error from a file).
    00332     static const iostate badbit =   _S_badbit;
    00333
    00334     /// Indicates that an input operation reached the end of an input sequence.
    00335     static const iostate eofbit =   _S_eofbit;
    00336
    00337     /// Indicates that an input operation failed to read the expected
    00338     /// characters, or that an output operation failed to generate the
    00339     /// desired characters.
    00340     static const iostate failbit =  _S_failbit;
    00341
    00342     /// Indicates all is well.
    00343     static const iostate goodbit =  _S_goodbit;
    00344
    00345     // 27.4.2.1.4  Type ios_base::openmode
    00346     /**
    00347      *  @brief This is a bitmask type.
    00348      *
    00349      *  @c "_Ios_Openmode" is implementation-defined, but it is valid to
    00350      *  perform bitwise operations on these values and expect the Right
    00351      *  Thing to happen.  Defined objects of type openmode are:
    00352      *  - app
    00353      *  - ate
    00354      *  - binary
    00355      *  - in
    00356      *  - out
    00357      *  - trunc
    00358     */
    00359     typedef _Ios_Openmode openmode;
    00360
    00361     /// Seek to end before each write.
    00362     static const openmode app =     _S_app;
    00363
    00364     /// Open and seek to end immediately after opening.
    00365     static const openmode ate =     _S_ate;
    00366
    00367     /// Perform input and output in binary mode (as opposed to text mode).
    00368     /// This is probably not what you think it is; see
    00369     /// http://gcc.gnu.org/onlinedocs/libstdc++/27_io/howto.html#3 and
    00370     /// http://gcc.gnu.org/onlinedocs/libstdc++/27_io/howto.html#7 for more.
    00371     static const openmode binary =  _S_bin;
    00372
    00373     /// Open for input.  Default for @c ifstream and fstream.
    00374     static const openmode in =      _S_in;
    00375
    00376     /// Open for output.  Default for @c ofstream and fstream.
    00377     static const openmode out =     _S_out;
    00378
    00379     /// Open for input.  Default for @c ofstream.
    00380     static const openmode trunc =   _S_trunc;
    00381
    00382     // 27.4.2.1.5  Type ios_base::seekdir
    00383     /**
    00384      *  @brief This is an enumerated type.
    00385      *
    00386      *  @c "_Ios_Seekdir" is implementation-defined.  Defined values
    00387      *  of type seekdir are:
    00388      *  - beg
    00389      *  - cur, equivalent to @c SEEK_CUR in the C standard library.
    00390      *  - end, equivalent to @c SEEK_END in the C standard library.
    00391     */
    00392     typedef _Ios_Seekdir seekdir;
    00393
    00394     /// Request a seek relative to the beginning of the stream.
    00395     static const seekdir beg =      _S_beg;
    00396
    00397     /// Request a seek relative to the current position within the sequence.
    00398     static const seekdir cur =      _S_cur;
    00399
    00400     /// Request a seek relative to the current end of the sequence.
    00401     static const seekdir end =      _S_end;
    00402
    00403     // Annex D.6
    00404     typedef int io_state;
    00405     typedef int open_mode;
    00406     typedef int seek_dir;
    00407
    00408     typedef std::streampos streampos;
    00409     typedef std::streamoff streamoff;
    00410
    00411     // Callbacks;
    00412     /**
    00413      *  @brief  The set of events that may be passed to an event callback.
    00414      *
    00415      *  erase_event is used during ~ios() and copyfmt().  imbue_event is used
    00416      *  during imbue().  copyfmt_event is used during copyfmt().
    00417     */
    00418     enum event
    00419     {
    00420       erase_event,
    00421       imbue_event,
    00422       copyfmt_event
    00423     };
    00424
    00425     /**
    00426      *  @brief  The type of an event callback function.
    00427      *  @param  event  One of the members of the event enum.
    00428      *  @param  ios_base  Reference to the ios_base object.
    00429      *  @param  int  The integer provided when the callback was registered.
    00430      *
    00431      *  Event callbacks are user defined functions that get called during
    00432      *  several ios_base and basic_ios functions, specifically imbue(),
    00433      *  copyfmt(), and ~ios().
    00434     */
    00435     typedef void (*event_callback) (event, ios_base&, int);
    00436
    00437     /**
    00438      *  @brief  Add the callback __fn with parameter __index.
    00439      *  @param  __fn  The function to add.
    00440      *  @param  __index  The integer to pass to the function when invoked.
    00441      *
    00442      *  Registers a function as an event callback with an integer parameter to
    00443      *  be passed to the function when invoked.  Multiple copies of the
    00444      *  function are allowed.  If there are multiple callbacks, they are
    00445      *  invoked in the order they were registered.
    00446     */
    00447     void
    00448     register_callback(event_callback __fn, int __index);
    00449
    00450   protected:
    00451     //@{
    00452     /**
    00453      *  @if maint
    00454      *  ios_base data members (doc me)
    00455      *  @endif
    00456     */
    00457     streamsize      _M_precision;
    00458     streamsize      _M_width;
    00459     fmtflags        _M_flags;
    00460     iostate     _M_exception;
    00461     iostate     _M_streambuf_state;
    00462     //@}
    00463
    00464     // 27.4.2.6  Members for callbacks
    00465     // 27.4.2.6  ios_base callbacks
    00466     struct _Callback_list
    00467     {
    00468       // Data Members
    00469       _Callback_list*       _M_next;
    00470       ios_base::event_callback  _M_fn;
    00471       int           _M_index;
    00472       _Atomic_word      _M_refcount;  // 0 means one reference.
    00473
    00474       _Callback_list(ios_base::event_callback __fn, int __index,
    00475              _Callback_list* __cb)
    00476       : _M_next(__cb), _M_fn(__fn), _M_index(__index), _M_refcount(0) { }
    00477
    00478       void
    00479       _M_add_reference() { __gnu_cxx::__atomic_add_dispatch(&_M_refcount, 1); }
    00480
    00481       // 0 => OK to delete.
    00482       int
    00483       _M_remove_reference()
    00484       { return __gnu_cxx::__exchange_and_add_dispatch(&_M_refcount, -1); }
    00485     };
    00486
    00487      _Callback_list*    _M_callbacks;
    00488
    00489     void
    00490     _M_call_callbacks(event __ev) throw();
    00491
    00492     void
    00493     _M_dispose_callbacks(void);
    00494
    00495     // 27.4.2.5  Members for iword/pword storage
    00496     struct _Words
    00497     {
    00498       void* _M_pword;
    00499       long  _M_iword;
    00500       _Words() : _M_pword(0), _M_iword(0) { }
    00501     };
    00502
    00503     // Only for failed iword/pword calls.
    00504     _Words      _M_word_zero;
    00505
    00506     // Guaranteed storage.
    00507     // The first 5 iword and pword slots are reserved for internal use.
    00508     enum { _S_local_word_size = 8 };
    00509     _Words      _M_local_word[_S_local_word_size];
    00510
    00511     // Allocated storage.
    00512     int         _M_word_size;
    00513     _Words*     _M_word;
    00514
    00515     _Words&
    00516     _M_grow_words(int __index, bool __iword);
    00517
    00518     // Members for locale and locale caching.
    00519     locale      _M_ios_locale;
    00520
    00521     void
    00522     _M_init();
    00523
    00524   public:
    00525
    00526     // 27.4.2.1.6  Class ios_base::Init
    00527     // Used to initialize standard streams. In theory, g++ could use
    00528     // -finit-priority to order this stuff correctly without going
    00529     // through these machinations.
    00530     class Init
    00531     {
    00532       friend class ios_base;
    00533     public:
    00534       Init();
    00535       ~Init();
    00536
    00537     private:
    00538       static _Atomic_word   _S_refcount;
    00539       static bool       _S_synced_with_stdio;
    00540     };
    00541
    00542     // [27.4.2.2] fmtflags state functions
    00543     /**
    00544      *  @brief  Access to format flags.
    00545      *  @return  The format control flags for both input and output.
    00546     */
    00547     inline fmtflags
    00548     flags() const { return _M_flags; }
    00549
    00550     /**
    00551      *  @brief  Setting new format flags all at once.
    00552      *  @param  fmtfl  The new flags to set.
    00553      *  @return  The previous format control flags.
    00554      *
    00555      *  This function overwrites all the format flags with @a fmtfl.
    00556     */
    00557     inline fmtflags
    00558     flags(fmtflags __fmtfl)
    00559     {
    00560       fmtflags __old = _M_flags;
    00561       _M_flags = __fmtfl;
    00562       return __old;
    00563     }
    00564
    00565     /**
    00566      *  @brief  Setting new format flags.
    00567      *  @param  fmtfl  Additional flags to set.
    00568      *  @return  The previous format control flags.
    00569      *
    00570      *  This function sets additional flags in format control.  Flags that
    00571      *  were previously set remain set.
    00572     */
    00573     inline fmtflags
    00574     setf(fmtflags __fmtfl)
    00575     {
    00576       fmtflags __old = _M_flags;
    00577       _M_flags |= __fmtfl;
    00578       return __old;
    00579     }
    00580
    00581     /**
    00582      *  @brief  Setting new format flags.
    00583      *  @param  fmtfl  Additional flags to set.
    00584      *  @param  mask  The flags mask for @a fmtfl.
    00585      *  @return  The previous format control flags.
    00586      *
    00587      *  This function clears @a mask in the format flags, then sets
    00588      *  @a fmtfl @c & @a mask.  An example mask is @c ios_base::adjustfield.
    00589     */
    00590     inline fmtflags
    00591     setf(fmtflags __fmtfl, fmtflags __mask)
    00592     {
    00593       fmtflags __old = _M_flags;
    00594       _M_flags &= ~__mask;
    00595       _M_flags |= (__fmtfl & __mask);
    00596       return __old;
    00597     }
    00598
    00599     /**
    00600      *  @brief  Clearing format flags.
    00601      *  @param  mask  The flags to unset.
    00602      *
    00603      *  This function clears @a mask in the format flags.
    00604     */
    00605     inline void
    00606     unsetf(fmtflags __mask) { _M_flags &= ~__mask; }
    00607
    00608     /**
    00609      *  @brief  Flags access.
    00610      *  @return  The precision to generate on certain output operations.
    00611      *
    00612      *  @if maint
    00613      *  Be careful if you try to give a definition of "precision" here; see
    00614      *  DR 189.
    00615      *  @endif
    00616     */
    00617     inline streamsize
    00618     precision() const { return _M_precision; }
    00619
    00620     /**
    00621      *  @brief  Changing flags.
    00622      *  @param  prec  The new precision value.
    00623      *  @return  The previous value of precision().
    00624     */
    00625     inline streamsize
    00626     precision(streamsize __prec)
    00627     {
    00628       streamsize __old = _M_precision;
    00629       _M_precision = __prec;
    00630       return __old;
    00631     }
    00632
    00633     /**
    00634      *  @brief  Flags access.
    00635      *  @return  The minimum field width to generate on output operations.
    00636      *
    00637      *  "Minimum field width" refers to the number of characters.
    00638     */
    00639     inline streamsize
    00640     width() const { return _M_width; }
    00641
    00642     /**
    00643      *  @brief  Changing flags.
    00644      *  @param  wide  The new width value.
    00645      *  @return  The previous value of width().
    00646     */
    00647     inline streamsize
    00648     width(streamsize __wide)
    00649     {
    00650       streamsize __old = _M_width;
    00651       _M_width = __wide;
    00652       return __old;
    00653     }
    00654
    00655     // [27.4.2.4] ios_base static members
    00656     /**
    00657      *  @brief  Interaction with the standard C I/O objects.
    00658      *  @param  sync  Whether to synchronize or not.
    00659      *  @return  True if the standard streams were previously synchronized.
    00660      *
    00661      *  The synchronization referred to is @e only that between the standard
    00662      *  C facilities (e.g., stdout) and the standard C++ objects (e.g.,
    00663      *  cout).  User-declared streams are unaffected.  See
    00664      *  http://gcc.gnu.org/onlinedocs/libstdc++/27_io/howto.html#8 for more.
    00665     */
    00666     static bool
    00667     sync_with_stdio(bool __sync = true);
    00668
    00669     // [27.4.2.3] ios_base locale functions
    00670     /**
    00671      *  @brief  Setting a new locale.
    00672      *  @param  loc  The new locale.
    00673      *  @return  The previous locale.
    00674      *
    00675      *  Sets the new locale for this stream, and then invokes each callback
    00676      *  with imbue_event.
    00677     */
    00678     locale
    00679     imbue(const locale& __loc);
    00680
    00681     /**
    00682      *  @brief  Locale access
    00683      *  @return  A copy of the current locale.
    00684      *
    00685      *  If @c imbue(loc) has previously been called, then this function
    00686      *  returns @c loc.  Otherwise, it returns a copy of @c std::locale(),
    00687      *  the global C++ locale.
    00688     */
    00689     inline locale
    00690     getloc() const { return _M_ios_locale; }
    00691
    00692     /**
    00693      *  @brief  Locale access
    00694      *  @return  A reference to the current locale.
    00695      *
    00696      *  Like getloc above, but returns a reference instead of
    00697      *  generating a copy.
    00698     */
    00699     inline const locale&
    00700     _M_getloc() const { return _M_ios_locale; }
    00701
    00702     // [27.4.2.5] ios_base storage functions
    00703     /**
    00704      *  @brief  Access to unique indices.
    00705      *  @return  An integer different from all previous calls.
    00706      *
    00707      *  This function returns a unique integer every time it is called.  It
    00708      *  can be used for any purpose, but is primarily intended to be a unique
    00709      *  index for the iword and pword functions.  The expectation is that an
    00710      *  application calls xalloc in order to obtain an index in the iword and
    00711      *  pword arrays that can be used without fear of conflict.
    00712      *
    00713      *  The implementation maintains a static variable that is incremented and
    00714      *  returned on each invocation.  xalloc is guaranteed to return an index
    00715      *  that is safe to use in the iword and pword arrays.
    00716     */
    00717     static int
    00718     xalloc() throw();
    00719
    00720     /**
    00721      *  @brief  Access to integer array.
    00722      *  @param  __ix  Index into the array.
    00723      *  @return  A reference to an integer associated with the index.
    00724      *
    00725      *  The iword function provides access to an array of integers that can be
    00726      *  used for any purpose.  The array grows as required to hold the
    00727      *  supplied index.  All integers in the array are initialized to 0.
    00728      *
    00729      *  The implementation reserves several indices.  You should use xalloc to
    00730      *  obtain an index that is safe to use.  Also note that since the array
    00731      *  can grow dynamically, it is not safe to hold onto the reference.
    00732     */
    00733     inline long&
    00734     iword(int __ix)
    00735     {
    00736       _Words& __word = (__ix < _M_word_size)
    00737             ? _M_word[__ix] : _M_grow_words(__ix, true);
    00738       return __word._M_iword;
    00739     }
    00740
    00741     /**
    00742      *  @brief  Access to void pointer array.
    00743      *  @param  __ix  Index into the array.
    00744      *  @return  A reference to a void* associated with the index.
    00745      *
    00746      *  The pword function provides access to an array of pointers that can be
    00747      *  used for any purpose.  The array grows as required to hold the
    00748      *  supplied index.  All pointers in the array are initialized to 0.
    00749      *
    00750      *  The implementation reserves several indices.  You should use xalloc to
    00751      *  obtain an index that is safe to use.  Also note that since the array
    00752      *  can grow dynamically, it is not safe to hold onto the reference.
    00753     */
    00754     inline void*&
    00755     pword(int __ix)
    00756     {
    00757       _Words& __word = (__ix < _M_word_size)
    00758             ? _M_word[__ix] : _M_grow_words(__ix, false);
    00759       return __word._M_pword;
    00760     }
    00761
    00762     // Destructor
    00763     /**
    00764      *  Invokes each callback with erase_event.  Destroys local storage.
    00765      *
    00766      *  Note that the ios_base object for the standard streams never gets
    00767      *  destroyed.  As a result, any callbacks registered with the standard
    00768      *  streams will not get invoked with erase_event (unless copyfmt is
    00769      *  used).
    00770     */
    00771     virtual ~ios_base();
    00772
    00773   protected:
    00774     ios_base();
    00775
    00776   // _GLIBCXX_RESOLVE_LIB_DEFECTS
    00777   // 50.  Copy constructor and assignment operator of ios_base
    00778   private:
    00779     ios_base(const ios_base&);
    00780
    00781     ios_base&
    00782     operator=(const ios_base&);
    00783   };
    00784
    00785   // [27.4.5.1] fmtflags manipulators
    00786   /// Calls base.setf(ios_base::boolalpha).
    00787   inline ios_base&
    00788   boolalpha(ios_base& __base)
    00789   {
    00790     __base.setf(ios_base::boolalpha);
    00791     return __base;
    00792   }
    00793
    00794   /// Calls base.unsetf(ios_base::boolalpha).
    00795   inline ios_base&
    00796   noboolalpha(ios_base& __base)
    00797   {
    00798     __base.unsetf(ios_base::boolalpha);
    00799     return __base;
    00800   }
    00801
    00802   /// Calls base.setf(ios_base::showbase).
    00803   inline ios_base&
    00804   showbase(ios_base& __base)
    00805   {
    00806     __base.setf(ios_base::showbase);
    00807     return __base;
    00808   }
    00809
    00810   /// Calls base.unsetf(ios_base::showbase).
    00811   inline ios_base&
    00812   noshowbase(ios_base& __base)
    00813   {
    00814     __base.unsetf(ios_base::showbase);
    00815     return __base;
    00816   }
    00817
    00818   /// Calls base.setf(ios_base::showpoint).
    00819   inline ios_base&
    00820   showpoint(ios_base& __base)
    00821   {
    00822     __base.setf(ios_base::showpoint);
    00823     return __base;
    00824   }
    00825
    00826   /// Calls base.unsetf(ios_base::showpoint).
    00827   inline ios_base&
    00828   noshowpoint(ios_base& __base)
    00829   {
    00830     __base.unsetf(ios_base::showpoint);
    00831     return __base;
    00832   }
    00833
    00834   /// Calls base.setf(ios_base::showpos).
    00835   inline ios_base&
    00836   showpos(ios_base& __base)
    00837   {
    00838     __base.setf(ios_base::showpos);
    00839     return __base;
    00840   }
    00841
    00842   /// Calls base.unsetf(ios_base::showpos).
    00843   inline ios_base&
    00844   noshowpos(ios_base& __base)
    00845   {
    00846     __base.unsetf(ios_base::showpos);
    00847     return __base;
    00848   }
    00849
    00850   /// Calls base.setf(ios_base::skipws).
    00851   inline ios_base&
    00852   skipws(ios_base& __base)
    00853   {
    00854     __base.setf(ios_base::skipws);
    00855     return __base;
    00856   }
    00857
    00858   /// Calls base.unsetf(ios_base::skipws).
    00859   inline ios_base&
    00860   noskipws(ios_base& __base)
    00861   {
    00862     __base.unsetf(ios_base::skipws);
    00863     return __base;
    00864   }
    00865
    00866   /// Calls base.setf(ios_base::uppercase).
    00867   inline ios_base&
    00868   uppercase(ios_base& __base)
    00869   {
    00870     __base.setf(ios_base::uppercase);
    00871     return __base;
    00872   }
    00873
    00874   /// Calls base.unsetf(ios_base::uppercase).
    00875   inline ios_base&
    00876   nouppercase(ios_base& __base)
    00877   {
    00878     __base.unsetf(ios_base::uppercase);
    00879     return __base;
    00880   }
    00881
    00882   /// Calls base.setf(ios_base::unitbuf).
    00883   inline ios_base&
    00884   unitbuf(ios_base& __base)
    00885   {
    00886      __base.setf(ios_base::unitbuf);
    00887      return __base;
    00888   }
    00889
    00890   /// Calls base.unsetf(ios_base::unitbuf).
    00891   inline ios_base&
    00892   nounitbuf(ios_base& __base)
    00893   {
    00894      __base.unsetf(ios_base::unitbuf);
    00895      return __base;
    00896   }
    00897
    00898   // [27.4.5.2] adjustfield anipulators
    00899   /// Calls base.setf(ios_base::internal, ios_base::adjustfield).
    00900   inline ios_base&
    00901   internal(ios_base& __base)
    00902   {
    00903      __base.setf(ios_base::internal, ios_base::adjustfield);
    00904      return __base;
    00905   }
    00906
    00907   /// Calls base.setf(ios_base::left, ios_base::adjustfield).
    00908   inline ios_base&
    00909   left(ios_base& __base)
    00910   {
    00911     __base.setf(ios_base::left, ios_base::adjustfield);
    00912     return __base;
    00913   }
    00914
    00915   /// Calls base.setf(ios_base::right, ios_base::adjustfield).
    00916   inline ios_base&
    00917   right(ios_base& __base)
    00918   {
    00919     __base.setf(ios_base::right, ios_base::adjustfield);
    00920     return __base;
    00921   }
    00922
    00923   // [27.4.5.3] basefield anipulators
    00924   /// Calls base.setf(ios_base::dec, ios_base::basefield).
    00925   inline ios_base&
    00926   dec(ios_base& __base)
    00927   {
    00928     __base.setf(ios_base::dec, ios_base::basefield);
    00929     return __base;
    00930   }
    00931
    00932   /// Calls base.setf(ios_base::hex, ios_base::basefield).
    00933   inline ios_base&
    00934   hex(ios_base& __base)
    00935   {
    00936     __base.setf(ios_base::hex, ios_base::basefield);
    00937     return __base;
    00938   }
    00939
    00940   /// Calls base.setf(ios_base::oct, ios_base::basefield).
    00941   inline ios_base&
    00942   oct(ios_base& __base)
    00943   {
    00944     __base.setf(ios_base::oct, ios_base::basefield);
    00945     return __base;
    00946   }
    00947
    00948   // [27.4.5.4] floatfield anipulators
    00949   /// Calls base.setf(ios_base::fixed, ios_base::floatfield).
    00950   inline ios_base&
    00951   fixed(ios_base& __base)
    00952   {
    00953     __base.setf(ios_base::fixed, ios_base::floatfield);
    00954     return __base;
    00955   }
    00956
    00957   /// Calls base.setf(ios_base::scientific, ios_base::floatfield).
    00958   inline ios_base&
    00959   scientific(ios_base& __base)
    00960   {
    00961     __base.setf(ios_base::scientific, ios_base::floatfield);
    00962     return __base;
    00963   }
    00964
    00965 _GLIBCXX_END_NAMESPACE
    00966
    00967 #endif /* _IOS_BASE_H */
    00968