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

Generated on Tue Apr 21 13:13:28 2009 for libstdc++ by  doxygen 1.5.8