/* * Copyright (c) 1998 * Silicon Graphics Computer Systems, Inc. * * Permission to use, copy, modify, distribute and sell this software * and its documentation for any purpose is hereby granted without fee, * provided that the above copyright notice appear in all copies and * that both that copyright notice and this permission notice appear * in supporting documentation. Silicon Graphics makes no * representations about the suitability of this software for any * purpose. It is provided "as is" without express or implied warranty. */ #ifndef __SGI_STL_IOMANIP #define __SGI_STL_IOMANIP #if defined(__sgi) && !defined(__GNUC__) && !defined(_STANDARD_C_PLUS_PLUS) #error This header file requires the -LANG:std option #endif #include // Includes and __STL_BEGIN_NAMESPACE //---------------------------------------------------------------------- // Machinery for defining manipulators. // Class that calls one of ios_base's single-argument member functions. template struct _Ios_Manip_1 { _Ios_Manip_1(_Arg (ios_base::*__f)(_Arg), const _Arg& __arg) : _M_f(__f), _M_arg(__arg) {} void operator()(ios_base& __ios) const { (__ios.*_M_f)(_M_arg); } _Arg (ios_base::*_M_f)(_Arg); _Arg _M_arg; }; // Class that calls one of ios_base's two-argument member functions. struct _Ios_Setf_Manip { ios_base::fmtflags _M_flag; ios_base::fmtflags _M_mask; bool _M_two_args; _Ios_Setf_Manip(ios_base::fmtflags __f) : _M_flag(__f), _M_mask(0), _M_two_args(false) {} _Ios_Setf_Manip(ios_base::fmtflags __f, ios_base::fmtflags __m) : _M_flag(__f), _M_mask(__m), _M_two_args(true) {} void operator()(ios_base& __ios) const { if (_M_two_args) __ios.setf(_M_flag, _M_mask); else __ios.setf(_M_flag); } }; template inline basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __in, const _Ios_Manip_1<_Arg>& __f) { __f(__in); return __in; } template inline basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const _Ios_Manip_1<_Arg>& __f) { __f(__os); return __os; } template inline basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __in, const _Ios_Setf_Manip& __f) { __f(__in); return __in; } template inline basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const _Ios_Setf_Manip& __f) { __f(__os); return __os; } //---------------------------------------------------------------------- // The ios_base manipulators. inline _Ios_Setf_Manip resetiosflags(ios_base::fmtflags __mask) { return _Ios_Setf_Manip(0, __mask); } inline _Ios_Setf_Manip setiosflags(ios_base::fmtflags __flag) { return _Ios_Setf_Manip(__flag); } inline _Ios_Setf_Manip setbase(int __n) { ios_base::fmtflags __base = __n == 8 ? ios_base::oct : __n == 10 ? ios_base::dec : __n == 16 ? ios_base::hex : ios_base::fmtflags(0); return _Ios_Setf_Manip(__base, ios_base::basefield); } inline _Ios_Manip_1 setprecision(int __n) { return _Ios_Manip_1(&ios_base::precision, __n); } inline _Ios_Manip_1 setw(int __n) { return _Ios_Manip_1(&ios_base::width, __n); } //---------------------------------------------------------------------- // setfill, a manipulator that operates on basic_ios<> instead of ios_base. template struct _Setfill_Manip { _Setfill_Manip(_CharT __c) : _M_c(__c) {} _CharT _M_c; }; template inline basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const _Setfill_Manip<_CharT2>& __m) { __os.fill(__m._M_c); return __os; } template inline _Setfill_Manip<_CharT> setfill(_CharT __c) { return _Setfill_Manip<_CharT>(__c); } __STL_END_NAMESPACE #endif /* __SGI_STL_IOMANIP */ // Local Variables: // mode:C++ // End: