ReactOS  0.4.14-dev-77-gd9e7c48
_iomanip.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 1999
3  * Silicon Graphics Computer Systems, Inc.
4  *
5  * Copyright (c) 1999
6  * Boris Fomitchev
7  *
8  * This material is provided "as is", with absolutely no warranty expressed
9  * or implied. Any use is at your own risk.
10  *
11  * Permission to use or copy this software for any purpose is hereby granted
12  * without fee, provided the above notices are retained on all copies.
13  * Permission to modify the code and to distribute modified code is granted,
14  * provided the above notices are retained, and a notice that the code was
15  * modified is included with the above copyright notice.
16  *
17  */
18 
19 #ifndef _STLP_INTERNAL_IOMANIP
20 #define _STLP_INTERNAL_IOMANIP
21 
22 #ifndef _STLP_INTERNAL_ISTREAM
23 # include <stl/_istream.h> // Includes <ostream> and <ios>
24 #endif
25 
27 
29 
30 //----------------------------------------------------------------------
31 // Machinery for defining manipulators.
32 
33 // Class that calls one of ios_base's single-argument member functions.
34 template <class _Arg>
35 struct _Ios_Manip_1 {
36  typedef _Arg (ios_base::*__f_ptr_type)(_Arg);
37 
38  _Ios_Manip_1(__f_ptr_type __f, const _Arg& __arg)
39  : _M_f(__f), _M_arg(__arg) {}
40 
41  void operator()(ios_base& __ios) const
42  { (__ios.*_M_f)(_M_arg); }
43 
45  _Arg _M_arg;
46 };
47 
48 // Class that calls one of ios_base's two-argument member functions.
53 
55  : _M_flag(__f), _M_mask(0), _M_two_args(false) {}
56 
58  : _M_flag(__f), _M_mask(__m), _M_two_args(true) {}
59 
60  void operator()(ios_base& __ios) const {
61  if (_M_two_args)
62  __ios.setf(_M_flag, _M_mask);
63  else
64  __ios.setf(_M_flag);
65  }
66 };
67 
69 
70 template <class _CharT, class _Traits, class _Arg>
73  const _STLP_PRIV _Ios_Manip_1<_Arg>& __f) {
74  __f(__istr);
75  return __istr;
76 }
77 
78 template <class _CharT, class _Traits, class _Arg>
81  const _STLP_PRIV _Ios_Manip_1<_Arg>& __f) {
82  __f(__os);
83  return __os;
84 }
85 
86 template <class _CharT, class _Traits>
89  const _STLP_PRIV _Ios_Setf_Manip& __f) {
90  __f(__istr);
91  return __istr;
92 }
93 
94 template <class _CharT, class _Traits>
97  const _STLP_PRIV _Ios_Setf_Manip& __f) {
98  __f(__os);
99  return __os;
100 }
101 
102 //----------------------------------------------------------------------
103 // The ios_base manipulators.
105 { return _STLP_PRIV _Ios_Setf_Manip(0, __mask); }
106 
108 { return _STLP_PRIV _Ios_Setf_Manip(__flag); }
109 
111  ios_base::fmtflags __base = __n == 8 ? ios_base::oct :
112  __n == 10 ? ios_base::dec :
113  __n == 16 ? ios_base::hex :
115  return _STLP_PRIV _Ios_Setf_Manip(__base, ios_base::basefield);
116 }
117 
122 }
123 
125 setw(int __n) {
128 }
129 
130 //----------------------------------------------------------------------
131 // setfill, a manipulator that operates on basic_ios<> instead of ios_base.
132 
134 
135 template <class _CharT>
137  _Setfill_Manip(_CharT __c) : _M_c(__c) {}
138  _CharT _M_c;
139 };
140 
142 
143 template <class _CharT, class _CharT2, class _Traits>
146  const _STLP_PRIV _Setfill_Manip<_CharT2>& __m) {
147  __os.fill(__m._M_c);
148  return __os;
149 }
150 
151 template <class _CharT, class _CharT2, class _Traits>
154  const _STLP_PRIV _Setfill_Manip<_CharT2>& __m) {
155  __is.fill(__m._M_c);
156  return __is;
157 }
158 
159 template <class _CharT>
162 
164 
165 #endif /* _STLP_INTERNAL_IOMANIP */
#define true
Definition: stdbool.h:37
return __n
Definition: _algo.h:75
_STLP_MOVE_TO_STD_NAMESPACE basic_istream< _CharT, _Traits > &_STLP_CALL operator>>(basic_istream< _CharT, _Traits > &__istr, const _STLP_PRIV _Ios_Manip_1< _Arg > &__f)
Definition: _iomanip.h:72
ios_base::fmtflags _M_mask
Definition: _iomanip.h:51
streamsize precision() const
Definition: _ios_base.h:127
char_type fill() const
Definition: _ios.h:81
_STLP_PRIV _Ios_Setf_Manip _STLP_CALL setiosflags(ios_base::fmtflags __flag)
Definition: _iomanip.h:107
_Ios_Manip_1(__f_ptr_type __f, const _Arg &__arg)
Definition: _iomanip.h:38
__f_ptr_type _M_f
Definition: _iomanip.h:44
_STLP_PRIV _Setfill_Manip< _CharT > _STLP_CALL setfill(_CharT __c)
Definition: _iomanip.h:160
ios_base &_STLP_CALL dec(ios_base &__s)
Definition: _ios_base.h:321
_STLP_PRIV _Ios_Manip_1< streamsize > _STLP_CALL setprecision(int __n)
Definition: _iomanip.h:119
static const char hex[16]
Definition: profile.c:123
ios_base::fmtflags _M_flag
Definition: _iomanip.h:50
#define __c
Definition: schilyio.h:209
#define _STLP_MOVE_TO_PRIV_NAMESPACE
Definition: features.h:524
void operator()(ios_base &__ios) const
Definition: _iomanip.h:60
_STLP_PRIV _Ios_Setf_Manip _STLP_CALL setbase(int __n)
Definition: _iomanip.h:110
#define _STLP_MOVE_TO_STD_NAMESPACE
Definition: features.h:525
void operator()(ios_base &__ios) const
Definition: _iomanip.h:41
_Ios_Setf_Manip(ios_base::fmtflags __f, ios_base::fmtflags __m)
Definition: _iomanip.h:57
#define _STLP_PRIV
Definition: _dm.h:70
#define false
Definition: stdbool.h:38
streamsize width() const
Definition: _ios_base.h:134
_Arg _M_arg
Definition: _iomanip.h:45
int fmtflags
Definition: _ios_base.h:57
_Setfill_Manip(_CharT __c)
Definition: _iomanip.h:137
_STLP_PRIV _Ios_Manip_1< streamsize > _STLP_CALL setw(int __n)
Definition: _iomanip.h:125
#define _STLP_END_NAMESPACE
Definition: features.h:503
_Arg(ios_base::* __f_ptr_type)(_Arg)
Definition: _iomanip.h:36
ios_base &_STLP_CALL oct(ios_base &__s)
Definition: _ios_base.h:327
basic_ostream< _CharT, _Traits > &_STLP_CALL operator<<(basic_ostream< _CharT, _Traits > &__os, const _STLP_PRIV _Ios_Manip_1< _Arg > &__f)
Definition: _iomanip.h:80
_STLP_PRIV _Ios_Setf_Manip _STLP_CALL resetiosflags(ios_base::fmtflags __mask)
Definition: _iomanip.h:104
fmtflags setf(fmtflags __flag)
Definition: _ios_base.h:114
bool _M_two_args
Definition: _iomanip.h:52
#define _STLP_BEGIN_NAMESPACE
Definition: features.h:501
_Ios_Setf_Manip(ios_base::fmtflags __f)
Definition: _iomanip.h:54
#define _STLP_CALL
Definition: _bc.h:131
_CharT _M_c
Definition: _iomanip.h:138