epoc32/include/tools/stlport/iomanip
branchSymbian3
changeset 4 837f303aceeb
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/tools/stlport/iomanip	Wed Mar 31 12:33:34 2010 +0100
     1.3 @@ -0,0 +1,175 @@
     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 +
    1.22 +#ifndef _STLP_IOMANIP
    1.23 +#define _STLP_IOMANIP
    1.24 +
    1.25 +#ifndef _STLP_OUTERMOST_HEADER_ID
    1.26 +#  define _STLP_OUTERMOST_HEADER_ID 0x1030
    1.27 +#  include <stl/_prolog.h>
    1.28 +#endif
    1.29 +
    1.30 +#ifdef _STLP_PRAGMA_ONCE
    1.31 +#  pragma once
    1.32 +#endif
    1.33 +
    1.34 +#include <stl/_ioserr.h>
    1.35 +#include <stl/_istream.h>              // Includes <ostream> and <ios>
    1.36 +
    1.37 +_STLP_BEGIN_NAMESPACE
    1.38 +
    1.39 +//----------------------------------------------------------------------
    1.40 +// Machinery for defining manipulators.
    1.41 +
    1.42 +// Class that calls one of ios_base's single-argument member functions.
    1.43 +template <class _Arg>
    1.44 +struct _Ios_Manip_1 {
    1.45 +   typedef _Arg (ios_base::*__f_ptr_type)(_Arg);
    1.46 +
    1.47 +  _Ios_Manip_1(__f_ptr_type __f, const _Arg& __arg)
    1.48 +    : _M_f(__f), _M_arg(__arg) {}
    1.49 +
    1.50 +  void operator()(ios_base& __ios) const
    1.51 +  { (__ios.*_M_f)(_M_arg); }
    1.52 +
    1.53 +  __f_ptr_type _M_f;
    1.54 +  _Arg _M_arg;
    1.55 +};
    1.56 +
    1.57 +// Class that calls one of ios_base's two-argument member functions.
    1.58 +struct _Ios_Setf_Manip {
    1.59 +  ios_base::fmtflags _M_flag;
    1.60 +  ios_base::fmtflags _M_mask;
    1.61 +  bool _M_two_args;
    1.62 +
    1.63 +  _Ios_Setf_Manip(ios_base::fmtflags __f)
    1.64 +    : _M_flag(__f), _M_mask(0), _M_two_args(false) {}
    1.65 +
    1.66 +  _Ios_Setf_Manip(ios_base::fmtflags __f, ios_base::fmtflags __m)
    1.67 +    : _M_flag(__f), _M_mask(__m), _M_two_args(true) {}
    1.68 +
    1.69 +  void operator()(ios_base& __ios) const {
    1.70 +    if (_M_two_args)
    1.71 +      __ios.setf(_M_flag, _M_mask);
    1.72 +    else
    1.73 +      __ios.setf(_M_flag);
    1.74 +  }
    1.75 +};
    1.76 +
    1.77 +
    1.78 +template <class _CharT, class _Traits, class _Arg>
    1.79 +inline basic_istream<_CharT, _Traits>& _STLP_CALL
    1.80 +operator>>(basic_istream<_CharT, _Traits>& __istr,
    1.81 +           const _Ios_Manip_1<_Arg>& __f) {
    1.82 +  __f(__istr);
    1.83 +  return __istr;
    1.84 +}
    1.85 +
    1.86 +template <class _CharT, class _Traits, class _Arg>
    1.87 +inline basic_ostream<_CharT, _Traits>& _STLP_CALL
    1.88 +operator<<(basic_ostream<_CharT, _Traits>& __os,
    1.89 +           const _Ios_Manip_1<_Arg>& __f) {
    1.90 +  __f(__os);
    1.91 +  return __os;
    1.92 +}
    1.93 +
    1.94 +template <class _CharT, class _Traits>
    1.95 +inline basic_istream<_CharT, _Traits>& _STLP_CALL
    1.96 +operator>>(basic_istream<_CharT, _Traits>& __istr, const _Ios_Setf_Manip& __f) {
    1.97 +  __f(__istr);
    1.98 +  return __istr;
    1.99 +}
   1.100 +
   1.101 +template <class _CharT, class _Traits>
   1.102 +inline basic_ostream<_CharT, _Traits>& _STLP_CALL
   1.103 +operator<<(basic_ostream<_CharT, _Traits>& __os, const _Ios_Setf_Manip& __f) {
   1.104 +  __f(__os);
   1.105 +  return __os;
   1.106 +}
   1.107 +
   1.108 +//----------------------------------------------------------------------
   1.109 +// The ios_base manipulators.
   1.110 +inline _Ios_Setf_Manip  _STLP_CALL resetiosflags(ios_base::fmtflags __mask)
   1.111 +{ return _Ios_Setf_Manip(0, __mask); }
   1.112 +
   1.113 +inline _Ios_Setf_Manip _STLP_CALL setiosflags(ios_base::fmtflags __flag)
   1.114 +{ return _Ios_Setf_Manip(__flag); }
   1.115 +
   1.116 +inline _Ios_Setf_Manip _STLP_CALL setbase(int __n) {
   1.117 +  ios_base::fmtflags __base = __n == 8  ? ios_base::oct :
   1.118 +                              __n == 10 ? ios_base::dec :
   1.119 +                              __n == 16 ? ios_base::hex :
   1.120 +                              ios_base::fmtflags(0);
   1.121 +  return _Ios_Setf_Manip(__base, ios_base::basefield);
   1.122 +}
   1.123 +
   1.124 +inline _Ios_Manip_1<streamsize> _STLP_CALL
   1.125 +setprecision(int __n) {
   1.126 +  _Ios_Manip_1<streamsize>::__f_ptr_type __f = &ios_base::precision;
   1.127 +  return _Ios_Manip_1<streamsize>(__f, __n);
   1.128 +}
   1.129 +
   1.130 +inline _Ios_Manip_1<streamsize>  _STLP_CALL
   1.131 +setw(int __n) {
   1.132 +  _Ios_Manip_1<streamsize>::__f_ptr_type __f = &ios_base::width;  
   1.133 +  return _Ios_Manip_1<streamsize>(__f, __n);
   1.134 +}
   1.135 +
   1.136 +//----------------------------------------------------------------------
   1.137 +// setfill, a manipulator that operates on basic_ios<> instead of ios_base.
   1.138 +
   1.139 +template <class _CharT>
   1.140 +struct _Setfill_Manip {
   1.141 +  _Setfill_Manip(_CharT __c) : _M_c(__c) {}
   1.142 +  _CharT _M_c;
   1.143 +};
   1.144 +
   1.145 +template <class _CharT, class _CharT2, class _Traits>
   1.146 +inline basic_ostream<_CharT, _Traits>& _STLP_CALL
   1.147 +operator<<(basic_ostream<_CharT, _Traits>& __os,
   1.148 +           const _Setfill_Manip<_CharT2>& __m) {
   1.149 +  __os.fill(__m._M_c);
   1.150 +  return __os;
   1.151 +}
   1.152 +
   1.153 +template <class _CharT, class _CharT2, class _Traits>
   1.154 +inline basic_istream<_CharT, _Traits>& _STLP_CALL
   1.155 +operator>>(basic_istream<_CharT, _Traits>& __is,
   1.156 +           const _Setfill_Manip<_CharT2>& __m) {
   1.157 +  __is.fill(__m._M_c);
   1.158 +  return __is;
   1.159 +}
   1.160 +
   1.161 +template <class _CharT>
   1.162 +inline _Setfill_Manip<_CharT> _STLP_CALL
   1.163 +setfill(_CharT __c) {
   1.164 +  return _Setfill_Manip<_CharT>(__c);
   1.165 +}
   1.166 +
   1.167 +_STLP_END_NAMESPACE
   1.168 +
   1.169 +#if (_STLP_OUTERMOST_HEADER_ID == 0x1030)
   1.170 +#  include <stl/_epilog.h>
   1.171 +#  undef _STLP_OUTERMOST_HEADER_ID
   1.172 +#endif
   1.173 +
   1.174 +#endif /* _STLP_IOMANIP */
   1.175 +
   1.176 +// Local Variables:
   1.177 +// mode:C++
   1.178 +// End: