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