1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
| // iomanip standard header
#pragma once
#ifndef _IOMANIP_
#define _IOMANIP_
#ifndef RC_INVOKED
#include <istream>
#include <type_traits>
#include <xlocmon>
#include <xloctime>
#pragma pack(push,_CRT_PACKING)
#pragma warning(push,3)
#pragma push_macro("new")
#undef new
_STD_BEGIN
// TEMPLATE STRUCT _Fillobj
template<class _Elem>
struct _Fillobj
{ // store fill character
_Fillobj(_Elem _Ch)
: _Fill(_Ch)
{ // construct from fill character
}
_Elem _Fill; // the fill character
};
// TEMPLATE FUNCTION setfill
template<class _Elem> inline
_Fillobj<_Elem> setfill(_Elem _Ch)
{ // return a _Fillobj manipulator
return (_Fillobj<_Elem>(_Ch));
}
template<class _Elem,
class _Traits,
class _Elem2> inline
basic_istream<_Elem, _Traits>&
operator>>(basic_istream<_Elem, _Traits>& _Istr,
const _Fillobj<_Elem2>& _Manip)
{ // set fill character in input stream
static_assert((is_same<_Elem, _Elem2>::value),
"wrong character type for setfill");
_Istr.fill(_Manip._Fill);
return (_Istr);
}
template<class _Elem,
class _Traits,
class _Elem2> inline
basic_ostream<_Elem, _Traits>&
operator<<(basic_ostream<_Elem, _Traits>& _Ostr,
const _Fillobj<_Elem2>& _Manip)
{ // set fill character in output stream
static_assert((is_same<_Elem, _Elem2>::value),
"wrong character type for setfill");
_Ostr.fill(_Manip._Fill);
return (_Ostr);
}
#if _HAS_CPP0X
// TEMPLATE STRUCT _Monobj
template<class _Money>
struct _Monobj
{ // store reference to monetary amount
_Monobj(_Money& _Val_arg, bool _Intl_arg)
: _Val(_Val_arg), _Intl(_Intl_arg)
{ // construct from monetary amount reference and int'l flag
}
_Money& _Val; // the monetary amount reference
bool _Intl; // international flag
private:
_Monobj& operator=(const _Monobj&);
};
// TEMPLATE FUNCTION get_money
template<class _Money> inline
_Monobj<_Money> get_money(_Money& _Val_arg,
bool _Intl_arg = false)
{ // return a _Monobj manipulator
return (_Monobj<_Money>(_Val_arg, _Intl_arg));
}
template<class _Elem,
class _Traits,
class _Money> inline
basic_istream<_Elem, _Traits>&
operator>>(basic_istream<_Elem, _Traits>& _Istr,
const _Monobj<_Money>& _Manip)
{ // get monetary amount from input stream
typedef basic_istream<_Elem, _Traits> _Myis;
typedef istreambuf_iterator<_Elem, _Traits> _Iter;
typedef money_get<_Elem, _Iter> _Mymget;
ios_base::iostate _State = ios_base::goodbit;
const typename _Myis::sentry _Ok(_Istr);
if (_Ok)
{ // state okay, extract monetary amount
const _Mymget& _Mget_fac = _USE(_Istr.getloc(), _Mymget);
_TRY_IO_BEGIN
_Mget_fac.get(_Iter(_Istr.rdbuf()), _Iter(0), _Manip._Intl,
_Istr, _State, _Manip._Val);
_CATCH_IO_(_Istr)
}
_Istr.setstate(_State);
return (_Istr);
}
// TEMPLATE FUNCTION put_money
template<class _Money> inline
_Monobj<const _Money>
put_money(const _Money& _Val_arg,
bool _Intl_arg = false)
{ // return a _Monobj manipulator
return (_Monobj<const _Money>(_Val_arg, _Intl_arg));
}
template<class _Elem,
class _Traits,
class _Money> inline
basic_ostream<_Elem, _Traits>&
operator<<(basic_ostream<_Elem, _Traits>& _Ostr,
const _Monobj<_Money>& _Manip)
{ // put monetary amount to output stream
typedef basic_ostream<_Elem, _Traits> _Myos;
typedef ostreambuf_iterator<_Elem, _Traits> _Iter;
typedef money_put<_Elem, _Iter> _Mymput;
ios_base::iostate _State = ios_base::goodbit;
const typename _Myos::sentry _Ok(_Ostr);
if (_Ok)
{ // state okay, insert monetary amount
const _Mymput& _Mput_fac = _USE(_Ostr.getloc(), _Mymput);
_TRY_IO_BEGIN
if (_Mput_fac.put(_Iter(_Ostr.rdbuf()), _Manip._Intl,
_Ostr, _Ostr.fill(), _Manip._Val).failed())
_State |= ios_base::badbit;
_CATCH_IO_(_Ostr)
}
_Ostr.setstate(_State);
return (_Ostr);
}
// TEMPLATE STRUCT _Timeobj
template<class _Elem>
struct _Timeobj
{ // store reference to tm object and format
_Timeobj(struct tm *_Tptr_arg, const _Elem *_Fmt_arg)
: _Tptr(_Tptr_arg), _Fmtfirst(_Fmt_arg)
{ // construct from tm pointer and format pointer
for (_Fmtlast = _Fmtfirst; *_Fmtlast != 0; ++_Fmtlast)
; // find end of format string
}
struct tm *_Tptr; // the tm struct pointer
const _Elem *_Fmtfirst; // format string start
const _Elem *_Fmtlast; // format string end
};
// TEMPLATE FUNCTION get_time
template<class _Elem> inline
_Timeobj<_Elem>
get_time(struct tm *_Tptr_arg, const _Elem *_Fmt_arg)
{ // return a _Timeobj manipulator
return (_Timeobj<_Elem>(_Tptr_arg, _Fmt_arg));
}
template<class _Elem,
class _Traits,
class _Elem2> inline
basic_istream<_Elem, _Traits>&
operator>>(basic_istream<_Elem, _Traits>& _Istr,
const _Timeobj<_Elem2>& _Manip)
{ // get time information from input stream
typedef basic_istream<_Elem, _Traits> _Myis;
typedef istreambuf_iterator<_Elem, _Traits> _Iter;
typedef time_get<_Elem2, _Iter> _Mytget;
static_assert((is_same<_Elem, _Elem2>::value),
"wrong character type for get_time");
ios_base::iostate _State = ios_base::goodbit;
const typename _Myis::sentry _Ok(_Istr);
if (_Ok)
{ // state okay, extract time amounts
const _Mytget& _Tget_fac = _USE(_Istr.getloc(), _Mytget);
_TRY_IO_BEGIN
_Tget_fac.get(_Iter(_Istr.rdbuf()), _Iter(0), _Istr, _State,
_Manip._Tptr, _Manip._Fmtfirst, _Manip._Fmtlast);
_CATCH_IO_(_Istr)
}
_Istr.setstate(_State);
return (_Istr);
}
// TEMPLATE FUNCTION put_time
template<class _Elem> inline
_Timeobj<_Elem>
put_time(struct tm *_Tptr_arg, const _Elem *_Fmt_arg)
{ // return a _Timeobj manipulator
return (_Timeobj<_Elem>(_Tptr_arg, _Fmt_arg));
}
template<class _Elem,
class _Traits,
class _Elem2> inline
basic_ostream<_Elem, _Traits>&
operator<<(basic_ostream<_Elem, _Traits>& _Ostr,
const _Timeobj<_Elem2>& _Manip)
{ // put time information to output stream
typedef basic_ostream<_Elem, _Traits> _Myos;
typedef ostreambuf_iterator<_Elem, _Traits> _Iter;
typedef time_put<_Elem2, _Iter> _Mytput;
static_assert((is_same<_Elem, _Elem2>::value),
"wrong character type for put_time");
ios_base::iostate _State = ios_base::goodbit;
const typename _Myos::sentry _Ok(_Ostr);
if (_Ok)
{ // state okay, insert monetary amount
const _Mytput& _Tput_fac = _USE(_Ostr.getloc(), _Mytput);
_TRY_IO_BEGIN
if (_Tput_fac.put(_Iter(_Ostr.rdbuf()), _Ostr, _Ostr.fill(),
_Manip._Tptr, _Manip._Fmtfirst, _Manip._Fmtlast).failed())
_State |= ios_base::badbit;
_CATCH_IO_(_Ostr)
}
_Ostr.setstate(_State);
return (_Ostr);
}
#endif /* _HAS_CPP0X */
// TEMPLATE STRUCT _Smanip
template<class _Arg>
struct _Smanip
{ // store function pointer and argument value
_Smanip(void (__cdecl *_Left)(ios_base&, _Arg), _Arg _Val)
: _Pfun(_Left), _Manarg(_Val)
{ // construct from function pointer and argument value
}
void (__cdecl *_Pfun)(ios_base&, _Arg); // the function pointer
_Arg _Manarg; // the argument value
};
template<class _Elem,
class _Traits,
class _Arg> inline
basic_istream<_Elem, _Traits>& operator>>(
basic_istream<_Elem, _Traits>& _Istr, const _Smanip<_Arg>& _Manip)
{ // extract by calling function with input stream and argument
(*_Manip._Pfun)(_Istr, _Manip._Manarg);
return (_Istr);
}
template<class _Elem,
class _Traits,
class _Arg> inline
basic_ostream<_Elem, _Traits>& operator<<(
basic_ostream<_Elem, _Traits>& _Ostr, const _Smanip<_Arg>& _Manip)
{ // insert by calling function with output stream and argument
(*_Manip._Pfun)(_Ostr, _Manip._Manarg);
return (_Ostr);
}
// INSTANTIATIONS
_MRTIMP2 _Smanip<ios_base::fmtflags> __cdecl resetiosflags(ios_base::fmtflags);
_MRTIMP2 _Smanip<ios_base::fmtflags> __cdecl setiosflags(ios_base::fmtflags);
_MRTIMP2 _Smanip<int> __cdecl setbase(int);
_MRTIMP2 _Smanip<streamsize> __cdecl setprecision(streamsize);
_MRTIMP2 _Smanip<streamsize> __cdecl setw(streamsize);
_STD_END
#pragma pop_macro("new")
#pragma warning(pop)
#pragma pack(pop)
#endif /* RC_INVOKED */
#endif /* _IOMANIP_ */
/*
* Copyright (c) 1992-2012 by P.J. Plauger. ALL RIGHTS RESERVED.
* Consult your license regarding permissions and restrictions.
V6.00:0009 */ |