00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00026 #ifndef HH_SENF_senf_Utils_Format_
00027 #define HH_SENF_senf_Utils_Format_ 1
00028
00029
00030 #include <limits>
00031 #include <iostream>
00032 #include <boost/utility/enable_if.hpp>
00033 #include <boost/type_traits/is_signed.hpp>
00034 #include <boost/type_traits/is_unsigned.hpp>
00035
00036
00037
00038
00039 namespace senf {
00040 namespace format {
00041
00045 #ifdef DOXYGEN
00046
00123 streamable_type eng(float v, float d=NAN);
00124
00125 #else
00126
00127 class eng
00128 {
00129 public:
00130 eng(float v, float d = std::numeric_limits<float>::quiet_NaN());
00131
00132 eng const & setw(unsigned w = 1) const;
00133 eng const & setprecision(unsigned p) const;
00134 eng const & setfill(char c) const;
00135
00136 eng const & showbase() const;
00137 eng const & noshowbase() const;
00138 eng const & showpos() const;
00139 eng const & noshowpos() const;
00140 eng const & showpoint() const;
00141 eng const & noshowpoint() const;
00142 eng const & uppercase() const;
00143 eng const & nouppercase() const;
00144 eng const & left() const;
00145 eng const & internal() const;
00146 eng const & right() const;
00147
00148 private:
00149 float v_;
00150 float d_;
00151
00152 mutable bool haveWidth_;
00153 mutable unsigned width_;
00154 mutable bool havePrecision_;
00155 mutable unsigned precision_;
00156 mutable bool haveFill_;
00157 mutable char fill_;
00158 mutable std::ios_base::fmtflags mask_;
00159 mutable std::ios_base::fmtflags flags_;
00160
00161 friend std::ostream & operator<<(std::ostream & os, eng const & v);
00162
00163 };
00164
00165 std::ostream & operator<<(std::ostream & os, eng const & v);
00166
00167 #endif
00168
00169 #ifdef DOXYGEN
00170
00184 template <class T>
00185 streamable_type dumpint(T const & v);
00186
00187 #else
00188
00189 template <class T>
00190 std::string dumpint(T const & v,
00191 typename boost::enable_if<boost::is_signed<T> >::type * = 0);
00192
00193 template <class T>
00194 std::string dumpint(T const & v,
00195 typename boost::enable_if<boost::is_unsigned<T> >::type * = 0);
00196
00197 template <class T>
00198 std::string dumpint(T const & v,
00199 typename boost::enable_if<boost::is_signed<typename T::value_type> >::type * = 0);
00200
00201 template <class T>
00202 std::string dumpint(T const & v,
00203 typename boost::enable_if<boost::is_unsigned<typename T::value_type> >::type * = 0);
00204
00205 #endif
00206
00237 class IndentHelper
00238 {
00239 static unsigned int static_level;
00240 unsigned int instance_level;
00241 public:
00242
00243 IndentHelper();
00244
00245 ~IndentHelper();
00246
00248 void increase();
00249
00250 unsigned int level() const;
00251 };
00252
00256 std::ostream & operator<<(std::ostream & os, IndentHelper const & indent);
00257
00258 }}
00259
00260
00261 #include "Format.cci"
00262
00263 #include "Format.cti"
00264 #endif
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275