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. More...
 
template<class T >
streamable_type senf::format::dumpint (T const &v)
 Dump integer value with internal representation. More...
 

Detailed Description

Function Documentation

◆ dumpint()

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)

◆ eng()

streamable_type senf::format::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:
    \par \c std::\c 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 \c ajustfield setting (changed
        with \c std::left, \c std:;right or \c std::internal). If the \c adjustfield is set to \c
        internal, padding is added between the sign and the number.

    \par \c std::\c 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.

    \par \c std::\c showbase, \c std::\c noshowbase
        If the \c showbase flag is set, Instead of writing out the scale exponent in numeric
        form, output the corresponding SI prefix.

    \par \c std::\c showpos, \c std::\c noshowpos
        If the \c showpos flag is set, positive values will have a '+' sign.

    \par \c std::\c showpoint, \c std::\c noshowpoint
        If the \c showpoint flag is set, the exponent will be output even if it is 0. Otherwise,
        if \c width is set, the exponent will be replaced with 4 blanks.

    \par \c std::\c uppercase, \c std::\c nouppercase
        If the \c uppercase flag is set, the exponent letter will be an uppercase 'E' instead of
        'e'. SI prefixes are \e not uppercased, since some SI prefixes differ only in case.

    \par \c std::\c setfill
        The fill character is honored for the outside padding but \e not for the internal
        padding.

    \par \c std::\c left, \c std::\c internal, \c std::\c 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"
    \param[in] v value
    \param[in] d optional delta