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