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