epoc32/include/tools/stlport/stl/_ios_base.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
williamr@4
     1
/*
williamr@4
     2
 * Copyright (c) 1999
williamr@4
     3
 * Silicon Graphics Computer Systems, Inc.
williamr@4
     4
 *
williamr@4
     5
 * Copyright (c) 1999
williamr@4
     6
 * Boris Fomitchev
williamr@4
     7
 *
williamr@4
     8
 * This material is provided "as is", with absolutely no warranty expressed
williamr@4
     9
 * or implied. Any use is at your own risk.
williamr@4
    10
 *
williamr@4
    11
 * Permission to use or copy this software for any purpose is hereby granted
williamr@4
    12
 * without fee, provided the above notices are retained on all copies.
williamr@4
    13
 * Permission to modify the code and to distribute modified code is granted,
williamr@4
    14
 * provided the above notices are retained, and a notice that the code was
williamr@4
    15
 * modified is included with the above copyright notice.
williamr@4
    16
 *
williamr@4
    17
 */
williamr@4
    18
#ifndef _STLP_IOS_BASE_H
williamr@4
    19
#define _STLP_IOS_BASE_H
williamr@4
    20
williamr@4
    21
#ifndef _STLP_INTERNAL_STDEXCEPT_BASE
williamr@4
    22
#  include <stl/_stdexcept_base.h>
williamr@4
    23
#endif
williamr@4
    24
williamr@4
    25
#ifndef _STLP_UTILITY
williamr@4
    26
#  include <utility>
williamr@4
    27
#endif
williamr@4
    28
williamr@4
    29
#ifndef _STLP_INTERNAL_LOCALE_H
williamr@4
    30
#  include <stl/_locale.h>
williamr@4
    31
#endif
williamr@4
    32
williamr@4
    33
#ifndef _STLP_INTERNAL_STRING_H
williamr@4
    34
#  include <stl/_string.h>
williamr@4
    35
#endif
williamr@4
    36
williamr@4
    37
_STLP_BEGIN_NAMESPACE
williamr@4
    38
williamr@4
    39
// ----------------------------------------------------------------------
williamr@4
    40
williamr@4
    41
// Class ios_base.  This is the base class of the ios hierarchy, which
williamr@4
    42
// includes basic_istream and basic_ostream.  Classes in the ios
williamr@4
    43
// hierarchy are actually quite simple: they are just glorified
williamr@4
    44
// wrapper classes.  They delegate buffering and physical character
williamr@4
    45
// manipulation to the streambuf classes, and they delegate most
williamr@4
    46
// formatting tasks to a locale.
williamr@4
    47
williamr@4
    48
class _STLP_CLASS_DECLSPEC ios_base {
williamr@4
    49
public:
williamr@4
    50
williamr@4
    51
  class _STLP_CLASS_DECLSPEC failure : public __Named_exception {
williamr@4
    52
  public:
williamr@4
    53
    explicit failure(const string&);
williamr@4
    54
    virtual ~failure() _STLP_NOTHROW_INHERENTLY;
williamr@4
    55
  };
williamr@4
    56
williamr@4
    57
  typedef int fmtflags;
williamr@4
    58
  typedef int iostate;
williamr@4
    59
  typedef int openmode;
williamr@4
    60
  typedef int seekdir;
williamr@4
    61
williamr@4
    62
# ifndef _STLP_NO_ANACHRONISMS
williamr@4
    63
  typedef fmtflags fmt_flags;
williamr@4
    64
# endif
williamr@4
    65
williamr@4
    66
  // Formatting flags.
williamr@4
    67
#if defined (_STLP_STATIC_CONST_INIT_BUG)
williamr@4
    68
  enum  {
williamr@4
    69
#else
williamr@4
    70
  // boris : type for all those constants is int
williamr@4
    71
  static const int
williamr@4
    72
#endif
williamr@4
    73
    left       = 0x0001,
williamr@4
    74
    right      = 0x0002,
williamr@4
    75
    internal   = 0x0004,
williamr@4
    76
    dec        = 0x0008,
williamr@4
    77
    hex        = 0x0010,
williamr@4
    78
    oct        = 0x0020,
williamr@4
    79
    fixed      = 0x0040,
williamr@4
    80
    scientific = 0x0080,
williamr@4
    81
    boolalpha  = 0x0100,
williamr@4
    82
    showbase   = 0x0200,
williamr@4
    83
    showpoint  = 0x0400,
williamr@4
    84
    showpos    = 0x0800,
williamr@4
    85
    skipws     = 0x1000,
williamr@4
    86
    unitbuf    = 0x2000,
williamr@4
    87
    uppercase  = 0x4000,
williamr@4
    88
    adjustfield = left | right | internal,
williamr@4
    89
    basefield   = dec | hex | oct,
williamr@4
    90
    floatfield  = scientific | fixed,
williamr@4
    91
williamr@4
    92
    // State flags.
williamr@4
    93
    goodbit = 0x00,
williamr@4
    94
    badbit  = 0x01,
williamr@4
    95
    eofbit  = 0x02,
williamr@4
    96
    failbit = 0x04,
williamr@4
    97
williamr@4
    98
    // Openmode flags.
williamr@4
    99
    __default_mode = 0x0, /* implementation detail */
williamr@4
   100
    app    = 0x01,
williamr@4
   101
    ate    = 0x02,
williamr@4
   102
    binary = 0x04,
williamr@4
   103
    in     = 0x08,
williamr@4
   104
    out    = 0x10,
williamr@4
   105
    trunc  = 0x20,
williamr@4
   106
williamr@4
   107
    // Seekdir flags
williamr@4
   108
williamr@4
   109
    beg = 0x01,
williamr@4
   110
    cur = 0x02,
williamr@4
   111
    end = 0x04
williamr@4
   112
# ifdef _STLP_STATIC_CONST_INIT_BUG
williamr@4
   113
  }
williamr@4
   114
# endif
williamr@4
   115
  ;
williamr@4
   116
williamr@4
   117
public:                         // Flag-manipulation functions.
williamr@4
   118
  fmtflags flags() const { return _M_fmtflags; }
williamr@4
   119
  fmtflags flags(fmtflags __flags) {
williamr@4
   120
    fmtflags __tmp = _M_fmtflags;
williamr@4
   121
    _M_fmtflags = __flags;
williamr@4
   122
    return __tmp;
williamr@4
   123
  }
williamr@4
   124
williamr@4
   125
  fmtflags setf(fmtflags __flag) {
williamr@4
   126
    fmtflags __tmp = _M_fmtflags;
williamr@4
   127
    _M_fmtflags |= __flag;
williamr@4
   128
    return __tmp;
williamr@4
   129
  }
williamr@4
   130
  fmtflags setf(fmtflags __flag, fmtflags __mask) {
williamr@4
   131
    fmtflags __tmp = _M_fmtflags;
williamr@4
   132
    _M_fmtflags &= ~__mask;
williamr@4
   133
    _M_fmtflags |= __flag & __mask;
williamr@4
   134
    return __tmp;
williamr@4
   135
  }
williamr@4
   136
  void unsetf(fmtflags __mask) { _M_fmtflags &= ~__mask; }
williamr@4
   137
williamr@4
   138
  streamsize precision() const { return _M_precision; }
williamr@4
   139
  streamsize precision(streamsize __newprecision) {
williamr@4
   140
    streamsize __tmp = _M_precision;
williamr@4
   141
    _M_precision = __newprecision;
williamr@4
   142
    return __tmp;
williamr@4
   143
  }
williamr@4
   144
williamr@4
   145
  streamsize width() const { return _M_width; }
williamr@4
   146
  streamsize width(streamsize __newwidth) {
williamr@4
   147
    streamsize __tmp = _M_width;
williamr@4
   148
    _M_width = __newwidth;
williamr@4
   149
    return __tmp;
williamr@4
   150
  }
williamr@4
   151
williamr@4
   152
public:                         // Locales
williamr@4
   153
  locale imbue(const locale&);
williamr@4
   154
  locale getloc() const { return _M_locale; }
williamr@4
   155
williamr@4
   156
public:                         // Auxiliary storage.
williamr@4
   157
  static int _STLP_CALL xalloc();
williamr@4
   158
  long&  iword(int __index);
williamr@4
   159
  void*& pword(int __index);
williamr@4
   160
williamr@4
   161
public:                         // Destructor.
williamr@4
   162
  virtual ~ios_base();
williamr@4
   163
williamr@4
   164
public:                         // Callbacks.
williamr@4
   165
  enum event { erase_event, imbue_event, copyfmt_event };
williamr@4
   166
  typedef void (*event_callback)(event, ios_base&, int __index);
williamr@4
   167
  void register_callback(event_callback __fn, int __index);
williamr@4
   168
williamr@4
   169
public:                         // This member function affects only
williamr@4
   170
                                // the eight predefined ios objects:
williamr@4
   171
                                // cin, cout, etc.
williamr@4
   172
  static bool _STLP_CALL sync_with_stdio(bool __sync = true);
williamr@4
   173
williamr@4
   174
public:                         // The C++ standard requires only that these
williamr@4
   175
                                // member functions be defined in basic_ios.
williamr@4
   176
                                // We define them in the non-template
williamr@4
   177
                                // base class to avoid code duplication.
williamr@4
   178
  operator void*() const { return !fail() ? (void*) __CONST_CAST(ios_base*,this) : (void*) 0; }
williamr@4
   179
  bool operator!() const { return fail(); }
williamr@4
   180
williamr@4
   181
  iostate rdstate() const { return _M_iostate; }
williamr@4
   182
williamr@4
   183
  bool good() const { return _M_iostate == 0; }
williamr@4
   184
  bool eof() const { return (_M_iostate & eofbit) != 0; }
williamr@4
   185
  bool fail() const { return (_M_iostate & (failbit | badbit)) != 0; }
williamr@4
   186
  bool bad() const { return (_M_iostate & badbit) != 0; }
williamr@4
   187
williamr@4
   188
protected:                      // The functional protected interface.
williamr@4
   189
williamr@4
   190
  // Copies the state of __x to *this.  This member function makes it
williamr@4
   191
  // possible to implement basic_ios::copyfmt without having to expose
williamr@4
   192
  // ios_base's private data members.  Does not copy _M_exception_mask
williamr@4
   193
  // or _M_iostate.
williamr@4
   194
  void _M_copy_state(const ios_base& __x);
williamr@4
   195
williamr@4
   196
  void _M_setstate_nothrow(iostate __state) { _M_iostate |= __state; }
williamr@4
   197
  void _M_clear_nothrow(iostate __state) { _M_iostate = __state; }
williamr@4
   198
  iostate _M_get_exception_mask() const { return _M_exception_mask; }
williamr@4
   199
  void _M_set_exception_mask(iostate __mask) { _M_exception_mask = __mask; }
williamr@4
   200
  void _M_check_exception_mask() {
williamr@4
   201
    if (_M_iostate & _M_exception_mask)
williamr@4
   202
      _M_throw_failure();
williamr@4
   203
  }
williamr@4
   204
williamr@4
   205
  void _M_invoke_callbacks(event);
williamr@4
   206
  void _STLP_FUNCTION_THROWS _M_throw_failure();
williamr@4
   207
williamr@4
   208
  ios_base();                   // Default constructor.
williamr@4
   209
williamr@4
   210
protected:                        // Initialization of the I/O system
williamr@4
   211
  static void _STLP_CALL _S_initialize();
williamr@4
   212
  static void _STLP_CALL _S_uninitialize();
williamr@4
   213
  static bool _S_was_synced;
williamr@4
   214
williamr@4
   215
private:                        // Invalidate the copy constructor and
williamr@4
   216
                                // assignment operator.
williamr@4
   217
  ios_base(const ios_base&);
williamr@4
   218
  void operator=(const ios_base&);
williamr@4
   219
williamr@4
   220
private:                        // Data members.
williamr@4
   221
williamr@4
   222
  fmtflags _M_fmtflags;         // Flags
williamr@4
   223
  iostate _M_iostate;
williamr@4
   224
  openmode _M_openmode;
williamr@4
   225
  seekdir _M_seekdir;
williamr@4
   226
  iostate _M_exception_mask;
williamr@4
   227
williamr@4
   228
  streamsize _M_precision;
williamr@4
   229
  streamsize _M_width;
williamr@4
   230
williamr@4
   231
  locale _M_locale;
williamr@4
   232
williamr@4
   233
  pair<event_callback, int>* _M_callbacks;
williamr@4
   234
  size_t _M_num_callbacks;      // Size of the callback array.
williamr@4
   235
  size_t _M_callback_index;     // Index of the next available callback;
williamr@4
   236
                                // initially zero.
williamr@4
   237
williamr@4
   238
  long* _M_iwords;              // Auxiliary storage.  The count is zero
williamr@4
   239
  size_t _M_num_iwords;         // if and only if the pointer is null.
williamr@4
   240
williamr@4
   241
  void** _M_pwords;
williamr@4
   242
  size_t _M_num_pwords;
williamr@4
   243
williamr@4
   244
protected:
williamr@4
   245
  // Cached copies of the curent locale's facets.  Set by init() and imbue().
williamr@4
   246
  locale::facet* _M_cached_ctype;
williamr@4
   247
  locale::facet* _M_cached_numpunct;
williamr@4
   248
  string         _M_cached_grouping;
williamr@4
   249
public:
williamr@4
   250
  // Equivalent to &use_facet< Facet >(getloc()), but faster.
williamr@4
   251
  const locale::facet* _M_ctype_facet() const { return _M_cached_ctype; }
williamr@4
   252
  const locale::facet* _M_numpunct_facet() const { return _M_cached_numpunct; }
williamr@4
   253
  const string&  _M_grouping() const { return _M_cached_grouping; }
williamr@4
   254
public:
williamr@4
   255
williamr@4
   256
  // ----------------------------------------------------------------------
williamr@4
   257
  // Nested initializer class.  This is an implementation detail, but it's
williamr@4
   258
  // prescribed by the standard.  The static initializer object (on
williamr@4
   259
  // implementations where such a thing is required) is declared in
williamr@4
   260
  // <iostream>
williamr@4
   261
williamr@4
   262
  class _STLP_CLASS_DECLSPEC Init
williamr@4
   263
  {
williamr@4
   264
    public:
williamr@4
   265
      Init();
williamr@4
   266
      ~Init();
williamr@4
   267
    private:
williamr@4
   268
      static long _S_count;
williamr@4
   269
      friend class ios_base;
williamr@4
   270
  };
williamr@4
   271
williamr@4
   272
  friend class Init;
williamr@4
   273
williamr@4
   274
public:
williamr@4
   275
# ifndef _STLP_NO_ANACHRONISMS
williamr@4
   276
  //  31.6  Old iostreams members                         [depr.ios.members]
williamr@4
   277
  typedef iostate  io_state;
williamr@4
   278
  typedef openmode open_mode;
williamr@4
   279
  typedef seekdir  seek_dir;
williamr@4
   280
  typedef _STLP_STD::streamoff  streamoff;
williamr@4
   281
  typedef _STLP_STD::streampos  streampos;
williamr@4
   282
# endif
williamr@4
   283
};
williamr@4
   284
williamr@4
   285
// ----------------------------------------------------------------------
williamr@4
   286
// ios_base manipulator functions, from section 27.4.5 of the C++ standard.
williamr@4
   287
// All of them are trivial one-line wrapper functions.
williamr@4
   288
williamr@4
   289
// fmtflag manipulators, section 27.4.5.1
williamr@4
   290
inline ios_base& _STLP_CALL boolalpha(ios_base& __s)
williamr@4
   291
  { __s.setf(ios_base::boolalpha); return __s;}
williamr@4
   292
williamr@4
   293
inline ios_base& _STLP_CALL noboolalpha(ios_base& __s)
williamr@4
   294
  { __s.unsetf(ios_base::boolalpha); return __s;}
williamr@4
   295
williamr@4
   296
inline ios_base& _STLP_CALL showbase(ios_base& __s)
williamr@4
   297
  { __s.setf(ios_base::showbase); return __s;}
williamr@4
   298
williamr@4
   299
inline ios_base& _STLP_CALL noshowbase(ios_base& __s)
williamr@4
   300
  { __s.unsetf(ios_base::showbase); return __s;}
williamr@4
   301
williamr@4
   302
inline ios_base& _STLP_CALL showpoint(ios_base& __s)
williamr@4
   303
  { __s.setf(ios_base::showpoint); return __s;}
williamr@4
   304
williamr@4
   305
inline ios_base& _STLP_CALL noshowpoint(ios_base& __s)
williamr@4
   306
  { __s.unsetf(ios_base::showpoint); return __s;}
williamr@4
   307
williamr@4
   308
inline ios_base& _STLP_CALL showpos(ios_base& __s)
williamr@4
   309
  { __s.setf(ios_base::showpos); return __s;}
williamr@4
   310
williamr@4
   311
inline ios_base& _STLP_CALL noshowpos(ios_base& __s)
williamr@4
   312
  { __s.unsetf(ios_base::showpos); return __s;}
williamr@4
   313
williamr@4
   314
inline ios_base& _STLP_CALL skipws(ios_base& __s)
williamr@4
   315
  { __s.setf(ios_base::skipws); return __s;}
williamr@4
   316
williamr@4
   317
inline ios_base& _STLP_CALL noskipws(ios_base& __s)
williamr@4
   318
  { __s.unsetf(ios_base::skipws); return __s;}
williamr@4
   319
williamr@4
   320
inline ios_base& _STLP_CALL uppercase(ios_base& __s)
williamr@4
   321
  { __s.setf(ios_base::uppercase); return __s;}
williamr@4
   322
williamr@4
   323
inline ios_base& _STLP_CALL nouppercase(ios_base& __s)
williamr@4
   324
  { __s.unsetf(ios_base::uppercase); return __s;}
williamr@4
   325
williamr@4
   326
inline ios_base& _STLP_CALL unitbuf(ios_base& __s)
williamr@4
   327
  { __s.setf(ios_base::unitbuf); return __s;}
williamr@4
   328
williamr@4
   329
inline ios_base& _STLP_CALL nounitbuf(ios_base& __s)
williamr@4
   330
  { __s.unsetf(ios_base::unitbuf); return __s;}
williamr@4
   331
williamr@4
   332
williamr@4
   333
// adjustfield manipulators, section 27.4.5.2
williamr@4
   334
inline ios_base& _STLP_CALL internal(ios_base& __s)
williamr@4
   335
  { __s.setf(ios_base::internal, ios_base::adjustfield); return __s; }
williamr@4
   336
williamr@4
   337
inline ios_base& _STLP_CALL left(ios_base& __s)
williamr@4
   338
  { __s.setf(ios_base::left, ios_base::adjustfield); return __s; }
williamr@4
   339
williamr@4
   340
inline ios_base& _STLP_CALL right(ios_base& __s)
williamr@4
   341
  { __s.setf(ios_base::right, ios_base::adjustfield); return __s; }
williamr@4
   342
williamr@4
   343
// basefield manipulators, section 27.4.5.3
williamr@4
   344
inline ios_base& _STLP_CALL dec(ios_base& __s)
williamr@4
   345
  { __s.setf(ios_base::dec, ios_base::basefield); return __s; }
williamr@4
   346
williamr@4
   347
inline ios_base& _STLP_CALL hex(ios_base& __s)
williamr@4
   348
  { __s.setf(ios_base::hex, ios_base::basefield); return __s; }
williamr@4
   349
williamr@4
   350
inline ios_base& _STLP_CALL oct(ios_base& __s)
williamr@4
   351
  { __s.setf(ios_base::oct, ios_base::basefield); return __s; }
williamr@4
   352
williamr@4
   353
williamr@4
   354
// floatfield manipulators, section 27.4.5.3
williamr@4
   355
inline ios_base& _STLP_CALL fixed(ios_base& __s)
williamr@4
   356
  { __s.setf(ios_base::fixed, ios_base::floatfield); return __s; }
williamr@4
   357
williamr@4
   358
inline ios_base& _STLP_CALL scientific(ios_base& __s)
williamr@4
   359
  { __s.setf(ios_base::scientific, ios_base::floatfield); return __s; }
williamr@4
   360
williamr@4
   361
_STLP_END_NAMESPACE
williamr@4
   362
williamr@4
   363
#endif /* _STLP_IOS_BASE */
williamr@4
   364
williamr@4
   365
// Local Variables:
williamr@4
   366
// mode:C++
williamr@4
   367
// End:
williamr@4
   368