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