epoc32/include/tools/stlport/stl/_ios_base.h
branchSymbian3
changeset 4 837f303aceeb
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/tools/stlport/stl/_ios_base.h	Wed Mar 31 12:33:34 2010 +0100
     1.3 @@ -0,0 +1,368 @@
     1.4 +/*
     1.5 + * Copyright (c) 1999
     1.6 + * Silicon Graphics Computer Systems, Inc.
     1.7 + *
     1.8 + * Copyright (c) 1999
     1.9 + * Boris Fomitchev
    1.10 + *
    1.11 + * This material is provided "as is", with absolutely no warranty expressed
    1.12 + * or implied. Any use is at your own risk.
    1.13 + *
    1.14 + * Permission to use or copy this software for any purpose is hereby granted
    1.15 + * without fee, provided the above notices are retained on all copies.
    1.16 + * Permission to modify the code and to distribute modified code is granted,
    1.17 + * provided the above notices are retained, and a notice that the code was
    1.18 + * modified is included with the above copyright notice.
    1.19 + *
    1.20 + */
    1.21 +#ifndef _STLP_IOS_BASE_H
    1.22 +#define _STLP_IOS_BASE_H
    1.23 +
    1.24 +#ifndef _STLP_INTERNAL_STDEXCEPT_BASE
    1.25 +#  include <stl/_stdexcept_base.h>
    1.26 +#endif
    1.27 +
    1.28 +#ifndef _STLP_UTILITY
    1.29 +#  include <utility>
    1.30 +#endif
    1.31 +
    1.32 +#ifndef _STLP_INTERNAL_LOCALE_H
    1.33 +#  include <stl/_locale.h>
    1.34 +#endif
    1.35 +
    1.36 +#ifndef _STLP_INTERNAL_STRING_H
    1.37 +#  include <stl/_string.h>
    1.38 +#endif
    1.39 +
    1.40 +_STLP_BEGIN_NAMESPACE
    1.41 +
    1.42 +// ----------------------------------------------------------------------
    1.43 +
    1.44 +// Class ios_base.  This is the base class of the ios hierarchy, which
    1.45 +// includes basic_istream and basic_ostream.  Classes in the ios
    1.46 +// hierarchy are actually quite simple: they are just glorified
    1.47 +// wrapper classes.  They delegate buffering and physical character
    1.48 +// manipulation to the streambuf classes, and they delegate most
    1.49 +// formatting tasks to a locale.
    1.50 +
    1.51 +class _STLP_CLASS_DECLSPEC ios_base {
    1.52 +public:
    1.53 +
    1.54 +  class _STLP_CLASS_DECLSPEC failure : public __Named_exception {
    1.55 +  public:
    1.56 +    explicit failure(const string&);
    1.57 +    virtual ~failure() _STLP_NOTHROW_INHERENTLY;
    1.58 +  };
    1.59 +
    1.60 +  typedef int fmtflags;
    1.61 +  typedef int iostate;
    1.62 +  typedef int openmode;
    1.63 +  typedef int seekdir;
    1.64 +
    1.65 +# ifndef _STLP_NO_ANACHRONISMS
    1.66 +  typedef fmtflags fmt_flags;
    1.67 +# endif
    1.68 +
    1.69 +  // Formatting flags.
    1.70 +#if defined (_STLP_STATIC_CONST_INIT_BUG)
    1.71 +  enum  {
    1.72 +#else
    1.73 +  // boris : type for all those constants is int
    1.74 +  static const int
    1.75 +#endif
    1.76 +    left       = 0x0001,
    1.77 +    right      = 0x0002,
    1.78 +    internal   = 0x0004,
    1.79 +    dec        = 0x0008,
    1.80 +    hex        = 0x0010,
    1.81 +    oct        = 0x0020,
    1.82 +    fixed      = 0x0040,
    1.83 +    scientific = 0x0080,
    1.84 +    boolalpha  = 0x0100,
    1.85 +    showbase   = 0x0200,
    1.86 +    showpoint  = 0x0400,
    1.87 +    showpos    = 0x0800,
    1.88 +    skipws     = 0x1000,
    1.89 +    unitbuf    = 0x2000,
    1.90 +    uppercase  = 0x4000,
    1.91 +    adjustfield = left | right | internal,
    1.92 +    basefield   = dec | hex | oct,
    1.93 +    floatfield  = scientific | fixed,
    1.94 +
    1.95 +    // State flags.
    1.96 +    goodbit = 0x00,
    1.97 +    badbit  = 0x01,
    1.98 +    eofbit  = 0x02,
    1.99 +    failbit = 0x04,
   1.100 +
   1.101 +    // Openmode flags.
   1.102 +    __default_mode = 0x0, /* implementation detail */
   1.103 +    app    = 0x01,
   1.104 +    ate    = 0x02,
   1.105 +    binary = 0x04,
   1.106 +    in     = 0x08,
   1.107 +    out    = 0x10,
   1.108 +    trunc  = 0x20,
   1.109 +
   1.110 +    // Seekdir flags
   1.111 +
   1.112 +    beg = 0x01,
   1.113 +    cur = 0x02,
   1.114 +    end = 0x04
   1.115 +# ifdef _STLP_STATIC_CONST_INIT_BUG
   1.116 +  }
   1.117 +# endif
   1.118 +  ;
   1.119 +
   1.120 +public:                         // Flag-manipulation functions.
   1.121 +  fmtflags flags() const { return _M_fmtflags; }
   1.122 +  fmtflags flags(fmtflags __flags) {
   1.123 +    fmtflags __tmp = _M_fmtflags;
   1.124 +    _M_fmtflags = __flags;
   1.125 +    return __tmp;
   1.126 +  }
   1.127 +
   1.128 +  fmtflags setf(fmtflags __flag) {
   1.129 +    fmtflags __tmp = _M_fmtflags;
   1.130 +    _M_fmtflags |= __flag;
   1.131 +    return __tmp;
   1.132 +  }
   1.133 +  fmtflags setf(fmtflags __flag, fmtflags __mask) {
   1.134 +    fmtflags __tmp = _M_fmtflags;
   1.135 +    _M_fmtflags &= ~__mask;
   1.136 +    _M_fmtflags |= __flag & __mask;
   1.137 +    return __tmp;
   1.138 +  }
   1.139 +  void unsetf(fmtflags __mask) { _M_fmtflags &= ~__mask; }
   1.140 +
   1.141 +  streamsize precision() const { return _M_precision; }
   1.142 +  streamsize precision(streamsize __newprecision) {
   1.143 +    streamsize __tmp = _M_precision;
   1.144 +    _M_precision = __newprecision;
   1.145 +    return __tmp;
   1.146 +  }
   1.147 +
   1.148 +  streamsize width() const { return _M_width; }
   1.149 +  streamsize width(streamsize __newwidth) {
   1.150 +    streamsize __tmp = _M_width;
   1.151 +    _M_width = __newwidth;
   1.152 +    return __tmp;
   1.153 +  }
   1.154 +
   1.155 +public:                         // Locales
   1.156 +  locale imbue(const locale&);
   1.157 +  locale getloc() const { return _M_locale; }
   1.158 +
   1.159 +public:                         // Auxiliary storage.
   1.160 +  static int _STLP_CALL xalloc();
   1.161 +  long&  iword(int __index);
   1.162 +  void*& pword(int __index);
   1.163 +
   1.164 +public:                         // Destructor.
   1.165 +  virtual ~ios_base();
   1.166 +
   1.167 +public:                         // Callbacks.
   1.168 +  enum event { erase_event, imbue_event, copyfmt_event };
   1.169 +  typedef void (*event_callback)(event, ios_base&, int __index);
   1.170 +  void register_callback(event_callback __fn, int __index);
   1.171 +
   1.172 +public:                         // This member function affects only
   1.173 +                                // the eight predefined ios objects:
   1.174 +                                // cin, cout, etc.
   1.175 +  static bool _STLP_CALL sync_with_stdio(bool __sync = true);
   1.176 +
   1.177 +public:                         // The C++ standard requires only that these
   1.178 +                                // member functions be defined in basic_ios.
   1.179 +                                // We define them in the non-template
   1.180 +                                // base class to avoid code duplication.
   1.181 +  operator void*() const { return !fail() ? (void*) __CONST_CAST(ios_base*,this) : (void*) 0; }
   1.182 +  bool operator!() const { return fail(); }
   1.183 +
   1.184 +  iostate rdstate() const { return _M_iostate; }
   1.185 +
   1.186 +  bool good() const { return _M_iostate == 0; }
   1.187 +  bool eof() const { return (_M_iostate & eofbit) != 0; }
   1.188 +  bool fail() const { return (_M_iostate & (failbit | badbit)) != 0; }
   1.189 +  bool bad() const { return (_M_iostate & badbit) != 0; }
   1.190 +
   1.191 +protected:                      // The functional protected interface.
   1.192 +
   1.193 +  // Copies the state of __x to *this.  This member function makes it
   1.194 +  // possible to implement basic_ios::copyfmt without having to expose
   1.195 +  // ios_base's private data members.  Does not copy _M_exception_mask
   1.196 +  // or _M_iostate.
   1.197 +  void _M_copy_state(const ios_base& __x);
   1.198 +
   1.199 +  void _M_setstate_nothrow(iostate __state) { _M_iostate |= __state; }
   1.200 +  void _M_clear_nothrow(iostate __state) { _M_iostate = __state; }
   1.201 +  iostate _M_get_exception_mask() const { return _M_exception_mask; }
   1.202 +  void _M_set_exception_mask(iostate __mask) { _M_exception_mask = __mask; }
   1.203 +  void _M_check_exception_mask() {
   1.204 +    if (_M_iostate & _M_exception_mask)
   1.205 +      _M_throw_failure();
   1.206 +  }
   1.207 +
   1.208 +  void _M_invoke_callbacks(event);
   1.209 +  void _STLP_FUNCTION_THROWS _M_throw_failure();
   1.210 +
   1.211 +  ios_base();                   // Default constructor.
   1.212 +
   1.213 +protected:                        // Initialization of the I/O system
   1.214 +  static void _STLP_CALL _S_initialize();
   1.215 +  static void _STLP_CALL _S_uninitialize();
   1.216 +  static bool _S_was_synced;
   1.217 +
   1.218 +private:                        // Invalidate the copy constructor and
   1.219 +                                // assignment operator.
   1.220 +  ios_base(const ios_base&);
   1.221 +  void operator=(const ios_base&);
   1.222 +
   1.223 +private:                        // Data members.
   1.224 +
   1.225 +  fmtflags _M_fmtflags;         // Flags
   1.226 +  iostate _M_iostate;
   1.227 +  openmode _M_openmode;
   1.228 +  seekdir _M_seekdir;
   1.229 +  iostate _M_exception_mask;
   1.230 +
   1.231 +  streamsize _M_precision;
   1.232 +  streamsize _M_width;
   1.233 +
   1.234 +  locale _M_locale;
   1.235 +
   1.236 +  pair<event_callback, int>* _M_callbacks;
   1.237 +  size_t _M_num_callbacks;      // Size of the callback array.
   1.238 +  size_t _M_callback_index;     // Index of the next available callback;
   1.239 +                                // initially zero.
   1.240 +
   1.241 +  long* _M_iwords;              // Auxiliary storage.  The count is zero
   1.242 +  size_t _M_num_iwords;         // if and only if the pointer is null.
   1.243 +
   1.244 +  void** _M_pwords;
   1.245 +  size_t _M_num_pwords;
   1.246 +
   1.247 +protected:
   1.248 +  // Cached copies of the curent locale's facets.  Set by init() and imbue().
   1.249 +  locale::facet* _M_cached_ctype;
   1.250 +  locale::facet* _M_cached_numpunct;
   1.251 +  string         _M_cached_grouping;
   1.252 +public:
   1.253 +  // Equivalent to &use_facet< Facet >(getloc()), but faster.
   1.254 +  const locale::facet* _M_ctype_facet() const { return _M_cached_ctype; }
   1.255 +  const locale::facet* _M_numpunct_facet() const { return _M_cached_numpunct; }
   1.256 +  const string&  _M_grouping() const { return _M_cached_grouping; }
   1.257 +public:
   1.258 +
   1.259 +  // ----------------------------------------------------------------------
   1.260 +  // Nested initializer class.  This is an implementation detail, but it's
   1.261 +  // prescribed by the standard.  The static initializer object (on
   1.262 +  // implementations where such a thing is required) is declared in
   1.263 +  // <iostream>
   1.264 +
   1.265 +  class _STLP_CLASS_DECLSPEC Init
   1.266 +  {
   1.267 +    public:
   1.268 +      Init();
   1.269 +      ~Init();
   1.270 +    private:
   1.271 +      static long _S_count;
   1.272 +      friend class ios_base;
   1.273 +  };
   1.274 +
   1.275 +  friend class Init;
   1.276 +
   1.277 +public:
   1.278 +# ifndef _STLP_NO_ANACHRONISMS
   1.279 +  //  31.6  Old iostreams members                         [depr.ios.members]
   1.280 +  typedef iostate  io_state;
   1.281 +  typedef openmode open_mode;
   1.282 +  typedef seekdir  seek_dir;
   1.283 +  typedef _STLP_STD::streamoff  streamoff;
   1.284 +  typedef _STLP_STD::streampos  streampos;
   1.285 +# endif
   1.286 +};
   1.287 +
   1.288 +// ----------------------------------------------------------------------
   1.289 +// ios_base manipulator functions, from section 27.4.5 of the C++ standard.
   1.290 +// All of them are trivial one-line wrapper functions.
   1.291 +
   1.292 +// fmtflag manipulators, section 27.4.5.1
   1.293 +inline ios_base& _STLP_CALL boolalpha(ios_base& __s)
   1.294 +  { __s.setf(ios_base::boolalpha); return __s;}
   1.295 +
   1.296 +inline ios_base& _STLP_CALL noboolalpha(ios_base& __s)
   1.297 +  { __s.unsetf(ios_base::boolalpha); return __s;}
   1.298 +
   1.299 +inline ios_base& _STLP_CALL showbase(ios_base& __s)
   1.300 +  { __s.setf(ios_base::showbase); return __s;}
   1.301 +
   1.302 +inline ios_base& _STLP_CALL noshowbase(ios_base& __s)
   1.303 +  { __s.unsetf(ios_base::showbase); return __s;}
   1.304 +
   1.305 +inline ios_base& _STLP_CALL showpoint(ios_base& __s)
   1.306 +  { __s.setf(ios_base::showpoint); return __s;}
   1.307 +
   1.308 +inline ios_base& _STLP_CALL noshowpoint(ios_base& __s)
   1.309 +  { __s.unsetf(ios_base::showpoint); return __s;}
   1.310 +
   1.311 +inline ios_base& _STLP_CALL showpos(ios_base& __s)
   1.312 +  { __s.setf(ios_base::showpos); return __s;}
   1.313 +
   1.314 +inline ios_base& _STLP_CALL noshowpos(ios_base& __s)
   1.315 +  { __s.unsetf(ios_base::showpos); return __s;}
   1.316 +
   1.317 +inline ios_base& _STLP_CALL skipws(ios_base& __s)
   1.318 +  { __s.setf(ios_base::skipws); return __s;}
   1.319 +
   1.320 +inline ios_base& _STLP_CALL noskipws(ios_base& __s)
   1.321 +  { __s.unsetf(ios_base::skipws); return __s;}
   1.322 +
   1.323 +inline ios_base& _STLP_CALL uppercase(ios_base& __s)
   1.324 +  { __s.setf(ios_base::uppercase); return __s;}
   1.325 +
   1.326 +inline ios_base& _STLP_CALL nouppercase(ios_base& __s)
   1.327 +  { __s.unsetf(ios_base::uppercase); return __s;}
   1.328 +
   1.329 +inline ios_base& _STLP_CALL unitbuf(ios_base& __s)
   1.330 +  { __s.setf(ios_base::unitbuf); return __s;}
   1.331 +
   1.332 +inline ios_base& _STLP_CALL nounitbuf(ios_base& __s)
   1.333 +  { __s.unsetf(ios_base::unitbuf); return __s;}
   1.334 +
   1.335 +
   1.336 +// adjustfield manipulators, section 27.4.5.2
   1.337 +inline ios_base& _STLP_CALL internal(ios_base& __s)
   1.338 +  { __s.setf(ios_base::internal, ios_base::adjustfield); return __s; }
   1.339 +
   1.340 +inline ios_base& _STLP_CALL left(ios_base& __s)
   1.341 +  { __s.setf(ios_base::left, ios_base::adjustfield); return __s; }
   1.342 +
   1.343 +inline ios_base& _STLP_CALL right(ios_base& __s)
   1.344 +  { __s.setf(ios_base::right, ios_base::adjustfield); return __s; }
   1.345 +
   1.346 +// basefield manipulators, section 27.4.5.3
   1.347 +inline ios_base& _STLP_CALL dec(ios_base& __s)
   1.348 +  { __s.setf(ios_base::dec, ios_base::basefield); return __s; }
   1.349 +
   1.350 +inline ios_base& _STLP_CALL hex(ios_base& __s)
   1.351 +  { __s.setf(ios_base::hex, ios_base::basefield); return __s; }
   1.352 +
   1.353 +inline ios_base& _STLP_CALL oct(ios_base& __s)
   1.354 +  { __s.setf(ios_base::oct, ios_base::basefield); return __s; }
   1.355 +
   1.356 +
   1.357 +// floatfield manipulators, section 27.4.5.3
   1.358 +inline ios_base& _STLP_CALL fixed(ios_base& __s)
   1.359 +  { __s.setf(ios_base::fixed, ios_base::floatfield); return __s; }
   1.360 +
   1.361 +inline ios_base& _STLP_CALL scientific(ios_base& __s)
   1.362 +  { __s.setf(ios_base::scientific, ios_base::floatfield); return __s; }
   1.363 +
   1.364 +_STLP_END_NAMESPACE
   1.365 +
   1.366 +#endif /* _STLP_IOS_BASE */
   1.367 +
   1.368 +// Local Variables:
   1.369 +// mode:C++
   1.370 +// End:
   1.371 +