00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00026 #include "Format.ih"
00027
00028
00029
00030 #define prefix_ inline
00031
00032
00033
00034
00035
00036 prefix_ senf::format::eng::eng(float v, float d)
00037 : v_ (v), d_ (d), haveWidth_ (false), width_ (0), havePrecision_ (false), precision_ (0),
00038 haveFill_ (false), fill_ (' '), mask_ (), flags_ ()
00039 {}
00040
00041 prefix_ senf::format::eng const & senf::format::eng::setw(unsigned w)
00042 const
00043 {
00044 haveWidth_ = true;
00045 width_ = w;
00046 return *this;
00047 }
00048
00049 prefix_ senf::format::eng const & senf::format::eng::setprecision(unsigned p)
00050 const
00051 {
00052 havePrecision_ = true;
00053 precision_ = p;
00054 return *this;
00055 }
00056
00057 prefix_ senf::format::eng const & senf::format::eng::setfill(char c)
00058 const
00059 {
00060 haveFill_ = true;
00061 fill_ = c;
00062 return *this;
00063 }
00064
00065 prefix_ senf::format::eng const & senf::format::eng::showbase()
00066 const
00067 {
00068 mask_ |= std::ios_base::showbase;
00069 flags_ |= std::ios_base::showbase;
00070 return *this;
00071 }
00072
00073 prefix_ senf::format::eng const & senf::format::eng::noshowbase()
00074 const
00075 {
00076 mask_ |= std::ios_base::showbase;
00077 flags_ &= ~std::ios_base::showbase;
00078 return *this;
00079 }
00080
00081 prefix_ senf::format::eng const & senf::format::eng::showpos()
00082 const
00083 {
00084 mask_ |= std::ios_base::showpos;
00085 flags_ |= std::ios_base::showpos;
00086 return *this;
00087 }
00088
00089 prefix_ senf::format::eng const & senf::format::eng::noshowpos()
00090 const
00091 {
00092 mask_ |= std::ios_base::showpos;
00093 flags_ &= ~std::ios_base::showpos;
00094 return *this;
00095 }
00096
00097 prefix_ senf::format::eng const & senf::format::eng::showpoint()
00098 const
00099 {
00100 mask_ |= std::ios_base::showpoint;
00101 flags_ |= std::ios_base::showpoint;
00102 return *this;
00103 }
00104
00105 prefix_ senf::format::eng const & senf::format::eng::noshowpoint()
00106 const
00107 {
00108 mask_ |= std::ios_base::showpoint;
00109 flags_ &= ~std::ios_base::showpoint;
00110 return *this;
00111 }
00112
00113 prefix_ senf::format::eng const & senf::format::eng::uppercase()
00114 const
00115 {
00116 mask_ |= std::ios_base::uppercase;
00117 flags_ |= std::ios_base::uppercase;
00118 return *this;
00119 }
00120
00121 prefix_ senf::format::eng const & senf::format::eng::nouppercase()
00122 const
00123 {
00124 mask_ |= std::ios_base::uppercase;
00125 flags_ &= ~std::ios_base::uppercase;
00126 return *this;
00127 }
00128
00129 prefix_ senf::format::eng const & senf::format::eng::left()
00130 const
00131 {
00132 mask_ |= std::ios_base::adjustfield;
00133 flags_ &= ~std::ios_base::adjustfield;
00134 flags_ |= std::ios_base::left;
00135 return *this;
00136 }
00137
00138 prefix_ senf::format::eng const & senf::format::eng::internal()
00139 const
00140 {
00141 mask_ |= std::ios_base::adjustfield;
00142 flags_ &= ~std::ios_base::adjustfield;
00143 flags_ |= std::ios_base::internal;
00144 return *this;
00145 }
00146
00147 prefix_ senf::format::eng const & senf::format::eng::right()
00148 const
00149 {
00150 mask_ |= std::ios_base::adjustfield;
00151 flags_ &= ~std::ios_base::adjustfield;
00152 flags_ |= std::ios_base::right;
00153 return *this;
00154 }
00155
00156
00157
00158
00159 prefix_ senf::format::IndentHelper::IndentHelper()
00160 : instance_level(1)
00161 {
00162 ++static_level;
00163 }
00164
00165 prefix_ senf::format::IndentHelper::~IndentHelper()
00166 {
00167 static_level -= instance_level;
00168 }
00169
00170 prefix_ void senf::format::IndentHelper::increase()
00171 {
00172 ++static_level;
00173 ++instance_level;
00174 }
00175
00176 prefix_ unsigned int senf::format::IndentHelper::level()
00177 const
00178 {
00179 return static_level;
00180 }
00181
00182 prefix_ std::ostream & senf::format::operator<<(std::ostream & os, senf::format::IndentHelper const & indent)
00183 {
00184 for (unsigned int i=0, j=indent.level(); i<j; ++i)
00185 os << " ";
00186 return os;
00187 }
00188
00189
00190
00191
00192
00193
00194
00195 #undef prefix_
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206