fiber
Loading...
Searching...
No Matches
fiber::FormatFloat Struct Reference

Formats an floating point for further printing use. More...

#include <OStream.hpp>

Inheritance diagram for fiber::FormatFloat:
fiber::FormatFloatParams fiber::FormatIntParams fiber::FormatStrParams fiber::_FormatUIntParams

Public Types

using value_type = float
 

Public Member Functions

constexpr FormatFloat ()=default
 
constexpr FormatFloat (const FormatFloat &)=default
 
constexpr FormatFloatoperator= (const FormatFloat &)=default
 
template<typename Float, typename std::enable_if< std::is_floating_point< Float >::value, int >::type = 0>
constexpr FormatFloat (Float value)
 
constexpr FormatFloatuse_thousands (bool b=true)
 enables thousand characters
 
constexpr FormatFloatthousands (char c=',')
 enable thousands seperator
 
constexpr FormatFloatcomma (char c)
 sets the comma value (default: '.')
 
constexpr FormatFloatfsign (bool b=true)
 forces the printing of the sign, even if it is positive
 
constexpr FormatFloatmwidth (int mw)
 sets the minimum width the the number should occupy in text - the rest will be filled with padding/fill characters
 
constexpr FormatFloatfill (char c)
 sets the padding/fill character
 
constexpr FormatFloatpad_sign (bool b=true)
 enables padding for the sign character
 
constexpr FormatFloatright ()
 flushright: sets the alignment to right - padding will be applied to the left
 
constexpr FormatFloatleft ()
 flushleft: sets the alignment to left - padding will be applied to the right
 
constexpr FormatFloatcenter ()
 center: sets the alignment to center - padding will be applied to both sides
 
constexpr FormatFloatsci ()
 formats the number in scientific notation: exponent so that there is always one digit before the comma.
 
constexpr FormatFloateng ()
 formats the number in engineering notation: exponent in magnitudes of three
 
constexpr FormatFloatfull ()
 formats the number so that it is shown in its full length without the use of exponents
 
constexpr FormatFloatdecimals (int d)
 sets the precision, aka. the number of total digits that will be printed before and after the comma
 
constexpr FormatFloatfcomma (bool b=true)
 force a comma in every print, even if it is not needed to display the number
 
constexpr FormatFloatfdeci (bool b=true)
 force the printing of all decimals, even if they are zero
 
constexpr FormatFloatfexp (bool b=true)
 force the printing of the exponent, even if it is zero
 
constexpr FormatFloatfexpsign (bool b=true)
 force the sign of the exponent, even if it is positive
 
- Public Member Functions inherited from fiber::FormatFloatParams
constexpr FormatFloatParams ()=default
 
constexpr FormatFloatParams (const FormatFloatParams &)=default
 
constexpr FormatFloatParamsoperator= (const FormatFloatParams &)=default
 
constexpr FormatFloatParams (const FormatStrParams &params)
 
constexpr FormatFloatParamsoperator= (const FormatStrParams &params)
 
constexpr FormatFloatParams (const FormatIntParams &params)
 
constexpr FormatFloatParamsoperator= (const FormatIntParams &params)
 
- Public Member Functions inherited from fiber::FormatIntParams
constexpr FormatIntParams ()=default
 
constexpr FormatIntParams (const FormatIntParams &)=default
 
constexpr FormatIntParamsoperator= (const FormatIntParams &)=default
 
constexpr FormatIntParams (const FormatStrParams &params)
 
constexpr FormatIntParamsoperator= (const FormatStrParams &params)
 

Static Public Member Functions

template<typename Float, typename std::enable_if< std::is_floating_point< Float >::value, int >::type = 0>
static constexpr FormatFloat like (Float value, const FormatFloatParams &params)
 
template<typename Float, typename std::enable_if< std::is_floating_point< Float >::value, int >::type = 0>
static constexpr FormatFloat like (Float value, const FormatIntParams &params)
 
template<typename Float, typename std::enable_if< std::is_floating_point< Float >::value, int >::type = 0>
static constexpr FormatFloat like (Float value, const FormatStrParams &params)
 

Public Attributes

value_type _value = 0
 
- Public Attributes inherited from fiber::FormatFloatParams
FloatRepresentation _representation = FloatRepresentation::Engineering
 
char _comma = '.'
 
unsigned int _decimals = 3
 
bool _force_comma = false
 
bool _force_decimals = false
 
bool _force_exponent = false
 
bool _force_exponent_sign = false
 
- Public Attributes inherited from fiber::FormatIntParams
bool _force_sign = false
 
bool _pad_sign = false
 
- Public Attributes inherited from fiber::FormatStrParams
AlignmentLRC _alignment = AlignmentLRC::Right
 
int _mwidth = 0
 
char _fill = ' '
 
- Public Attributes inherited from fiber::_FormatUIntParams
char _thousands_char = ','
 
bool _use_thousands = false
 

Detailed Description

Formats an floating point for further printing use.

Member Typedef Documentation

◆ value_type

Constructor & Destructor Documentation

◆ FormatFloat() [1/3]

fiber::FormatFloat::FormatFloat ( )
constexprdefault

◆ FormatFloat() [2/3]

fiber::FormatFloat::FormatFloat ( const FormatFloat & )
constexprdefault

◆ FormatFloat() [3/3]

template<typename Float, typename std::enable_if< std::is_floating_point< Float >::value, int >::type = 0>
fiber::FormatFloat::FormatFloat ( Float value)
inlineexplicitconstexpr

Member Function Documentation

◆ center()

FormatFloat & fiber::FormatFloat::center ( )
inlineconstexpr

center: sets the alignment to center - padding will be applied to both sides

◆ comma()

FormatFloat & fiber::FormatFloat::comma ( char c)
inlineconstexpr

sets the comma value (default: '.')

◆ decimals()

FormatFloat & fiber::FormatFloat::decimals ( int d)
inlineconstexpr

sets the precision, aka. the number of total digits that will be printed before and after the comma

◆ eng()

FormatFloat & fiber::FormatFloat::eng ( )
inlineconstexpr

formats the number in engineering notation: exponent in magnitudes of three

◆ fcomma()

FormatFloat & fiber::FormatFloat::fcomma ( bool b = true)
inlineconstexpr

force a comma in every print, even if it is not needed to display the number

◆ fdeci()

FormatFloat & fiber::FormatFloat::fdeci ( bool b = true)
inlineconstexpr

force the printing of all decimals, even if they are zero

◆ fexp()

FormatFloat & fiber::FormatFloat::fexp ( bool b = true)
inlineconstexpr

force the printing of the exponent, even if it is zero

◆ fexpsign()

FormatFloat & fiber::FormatFloat::fexpsign ( bool b = true)
inlineconstexpr

force the sign of the exponent, even if it is positive

◆ fill()

FormatFloat & fiber::FormatFloat::fill ( char c)
inlineconstexpr

sets the padding/fill character

◆ fsign()

FormatFloat & fiber::FormatFloat::fsign ( bool b = true)
inlineconstexpr

forces the printing of the sign, even if it is positive

◆ full()

FormatFloat & fiber::FormatFloat::full ( )
inlineconstexpr

formats the number so that it is shown in its full length without the use of exponents

◆ left()

FormatFloat & fiber::FormatFloat::left ( )
inlineconstexpr

flushleft: sets the alignment to left - padding will be applied to the right

◆ like() [1/3]

template<typename Float, typename std::enable_if< std::is_floating_point< Float >::value, int >::type = 0>
static constexpr FormatFloat fiber::FormatFloat::like ( Float value,
const FormatFloatParams & params )
inlinestaticconstexpr

◆ like() [2/3]

template<typename Float, typename std::enable_if< std::is_floating_point< Float >::value, int >::type = 0>
static constexpr FormatFloat fiber::FormatFloat::like ( Float value,
const FormatIntParams & params )
inlinestaticconstexpr

◆ like() [3/3]

template<typename Float, typename std::enable_if< std::is_floating_point< Float >::value, int >::type = 0>
static constexpr FormatFloat fiber::FormatFloat::like ( Float value,
const FormatStrParams & params )
inlinestaticconstexpr

◆ mwidth()

FormatFloat & fiber::FormatFloat::mwidth ( int mw)
inlineconstexpr

sets the minimum width the the number should occupy in text - the rest will be filled with padding/fill characters

◆ operator=()

FormatFloat & fiber::FormatFloat::operator= ( const FormatFloat & )
constexprdefault

◆ pad_sign()

FormatFloat & fiber::FormatFloat::pad_sign ( bool b = true)
inlineconstexpr

enables padding for the sign character

◆ right()

FormatFloat & fiber::FormatFloat::right ( )
inlineconstexpr

flushright: sets the alignment to right - padding will be applied to the left

◆ sci()

FormatFloat & fiber::FormatFloat::sci ( )
inlineconstexpr

formats the number in scientific notation: exponent so that there is always one digit before the comma.

◆ thousands()

FormatFloat & fiber::FormatFloat::thousands ( char c = ',')
inlineconstexpr

enable thousands seperator

Parameters
cthe character to be used for thousands seperator (default: ',')

◆ use_thousands()

FormatFloat & fiber::FormatFloat::use_thousands ( bool b = true)
inlineconstexpr

enables thousand characters

Member Data Documentation

◆ _value

value_type fiber::FormatFloat::_value = 0

The documentation for this struct was generated from the following file: