ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

_ios_base.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 1999
00003  * Silicon Graphics Computer Systems, Inc.
00004  *
00005  * Copyright (c) 1999
00006  * Boris Fomitchev
00007  *
00008  * This material is provided "as is", with absolutely no warranty expressed
00009  * or implied. Any use is at your own risk.
00010  *
00011  * Permission to use or copy this software for any purpose is hereby granted
00012  * without fee, provided the above notices are retained on all copies.
00013  * Permission to modify the code and to distribute modified code is granted,
00014  * provided the above notices are retained, and a notice that the code was
00015  * modified is included with the above copyright notice.
00016  *
00017  */
00018 #ifndef _STLP_IOS_BASE_H
00019 #define _STLP_IOS_BASE_H
00020 
00021 #ifndef _STLP_INTERNAL_STDEXCEPT_BASE
00022 #  include <stl/_stdexcept_base.h>
00023 #endif
00024 
00025 #ifndef _STLP_INTERNAL_PAIR_H
00026 #  include <stl/_pair.h>
00027 #endif
00028 
00029 #ifndef _STLP_INTERNAL_LOCALE_H
00030 #  include <stl/_locale.h>
00031 #endif
00032 
00033 #ifndef _STLP_INTERNAL_STRING_H
00034 #  include <stl/_string.h>
00035 #endif
00036 
00037 _STLP_BEGIN_NAMESPACE
00038 
00039 // ----------------------------------------------------------------------
00040 
00041 // Class ios_base.  This is the base class of the ios hierarchy, which
00042 // includes basic_istream and basic_ostream.  Classes in the ios
00043 // hierarchy are actually quite simple: they are just glorified
00044 // wrapper classes.  They delegate buffering and physical character
00045 // manipulation to the streambuf classes, and they delegate most
00046 // formatting tasks to a locale.
00047 
00048 class _STLP_CLASS_DECLSPEC ios_base {
00049 public:
00050 
00051   class _STLP_CLASS_DECLSPEC failure : public __Named_exception {
00052   public:
00053     explicit failure(const string&);
00054     virtual ~failure() _STLP_NOTHROW_INHERENTLY;
00055   };
00056 
00057   typedef int fmtflags;
00058   typedef int iostate;
00059   typedef int openmode;
00060   typedef int seekdir;
00061 
00062 # ifndef _STLP_NO_ANACHRONISMS
00063   typedef fmtflags fmt_flags;
00064 # endif
00065 
00066   // Formatting flags.
00067   _STLP_STATIC_CONSTANT(int, left = 0x0001);
00068   _STLP_STATIC_CONSTANT(int, right = 0x0002);
00069   _STLP_STATIC_CONSTANT(int, internal   = 0x0004);
00070   _STLP_STATIC_CONSTANT(int, dec        = 0x0008);
00071   _STLP_STATIC_CONSTANT(int, hex        = 0x0010);
00072   _STLP_STATIC_CONSTANT(int, oct        = 0x0020);
00073   _STLP_STATIC_CONSTANT(int, fixed      = 0x0040);
00074   _STLP_STATIC_CONSTANT(int, scientific = 0x0080);
00075   _STLP_STATIC_CONSTANT(int, boolalpha  = 0x0100);
00076   _STLP_STATIC_CONSTANT(int, showbase   = 0x0200);
00077   _STLP_STATIC_CONSTANT(int, showpoint  = 0x0400);
00078   _STLP_STATIC_CONSTANT(int, showpos    = 0x0800);
00079   _STLP_STATIC_CONSTANT(int, skipws     = 0x1000);
00080   _STLP_STATIC_CONSTANT(int, unitbuf    = 0x2000);
00081   _STLP_STATIC_CONSTANT(int, uppercase  = 0x4000);
00082   _STLP_STATIC_CONSTANT(int, adjustfield = left | right | internal);
00083   _STLP_STATIC_CONSTANT(int, basefield   = dec | hex | oct);
00084   _STLP_STATIC_CONSTANT(int, floatfield  = scientific | fixed);
00085 
00086   // State flags.
00087   _STLP_STATIC_CONSTANT(int, goodbit = 0x00);
00088   _STLP_STATIC_CONSTANT(int, badbit  = 0x01);
00089   _STLP_STATIC_CONSTANT(int, eofbit  = 0x02);
00090   _STLP_STATIC_CONSTANT(int, failbit = 0x04);
00091 
00092   // Openmode flags.
00093   _STLP_STATIC_CONSTANT(int, __default_mode = 0x0); /* implementation detail */
00094   _STLP_STATIC_CONSTANT(int, app    = 0x01);
00095   _STLP_STATIC_CONSTANT(int, ate    = 0x02);
00096   _STLP_STATIC_CONSTANT(int, binary = 0x04);
00097   _STLP_STATIC_CONSTANT(int, in     = 0x08);
00098   _STLP_STATIC_CONSTANT(int, out    = 0x10);
00099   _STLP_STATIC_CONSTANT(int, trunc  = 0x20);
00100 
00101   // Seekdir flags
00102   _STLP_STATIC_CONSTANT(int, beg = 0x01);
00103   _STLP_STATIC_CONSTANT(int, cur = 0x02);
00104   _STLP_STATIC_CONSTANT(int, end = 0x04);
00105 
00106 public:                         // Flag-manipulation functions.
00107   fmtflags flags() const { return _M_fmtflags; }
00108   fmtflags flags(fmtflags __flags) {
00109     fmtflags __tmp = _M_fmtflags;
00110     _M_fmtflags = __flags;
00111     return __tmp;
00112   }
00113 
00114   fmtflags setf(fmtflags __flag) {
00115     fmtflags __tmp = _M_fmtflags;
00116     _M_fmtflags |= __flag;
00117     return __tmp;
00118   }
00119   fmtflags setf(fmtflags __flag, fmtflags __mask) {
00120     fmtflags __tmp = _M_fmtflags;
00121     _M_fmtflags &= ~__mask;
00122     _M_fmtflags |= __flag & __mask;
00123     return __tmp;
00124   }
00125   void unsetf(fmtflags __mask) { _M_fmtflags &= ~__mask; }
00126 
00127   streamsize precision() const { return _M_precision; }
00128   streamsize precision(streamsize __newprecision) {
00129     streamsize __tmp = _M_precision;
00130     _M_precision = __newprecision;
00131     return __tmp;
00132   }
00133 
00134   streamsize width() const { return _M_width; }
00135   streamsize width(streamsize __newwidth) {
00136     streamsize __tmp = _M_width;
00137     _M_width = __newwidth;
00138     return __tmp;
00139   }
00140 
00141 public:                         // Locales
00142   locale imbue(const locale&);
00143   locale getloc() const { return _M_locale; }
00144 
00145 public:                         // Auxiliary storage.
00146   static int _STLP_CALL xalloc();
00147   long&  iword(int __index);
00148   void*& pword(int __index);
00149 
00150 public:                         // Destructor.
00151   virtual ~ios_base();
00152 
00153 public:                         // Callbacks.
00154   enum event { erase_event, imbue_event, copyfmt_event };
00155   typedef void (*event_callback)(event, ios_base&, int __index);
00156   void register_callback(event_callback __fn, int __index);
00157 
00158 public:                         // This member function affects only
00159                                 // the eight predefined ios objects:
00160                                 // cin, cout, etc.
00161   static bool _STLP_CALL sync_with_stdio(bool __sync = true);
00162 
00163 public:                         // The C++ standard requires only that these
00164                                 // member functions be defined in basic_ios.
00165                                 // We define them in the non-template
00166                                 // base class to avoid code duplication.
00167   operator void*() const { return !fail() ? (void*) __CONST_CAST(ios_base*,this) : (void*) 0; }
00168   bool operator!() const { return fail(); }
00169 
00170   iostate rdstate() const { return _M_iostate; }
00171 
00172   bool good() const { return _M_iostate == 0; }
00173   bool eof() const { return (_M_iostate & eofbit) != 0; }
00174   bool fail() const { return (_M_iostate & (failbit | badbit)) != 0; }
00175   bool bad() const { return (_M_iostate & badbit) != 0; }
00176 
00177 protected:                      // The functional protected interface.
00178 
00179   // Copies the state of __x to *this.  This member function makes it
00180   // possible to implement basic_ios::copyfmt without having to expose
00181   // ios_base's private data members.  Does not copy _M_exception_mask
00182   // or _M_iostate.
00183   void _M_copy_state(const ios_base& __x);
00184 
00185   void _M_setstate_nothrow(iostate __state) { _M_iostate |= __state; }
00186   void _M_clear_nothrow(iostate __state) { _M_iostate = __state; }
00187   iostate _M_get_exception_mask() const { return _M_exception_mask; }
00188   void _M_set_exception_mask(iostate __mask) { _M_exception_mask = __mask; }
00189   void _M_check_exception_mask() {
00190     if (_M_iostate & _M_exception_mask)
00191       _M_throw_failure();
00192   }
00193 
00194   void _M_invoke_callbacks(event);
00195   void _STLP_FUNCTION_THROWS _M_throw_failure();
00196 
00197   ios_base();                   // Default constructor.
00198 
00199 protected:                        // Initialization of the I/O system
00200   static void _STLP_CALL _S_initialize();
00201   static void _STLP_CALL _S_uninitialize();
00202   static bool _S_is_synced;
00203 
00204 private:                        // Invalidate the copy constructor and
00205                                 // assignment operator.
00206   ios_base(const ios_base&);
00207   void operator=(const ios_base&);
00208 
00209 private:                        // Data members.
00210 
00211   fmtflags _M_fmtflags;         // Flags
00212   iostate _M_iostate;
00213   openmode _M_openmode;
00214   seekdir _M_seekdir;
00215   iostate _M_exception_mask;
00216 
00217   streamsize _M_precision;
00218   streamsize _M_width;
00219 
00220   locale _M_locale;
00221 
00222   pair<event_callback, int>* _M_callbacks;
00223   size_t _M_num_callbacks;      // Size of the callback array.
00224   size_t _M_callback_index;     // Index of the next available callback;
00225                                 // initially zero.
00226 
00227   long* _M_iwords;              // Auxiliary storage.  The count is zero
00228   size_t _M_num_iwords;         // if and only if the pointer is null.
00229 
00230   void** _M_pwords;
00231   size_t _M_num_pwords;
00232 
00233 public:
00234   // ----------------------------------------------------------------------
00235   // Nested initializer class.  This is an implementation detail, but it's
00236   // prescribed by the standard.  The static initializer object (on
00237   // implementations where such a thing is required) is declared in
00238   // <iostream>
00239   class _STLP_CLASS_DECLSPEC Init
00240   {
00241     public:
00242       Init();
00243       ~Init();
00244     private:
00245       static long _S_count;
00246       friend class ios_base;
00247   };
00248 
00249   friend class Init;
00250 
00251 public:
00252 # ifndef _STLP_NO_ANACHRONISMS
00253   //  31.6  Old iostreams members                         [depr.ios.members]
00254   typedef iostate  io_state;
00255   typedef openmode open_mode;
00256   typedef seekdir  seek_dir;
00257   typedef _STLP_STD::streamoff  streamoff;
00258   typedef _STLP_STD::streampos  streampos;
00259 # endif
00260 };
00261 
00262 // ----------------------------------------------------------------------
00263 // ios_base manipulator functions, from section 27.4.5 of the C++ standard.
00264 // All of them are trivial one-line wrapper functions.
00265 
00266 // fmtflag manipulators, section 27.4.5.1
00267 inline ios_base& _STLP_CALL boolalpha(ios_base& __s)
00268   { __s.setf(ios_base::boolalpha); return __s;}
00269 
00270 inline ios_base& _STLP_CALL noboolalpha(ios_base& __s)
00271   { __s.unsetf(ios_base::boolalpha); return __s;}
00272 
00273 inline ios_base& _STLP_CALL showbase(ios_base& __s)
00274   { __s.setf(ios_base::showbase); return __s;}
00275 
00276 inline ios_base& _STLP_CALL noshowbase(ios_base& __s)
00277   { __s.unsetf(ios_base::showbase); return __s;}
00278 
00279 inline ios_base& _STLP_CALL showpoint(ios_base& __s)
00280   { __s.setf(ios_base::showpoint); return __s;}
00281 
00282 inline ios_base& _STLP_CALL noshowpoint(ios_base& __s)
00283   { __s.unsetf(ios_base::showpoint); return __s;}
00284 
00285 inline ios_base& _STLP_CALL showpos(ios_base& __s)
00286   { __s.setf(ios_base::showpos); return __s;}
00287 
00288 inline ios_base& _STLP_CALL noshowpos(ios_base& __s)
00289   { __s.unsetf(ios_base::showpos); return __s;}
00290 
00291 inline ios_base& _STLP_CALL skipws(ios_base& __s)
00292   { __s.setf(ios_base::skipws); return __s;}
00293 
00294 inline ios_base& _STLP_CALL noskipws(ios_base& __s)
00295   { __s.unsetf(ios_base::skipws); return __s;}
00296 
00297 inline ios_base& _STLP_CALL uppercase(ios_base& __s)
00298   { __s.setf(ios_base::uppercase); return __s;}
00299 
00300 inline ios_base& _STLP_CALL nouppercase(ios_base& __s)
00301   { __s.unsetf(ios_base::uppercase); return __s;}
00302 
00303 inline ios_base& _STLP_CALL unitbuf(ios_base& __s)
00304   { __s.setf(ios_base::unitbuf); return __s;}
00305 
00306 inline ios_base& _STLP_CALL nounitbuf(ios_base& __s)
00307   { __s.unsetf(ios_base::unitbuf); return __s;}
00308 
00309 
00310 // adjustfield manipulators, section 27.4.5.2
00311 inline ios_base& _STLP_CALL internal(ios_base& __s)
00312   { __s.setf(ios_base::internal, ios_base::adjustfield); return __s; }
00313 
00314 inline ios_base& _STLP_CALL left(ios_base& __s)
00315   { __s.setf(ios_base::left, ios_base::adjustfield); return __s; }
00316 
00317 inline ios_base& _STLP_CALL right(ios_base& __s)
00318   { __s.setf(ios_base::right, ios_base::adjustfield); return __s; }
00319 
00320 // basefield manipulators, section 27.4.5.3
00321 inline ios_base& _STLP_CALL dec(ios_base& __s)
00322   { __s.setf(ios_base::dec, ios_base::basefield); return __s; }
00323 
00324 inline ios_base& _STLP_CALL hex(ios_base& __s)
00325   { __s.setf(ios_base::hex, ios_base::basefield); return __s; }
00326 
00327 inline ios_base& _STLP_CALL oct(ios_base& __s)
00328   { __s.setf(ios_base::oct, ios_base::basefield); return __s; }
00329 
00330 
00331 // floatfield manipulators, section 27.4.5.3
00332 inline ios_base& _STLP_CALL fixed(ios_base& __s)
00333   { __s.setf(ios_base::fixed, ios_base::floatfield); return __s; }
00334 
00335 inline ios_base& _STLP_CALL scientific(ios_base& __s)
00336   { __s.setf(ios_base::scientific, ios_base::floatfield); return __s; }
00337 
00338 _STLP_END_NAMESPACE
00339 
00340 #endif /* _STLP_IOS_BASE */
00341 
00342 // Local Variables:
00343 // mode:C++
00344 // End:
00345 

Generated on Sun May 27 2012 04:29:08 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.