3 * Silicon Graphics Computer Systems, Inc.
8 * This material is provided "as is", with absolutely no warranty expressed
9 * or implied. Any use is at your own risk.
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.
22 #ifndef _STLP_OUTERMOST_HEADER_ID
23 # define _STLP_OUTERMOST_HEADER_ID 0x1030
24 # include <stl/_prolog.h>
27 #ifdef _STLP_PRAGMA_ONCE
31 #include <stl/_ioserr.h>
32 #include <stl/_istream.h> // includes <ostream> and <ios>
36 //----------------------------------------------------------------------
37 // Machinery for defining manipulators.
39 // Class that calls one of ios_base's single-argument member functions.
42 typedef _Arg (ios_base::*__f_ptr_type)(_Arg);
44 _Ios_Manip_1(__f_ptr_type __f, const _Arg& __arg)
45 : _M_f(__f), _M_arg(__arg) {}
47 void operator()(ios_base& __ios) const
48 { (__ios.*_M_f)(_M_arg); }
54 // Class that calls one of ios_base's two-argument member functions.
55 struct _Ios_Setf_Manip {
56 ios_base::fmtflags _M_flag;
57 ios_base::fmtflags _M_mask;
60 _Ios_Setf_Manip(ios_base::fmtflags __f)
61 : _M_flag(__f), _M_mask(0), _M_two_args(false) {}
63 _Ios_Setf_Manip(ios_base::fmtflags __f, ios_base::fmtflags __m)
64 : _M_flag(__f), _M_mask(__m), _M_two_args(true) {}
66 void operator()(ios_base& __ios) const {
68 __ios.setf(_M_flag, _M_mask);
75 template <class _CharT, class _Traits, class _Arg>
76 inline basic_istream<_CharT, _Traits>& _STLP_CALL
77 operator>>(basic_istream<_CharT, _Traits>& __istr,
78 const _Ios_Manip_1<_Arg>& __f) {
83 template <class _CharT, class _Traits, class _Arg>
84 inline basic_ostream<_CharT, _Traits>& _STLP_CALL
85 operator<<(basic_ostream<_CharT, _Traits>& __os,
86 const _Ios_Manip_1<_Arg>& __f) {
91 template <class _CharT, class _Traits>
92 inline basic_istream<_CharT, _Traits>& _STLP_CALL
93 operator>>(basic_istream<_CharT, _Traits>& __istr, const _Ios_Setf_Manip& __f) {
98 template <class _CharT, class _Traits>
99 inline basic_ostream<_CharT, _Traits>& _STLP_CALL
100 operator<<(basic_ostream<_CharT, _Traits>& __os, const _Ios_Setf_Manip& __f) {
105 //----------------------------------------------------------------------
106 // The ios_base manipulators.
107 inline _Ios_Setf_Manip _STLP_CALL resetiosflags(ios_base::fmtflags __mask)
108 { return _Ios_Setf_Manip(0, __mask); }
110 inline _Ios_Setf_Manip _STLP_CALL setiosflags(ios_base::fmtflags __flag)
111 { return _Ios_Setf_Manip(__flag); }
113 inline _Ios_Setf_Manip _STLP_CALL setbase(int __n) {
114 ios_base::fmtflags __base = __n == 8 ? ios_base::oct :
115 __n == 10 ? ios_base::dec :
116 __n == 16 ? ios_base::hex :
117 ios_base::fmtflags(0);
118 return _Ios_Setf_Manip(__base, ios_base::basefield);
121 inline _Ios_Manip_1<streamsize> _STLP_CALL
122 setprecision(int __n) {
123 _Ios_Manip_1<streamsize>::__f_ptr_type __f = &ios_base::precision;
124 return _Ios_Manip_1<streamsize>(__f, __n);
127 inline _Ios_Manip_1<streamsize> _STLP_CALL
129 _Ios_Manip_1<streamsize>::__f_ptr_type __f = &ios_base::width;
130 return _Ios_Manip_1<streamsize>(__f, __n);
133 //----------------------------------------------------------------------
134 // setfill, a manipulator that operates on basic_ios<> instead of ios_base.
136 template <class _CharT>
137 struct _Setfill_Manip {
138 _Setfill_Manip(_CharT __c) : _M_c(__c) {}
142 template <class _CharT, class _CharT2, class _Traits>
143 inline basic_ostream<_CharT, _Traits>& _STLP_CALL
144 operator<<(basic_ostream<_CharT, _Traits>& __os,
145 const _Setfill_Manip<_CharT2>& __m) {
150 template <class _CharT, class _CharT2, class _Traits>
151 inline basic_istream<_CharT, _Traits>& _STLP_CALL
152 operator>>(basic_istream<_CharT, _Traits>& __is,
153 const _Setfill_Manip<_CharT2>& __m) {
158 template <class _CharT>
159 inline _Setfill_Manip<_CharT> _STLP_CALL
160 setfill(_CharT __c) {
161 return _Setfill_Manip<_CharT>(__c);
166 #if (_STLP_OUTERMOST_HEADER_ID == 0x1030)
167 # include <stl/_epilog.h>
168 # undef _STLP_OUTERMOST_HEADER_ID
171 #endif /* _STLP_IOMANIP */