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

Generated on Fri May 6 01:08:59 2005 for libstdc++-v3 Source by  doxygen 1.4.2