1.1 --- a/epoc32/include/stdapis/stlport/iomanip Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/stdapis/stlport/iomanip Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,225 @@
1.4 -iomanip
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 +
1.24 +#ifndef _STLP_IOMANIP
1.25 +#define _STLP_IOMANIP
1.26 +
1.27 +# ifndef _STLP_OUTERMOST_HEADER_ID
1.28 +# define _STLP_OUTERMOST_HEADER_ID 0x1030
1.29 +# include <stl/_prolog.h>
1.30 +# endif
1.31 +
1.32 +# ifdef _STLP_PRAGMA_ONCE
1.33 +# pragma once
1.34 +# endif
1.35 +
1.36 +# if defined ( _STLP_OWN_IOSTREAMS )
1.37 +
1.38 +# include <stl/_istream.h> // Includes <ostream> and <ios>
1.39 +
1.40 +_STLP_BEGIN_NAMESPACE
1.41 +
1.42 +//----------------------------------------------------------------------
1.43 +// Machinery for defining manipulators.
1.44 +
1.45 +// Class that calls one of ios_base's single-argument member functions.
1.46 +template <class _Arg>
1.47 +struct _Ios_Manip_1 {
1.48 +#ifdef __SYMBIAN32__
1.49 + typedef void (_STLP_CALL *__f_ptr_type)(ios_base&, _Arg);
1.50 +#else
1.51 + typedef _Arg (ios_base::*__f_ptr_type)(_Arg);
1.52 +#endif
1.53 + _Ios_Manip_1(__f_ptr_type __f, const _Arg& __arg)
1.54 + : _M_f(__f), _M_arg(__arg)
1.55 + {}
1.56 +
1.57 + void operator()(ios_base& __ios) const {
1.58 +#ifdef __SYMBIAN32__
1.59 + (*_M_f)(__ios, _M_arg);
1.60 +#else
1.61 + (__ios.*_M_f)(_M_arg);
1.62 +#endif
1.63 + }
1.64 +
1.65 + __f_ptr_type _M_f;
1.66 + _Arg _M_arg;
1.67 +};
1.68 +
1.69 +// Class that calls one of ios_base's two-argument member functions.
1.70 +struct _Ios_Setf_Manip {
1.71 + ios_base::fmtflags _M_flag;
1.72 + ios_base::fmtflags _M_mask;
1.73 + bool _M_two_args;
1.74 +
1.75 + _Ios_Setf_Manip(ios_base::fmtflags __f)
1.76 + : _M_flag(__f), _M_mask(0), _M_two_args(false)
1.77 + {}
1.78 +
1.79 + _Ios_Setf_Manip(ios_base::fmtflags __f, ios_base::fmtflags __m)
1.80 + : _M_flag(__f), _M_mask(__m), _M_two_args(true)
1.81 + {}
1.82 +
1.83 + void operator()(ios_base& __ios) const {
1.84 + if (_M_two_args)
1.85 + __ios.setf(_M_flag, _M_mask);
1.86 + else
1.87 + __ios.setf(_M_flag);
1.88 + }
1.89 +};
1.90 +
1.91 +
1.92 +template <class _CharT, class _Traits, class _Arg>
1.93 +inline basic_istream<_CharT, _Traits>& _STLP_CALL
1.94 +operator>>(basic_istream<_CharT, _Traits>& _SP_in,
1.95 + const _Ios_Manip_1<_Arg>& __f)
1.96 +{
1.97 + __f(_SP_in);
1.98 + return _SP_in;
1.99 +}
1.100 +
1.101 +template <class _CharT, class _Traits, class _Arg>
1.102 +inline basic_ostream<_CharT, _Traits>& _STLP_CALL
1.103 +operator<<(basic_ostream<_CharT, _Traits>& __os,
1.104 + const _Ios_Manip_1<_Arg>& __f)
1.105 +{
1.106 + __f(__os);
1.107 + return __os;
1.108 +}
1.109 +
1.110 +template <class _CharT, class _Traits>
1.111 +inline basic_istream<_CharT, _Traits>& _STLP_CALL
1.112 +operator>>(basic_istream<_CharT, _Traits>& _SP_in, const _Ios_Setf_Manip& __f)
1.113 +{
1.114 + __f(_SP_in);
1.115 + return _SP_in;
1.116 +}
1.117 +
1.118 +template <class _CharT, class _Traits>
1.119 +inline basic_ostream<_CharT, _Traits>& _STLP_CALL
1.120 +operator<<(basic_ostream<_CharT, _Traits>& __os, const _Ios_Setf_Manip& __f)
1.121 +
1.122 +{
1.123 + __f(__os);
1.124 + return __os;
1.125 +}
1.126 +
1.127 +//----------------------------------------------------------------------
1.128 +// The ios_base manipulators.
1.129 +
1.130 +#ifdef __SYMBIAN32__
1.131 + // setprecision
1.132 +static void _STLP_CALL spfun(ios_base& iostr, streamsize prec)
1.133 + { // set precision
1.134 + iostr.precision(prec);
1.135 + }
1.136 +
1.137 + // setw
1.138 +static void _STLP_CALL swfun(ios_base& iostr, streamsize wide)
1.139 + { // set width
1.140 + iostr.width(wide);
1.141 + }
1.142 +#endif
1.143 +
1.144 +inline _Ios_Setf_Manip _STLP_CALL resetiosflags(ios_base::fmtflags __mask) {
1.145 + return _Ios_Setf_Manip(0, __mask);
1.146 +}
1.147 +
1.148 +inline _Ios_Setf_Manip _STLP_CALL setiosflags(ios_base::fmtflags __flag) {
1.149 + return _Ios_Setf_Manip(__flag);
1.150 +}
1.151 +
1.152 +inline _Ios_Setf_Manip _STLP_CALL setbase(int __n) {
1.153 + ios_base::fmtflags __base = __n == 8 ? ios_base::oct :
1.154 + __n == 10 ? ios_base::dec :
1.155 + __n == 16 ? ios_base::hex :
1.156 + ios_base::fmtflags(0);
1.157 + return _Ios_Setf_Manip(__base, ios_base::basefield);
1.158 +}
1.159 +
1.160 +inline _Ios_Manip_1<streamsize> _STLP_CALL
1.161 +setprecision(int __n) {
1.162 +#ifdef __SYMBIAN32__
1.163 + _Ios_Manip_1<streamsize>::__f_ptr_type __f = &spfun;
1.164 +#else
1.165 + _Ios_Manip_1<streamsize>::__f_ptr_type __f = &ios_base::precision;
1.166 +#endif
1.167 + return _Ios_Manip_1<streamsize>(__f, __n);
1.168 +}
1.169 +
1.170 +inline _Ios_Manip_1<streamsize> _STLP_CALL
1.171 +setw(int __n) {
1.172 +#ifdef __SYMBIAN32__
1.173 + _Ios_Manip_1<streamsize>::__f_ptr_type __f = &swfun;
1.174 +#else
1.175 + _Ios_Manip_1<streamsize>::__f_ptr_type __f = &ios_base::width;
1.176 +#endif
1.177 +
1.178 + return _Ios_Manip_1<streamsize>(__f, __n);
1.179 +}
1.180 +
1.181 +//----------------------------------------------------------------------
1.182 +// setfill, a manipulator that operates on basic_ios<> instead of ios_base.
1.183 +
1.184 +template <class _CharT>
1.185 +struct _Setfill_Manip {
1.186 + _Setfill_Manip(_CharT __c) : _M_c(__c) {}
1.187 + _CharT _M_c;
1.188 +};
1.189 +
1.190 +template <class _CharT, class _CharT2, class _Traits>
1.191 +inline basic_ostream<_CharT, _Traits>& _STLP_CALL
1.192 +operator<<(basic_ostream<_CharT, _Traits>& __os,
1.193 + const _Setfill_Manip<_CharT2>& __m)
1.194 +{
1.195 + __os.fill(__m._M_c);
1.196 + return __os;
1.197 +}
1.198 +
1.199 +template <class _CharT, class _CharT2, class _Traits>
1.200 +inline basic_istream<_CharT, _Traits>& _STLP_CALL
1.201 +operator>>(basic_istream<_CharT, _Traits>& __is,
1.202 + const _Setfill_Manip<_CharT2>& __m)
1.203 +{
1.204 + __is.fill(__m._M_c);
1.205 + return __is;
1.206 +}
1.207 +
1.208 +template <class _CharT>
1.209 +inline _Setfill_Manip<_CharT> _STLP_CALL
1.210 +setfill(_CharT __c) {
1.211 + return _Setfill_Manip<_CharT>(__c);
1.212 +}
1.213 +
1.214 +_STLP_END_NAMESPACE
1.215 +
1.216 +# elif !defined (_STLP_USE_NO_IOSTREAMS)
1.217 +# include <wrap_std/iomanip>
1.218 +# endif
1.219 +
1.220 +# if (_STLP_OUTERMOST_HEADER_ID == 0x1030)
1.221 +# include <stl/_epilog.h>
1.222 +# undef _STLP_OUTERMOST_HEADER_ID
1.223 +# endif
1.224 +
1.225 +#endif /* _STLP_IOMANIP */
1.226 +
1.227 +// Local Variables:
1.228 +// mode:C++
1.229 +// End: