Whole document tree std_iomanip.hGo to the documentation of this file.00001 // Standard stream manipulators -*- C++ -*- 00002 00003 // Copyright (C) 1997-1999, 2001 Free Software Foundation, Inc. 00004 // 00005 // This file is part of the GNU ISO C++ Library. This library is free 00006 // software; you can redistribute it and/or modify it under the 00007 // terms of the GNU General Public License as published by the 00008 // Free Software Foundation; either version 2, or (at your option) 00009 // any later version. 00010 00011 // This library is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // GNU General Public License for more details. 00015 00016 // You should have received a copy of the GNU General Public License along 00017 // with this library; see the file COPYING. If not, write to the Free 00018 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, 00019 // USA. 00020 00021 // As a special exception, you may use this file as part of a free software 00022 // library without restriction. Specifically, if other files instantiate 00023 // templates or use macros or inline functions from this file, or you compile 00024 // this file and link it with other files to produce an executable, this 00025 // file does not by itself cause the resulting executable to be covered by 00026 // the GNU General Public License. This exception does not however 00027 // invalidate any other reasons why the executable file might be covered by 00028 // the GNU General Public License. 00029 00030 // 00031 // ISO C++ 14882: 27.6.3 Standard manipulators 00032 // 00033 00034 #ifndef _CPP_IOMANIP 00035 #define _CPP_IOMANIP 1 00036 00037 #pragma GCC system_header 00038 00039 #include <bits/c++config.h> 00040 #include <bits/std_istream.h> 00041 #include <bits/std_functional.h> 00042 00043 namespace std 00044 { 00045 00046 struct _Resetiosflags { ios_base::fmtflags _M_mask; }; 00047 00048 inline _Resetiosflags 00049 resetiosflags(ios_base::fmtflags __mask) 00050 { 00051 _Resetiosflags __x; 00052 __x._M_mask = __mask; 00053 return __x; 00054 } 00055 00056 template <class _CharT, class _Traits> 00057 basic_istream<_CharT,_Traits>& 00058 operator>>(basic_istream<_CharT,_Traits>& __is, _Resetiosflags __f) 00059 { 00060 __is.setf(ios_base::fmtflags(0), __f._M_mask); 00061 return __is; 00062 } 00063 00064 template <class _CharT, class _Traits> 00065 basic_ostream<_CharT,_Traits>& 00066 operator<<(basic_ostream<_CharT,_Traits>& __os, _Resetiosflags __f) 00067 { 00068 __os.setf(ios_base::fmtflags(0), __f._M_mask); 00069 return __os; 00070 } 00071 00072 00073 struct _Setiosflags { ios_base::fmtflags _M_mask; }; 00074 00075 inline _Setiosflags 00076 setiosflags (ios_base::fmtflags __mask) 00077 { 00078 _Setiosflags __x; 00079 __x._M_mask = __mask; 00080 return __x; 00081 } 00082 00083 template <class _CharT, class _Traits> 00084 basic_istream<_CharT,_Traits>& 00085 operator>>(basic_istream<_CharT,_Traits>& __is, _Setiosflags __f) 00086 { 00087 __is.setf(__f._M_mask); 00088 return __is; 00089 } 00090 00091 template <class _CharT, class _Traits> 00092 basic_ostream<_CharT,_Traits>& 00093 operator<<(basic_ostream<_CharT,_Traits>& __os, _Setiosflags __f) 00094 { 00095 __os.setf(__f._M_mask); 00096 return __os; 00097 } 00098 00099 00100 struct _Setbase { int _M_base; }; 00101 00102 inline _Setbase 00103 setbase (int __base) 00104 { 00105 _Setbase __x; 00106 __x._M_base = __base; 00107 return __x; 00108 } 00109 00110 template <class _CharT, class _Traits> 00111 basic_istream<_CharT,_Traits>& 00112 operator>>(basic_istream<_CharT,_Traits>& __is, _Setbase __f) 00113 { 00114 __is.setf(__f._M_base == 8 ? ios_base::oct : 00115 __f._M_base == 10 ? ios_base::dec : 00116 __f._M_base == 16 ? ios_base::hex : 00117 ios_base::fmtflags(0), ios_base::basefield); 00118 return __is; 00119 } 00120 00121 template <class _CharT, class _Traits> 00122 basic_ostream<_CharT,_Traits>& 00123 operator<<(basic_ostream<_CharT,_Traits>& __os, _Setbase __f) 00124 { 00125 __os.setf(__f._M_base == 8 ? ios_base::oct : 00126 __f._M_base == 10 ? ios_base::dec : 00127 __f._M_base == 16 ? ios_base::hex : 00128 ios_base::fmtflags(0), ios_base::basefield); 00129 return __os; 00130 } 00131 00132 00133 template<class _CharT> 00134 struct _Setfill { _CharT _M_c; }; 00135 00136 template<class _CharT> 00137 _Setfill<_CharT> 00138 setfill(_CharT __c) 00139 { 00140 _Setfill<_CharT> __x; 00141 __x._M_c = __c; 00142 return __x; 00143 } 00144 00145 template <class _CharT, class _Traits> 00146 basic_istream<_CharT,_Traits>& 00147 operator>>(basic_istream<_CharT,_Traits>& __is, _Setfill<_CharT> __f) 00148 { 00149 __is.fill(__f._M_c); 00150 return __is; 00151 } 00152 00153 template <class _CharT, class _Traits> 00154 basic_ostream<_CharT,_Traits>& 00155 operator<<(basic_ostream<_CharT,_Traits>& __os, _Setfill<_CharT> __f) 00156 { 00157 __os.fill(__f._M_c); 00158 return __os; 00159 } 00160 00161 00162 struct _Setprecision { int _M_n; }; 00163 00164 inline _Setprecision 00165 setprecision(int __n) 00166 { 00167 _Setprecision __x; 00168 __x._M_n = __n; 00169 return __x; 00170 } 00171 00172 template <class _CharT, class _Traits> 00173 basic_istream<_CharT,_Traits>& 00174 operator>>(basic_istream<_CharT,_Traits>& __is, _Setprecision __f) 00175 { 00176 __is.precision(__f._M_n); 00177 return __is; 00178 } 00179 00180 template <class _CharT, class _Traits> 00181 basic_ostream<_CharT,_Traits>& 00182 operator<<(basic_ostream<_CharT,_Traits>& __os, _Setprecision __f) 00183 { 00184 __os.precision(__f._M_n); 00185 return __os; 00186 } 00187 00188 00189 struct _Setw { int _M_n; }; 00190 00191 inline _Setw 00192 setw(int __n) 00193 { 00194 _Setw __x; 00195 __x._M_n = __n; 00196 return __x; 00197 } 00198 00199 template <class _CharT, class _Traits> 00200 basic_istream<_CharT,_Traits>& 00201 operator>>(basic_istream<_CharT,_Traits>& __is, _Setw __f) 00202 { 00203 __is.width(__f._M_n); 00204 return __is; 00205 } 00206 00207 template <class _CharT, class _Traits> 00208 basic_ostream<_CharT,_Traits>& 00209 operator<<(basic_ostream<_CharT,_Traits>& __os, _Setw __f) 00210 { 00211 __os.width(__f._M_n); 00212 return __os; 00213 } 00214 00215 } // namespace std 00216 00217 #endif /* __IOMANIP */ 00218 Generated on Mon Apr 8 03:11:33 2002 for libstdc++-v3 Source by ![]() |