Formating


Classes

class   senf::format::IndentHelper
  Helper class to easily achieve indent levels. More...

Functions

streamable_type  senf::format::eng (float v, float d=NAN)
  Format value in engineering representation.
template<class T >
streamable_type  senf::format::dumpint (T const &v)
  Dump integer value with internal representation.

Function Documentation

template<class T >
streamable_type senf::format::
dumpint ( T const &  v )

Dump integer value with internal representation.

senf::format::dumpint() will output a signed or unsigned numeric argument in the following representations:

  • hexadecimal notation
  • decimal notation
  • byte values interpreted as ASCII characters (in network byte order)
All fields will be padded depending on the size of the type to a byte boundary (e.g. a 32bit integer type will be padded to 8 hex-digits, 10 decimal digits and 4 ASCII characters)

senf::format::eng::
eng ( float  v,
float  d = NAN )

Format value in engineering representation.

The engineering representation is an exponential representation. Exponents however are always multiples of 3:

123.45   -> 123.450e+00
123.45e2 ->  12.345e+03

Additionally, an optional delta value may be displayed:

123.45+-1.34e+03

senf::format::eng supports several formating options:

std::setw
If the width is set >0, the output will be padded internally. If the width is set to more than the minimal required output width including internal padding, the output is padded on the left or right depending on the streams ajustfield setting (changed with std::left, std:;right or std::interal). If the adjustfield is set to internal, padding is added between the sign and the number.
std::setprecision
The default stream precision is 6. This will schow values with 6 significant digits. The count includes the number of digits in front of the decimal point.
std::showbase, std::noshowbase
If the showbase flag is set, Instead of writing out the scale exponent in numeric form, output the corresponding SI prefix.
std::showpos, std::noshowpos
If the showpos flag is set, positive values will have a '+' sign.
std::showpoint, std::noshowpoint
If the showpoint flag is set, the exponent will be output even if it is 0. Otherwise, if width is set, the exponent will be replaced with 4 blanks.
std::uppercase, std::nouppercase
If the uppercase flag is set, the exponent letter will be an uppercase 'E' instead of 'e'. SI prefixes are not uppercased, since some SI prefixes differ only in case.
std::setfill
The fill character is honored for the outside padding but not for the internal padding.
std::left, std::internal, std::right
The alignment flags specify the external padding but do not affect the internal padding.
All these flags may optionally be set by calling members of the senf::format::eng() return value with the same name.

Examples:

os << senf::format::eng(1.23);
  -> "1.230"

os << std::setw(1) << senf::format::eng(1.23);
  -> "   1.230    "

os << std::setw(25) << std::setprecision(5) << std::showpos << std::uppercase
   << std::internal << senf::format::eng(12345,67);
  -> "+       12.35+-000.07E+03"

os << std::showbase << senf::format::eng(12345,67);
  -> "12.345+-0.067k"

senf::str(senf::format::eng(12.345,67).setw().setprecision(5).showpoint().uppercase())
  -> "  12.35+-67.00E+00"
Parameters:
[in]  v  value
[in]  d  optional delta

Definition at line 36 of file Format.cci.