Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
ecl::interfaces::FormatFloat< Number > Class Template Reference

Formatter for float types. More...

#include <floats.hpp>

Public Member Functions

FormatFloat< Number > & align (const ecl::Alignment a)
 Sets the alignment format parameter. More...
 
FormatFloat< Number > & base (const ecl::FloatBase b)
 Sets the base notation to use. More...
 
 FormatFloat (const int w=-1, const unsigned int p=4, const ecl::Alignment a=NoAlign, const ecl::FloatBase b=Fixed)
 
FormatFloat< Number > & operator() (const Number n)
 
FormatFloat< Number > & operator() (const Number n, const unsigned int p, const int w)
 
FormatFloat< Number > & operator() (const Number n, const unsigned int p, const int w, const ecl::Alignment align, const ecl::FloatBase b)
 
FormatFloat< Number > & operator() (const unsigned int p, const int w, const ecl::Alignment align, const ecl::FloatBase b)
 
FormatFloat< Number > & operator() (unsigned int p, const int w)
 
int precision ()
 Returns the current precision setting. More...
 
FormatFloat< Number > & precision (const unsigned int p)
 Sets the precision format parameter. More...
 
int width ()
 Returns the current precision setting. More...
 
FormatFloat< Number > & width (const int w)
 Sets the width format parameter. More...
 
virtual ~FormatFloat ()
 

Protected Member Functions

template<typename OutputStream >
void formatFixed (OutputStream &ostream) const
 
template<typename OutputStream >
void formatSci (OutputStream &ostream) const
 
template<typename OutputStream >
void pad (int n, OutputStream &ostream) const
 
template<typename OutputStream >
void postPad (int n, OutputStream &ostream) const
 
template<typename OutputStream >
void prePad (int n, OutputStream &ostream) const
 

Protected Attributes

ecl::Alignmentalignment_
 
ecl::FloatBasebase_
 
int * precision_
 
ecl::Alignment prm_alignment
 
ecl::FloatBase prm_base
 
int prm_precision
 
int prm_width
 
bool ready_to_format
 
ecl::Alignment tmp_alignment
 
ecl::FloatBase tmp_base
 
int tmp_precision
 
int tmp_width
 
Number value_
 
int * width_
 

Friends

template<typename OutputStream , typename N >
OutputStream & operator<< (OutputStream &ostream, FormatFloat< N > &formatter)
 

Detailed Description

template<typename Number>
class ecl::interfaces::FormatFloat< Number >

Formatter for float types.

Default formatter for float types. For convenience, use the individual Format<float|double> classes that inherit this one instead.

Definition at line 67 of file floats.hpp.

Constructor & Destructor Documentation

◆ FormatFloat()

template<typename Number >
ecl::interfaces::FormatFloat< Number >::FormatFloat ( const int  w = -1,
const unsigned int  p = 4,
const ecl::Alignment  a = NoAlign,
const ecl::FloatBase  b = Fixed 
)
inline

Default constructor. Initialises the format tags for width, precision, alignment and base.

Parameters
w: width (default - no width constraints)
p: the number of decimal places of precision (default - 4)
a: the textual alignment (default - no alignment constraints)
b: the base format for the floating point representation (default - fixed)

Definition at line 81 of file floats.hpp.

◆ ~FormatFloat()

template<typename Number >
virtual ecl::interfaces::FormatFloat< Number >::~FormatFloat ( )
inlinevirtual

Definition at line 92 of file floats.hpp.

Member Function Documentation

◆ align()

template<typename Number >
FormatFloat< Number > & ecl::interfaces::FormatFloat< Number >::align ( const ecl::Alignment  a)

Sets the alignment format parameter.

Sets the alignment format parameter.

Parameters
a: the textual alignment.
Returns
FormatFloat& : this formatter readied for use with a stream.

Sets the alignment format parameter. This aligns the text output in the text window which has a width specified by the width parameter.

Parameters
a: the aligning property for the output text.
See also
Alignment

Definition at line 280 of file floats.hpp.

◆ base()

template<typename Number >
FormatFloat< Number > & ecl::interfaces::FormatFloat< Number >::base ( const ecl::FloatBase  b)

Sets the base notation to use.

Sets the base notation to use (fixed or scientific).

Parameters
b: the base format for the floating point representation.
Returns
FormatFloat& : this formatter readied for use with a stream.

Sets the base format. For floating point values, this can be fixed, exponential or scientific.

Parameters
b: the base representation used for the output.
See also
FloatBase

Definition at line 254 of file floats.hpp.

◆ formatFixed()

template<typename Number >
template<typename OutputStream >
void ecl::interfaces::FormatFloat< Number >::formatFixed ( OutputStream &  ostream) const
protected

Definition at line 371 of file floats.hpp.

◆ formatSci()

template<typename Number >
template<typename OutputStream >
void ecl::interfaces::FormatFloat< Number >::formatSci ( OutputStream &  ostream) const
protected

Definition at line 403 of file floats.hpp.

◆ operator()() [1/5]

template<typename Number >
FormatFloat< Number > & ecl::interfaces::FormatFloat< Number >::operator() ( const Number  n)

Convenient stream formatter. This function directly formats the specified input value with the stored settings.

Format<float> format;
cout << format(3,4)(3.5215233) << endl;
Parameters
n: the input value to be formatted.
Returns
FormatFloat& : this formatter readied for use with a stream.

Definition at line 316 of file floats.hpp.

◆ operator()() [2/5]

template<typename Number >
FormatFloat< Number > & ecl::interfaces::FormatFloat< Number >::operator() ( const Number  n,
const unsigned int  p,
const int  w 
)

Convenient stream formatter. This member directly formats the specified input value with the supplied/temporary parameters.

Parameters
n: the input value to be formatted.
p: the number of decimal places of precision.
w: the total width of the text output.

Definition at line 326 of file floats.hpp.

◆ operator()() [3/5]

template<typename Number >
FormatFloat< Number > & ecl::interfaces::FormatFloat< Number >::operator() ( const Number  n,
const unsigned int  p,
const int  w,
const ecl::Alignment  align,
const ecl::FloatBase  b 
)

Convenient stream formatter. This member directly formats the specified input value with the supplied/temporary parameters.

Parameters
n: the input value to be formatted.
p: the number of decimal places of precision.
w: the total width of the text output.
align: the aligning property for the output text.
b: the base representation used for the output.

Definition at line 346 of file floats.hpp.

◆ operator()() [4/5]

template<typename Number >
FormatFloat< Number > & ecl::interfaces::FormatFloat< Number >::operator() ( const unsigned int  p,
const int  w,
const ecl::Alignment  align,
const ecl::FloatBase  b 
)

Convenient stream format parameter setter. This one permanently configures all parameters.

Parameters
p: the number of decimal places of precision.
w: the total width of the text output.
align: the aligning property for the output text.
b: the base representation used for the output.
Returns
FormatFloat& : this formatter readied for use with a stream.

Definition at line 303 of file floats.hpp.

◆ operator()() [5/5]

template<typename Number >
FormatFloat< Number > & ecl::interfaces::FormatFloat< Number >::operator() ( unsigned int  p,
const int  w 
)

Convenient stream format parameter setter. This one permanently configures the width and precision as specified.

Parameters
p: the number of decimal places of precision.
w: the total width of the text output.
Returns
FormatFloat& : this formatter readied for use with a stream.

Definition at line 295 of file floats.hpp.

◆ pad()

template<typename Number >
template<typename OutputStream >
void ecl::interfaces::FormatFloat< Number >::pad ( int  n,
OutputStream &  ostream 
) const
protected

Definition at line 441 of file floats.hpp.

◆ postPad()

template<typename Number >
template<typename OutputStream >
void ecl::interfaces::FormatFloat< Number >::postPad ( int  n,
OutputStream &  ostream 
) const
protected

Definition at line 426 of file floats.hpp.

◆ precision() [1/2]

template<typename Number >
int ecl::interfaces::FormatFloat< Number >::precision ( )
inline

Returns the current precision setting.

Returns
int : the precision value.

Definition at line 141 of file floats.hpp.

◆ precision() [2/2]

template<typename Number >
FormatFloat<Number>& ecl::interfaces::FormatFloat< Number >::precision ( const unsigned int  p)
inline

Sets the precision format parameter.

Sets the precision format parameter.

Parameters
p: the number of decimal places of precision.
Returns
FormatFloat& : this formatter readied for use with a stream.

Definition at line 105 of file floats.hpp.

◆ prePad()

template<typename Number >
template<typename OutputStream >
void ecl::interfaces::FormatFloat< Number >::prePad ( int  n,
OutputStream &  ostream 
) const
protected

Definition at line 411 of file floats.hpp.

◆ width() [1/2]

template<typename Number >
int ecl::interfaces::FormatFloat< Number >::width ( )
inline

Returns the current precision setting.

Returns
int : the width value (-1 for no constraint).

Definition at line 148 of file floats.hpp.

◆ width() [2/2]

template<typename Number >
FormatFloat< Number > & ecl::interfaces::FormatFloat< Number >::width ( const int  w)

Sets the width format parameter.

Sets the width format parameter.

Parameters
w: the width to use for the inserted float (-1 is no width constraint).
Returns
FormatFloat& : this formatter readied for use with a stream.

Sets the width format parameter. Setting this to -1 will turn off width formatting constraints.

Parameters
w: the total width of the text output.

Definition at line 264 of file floats.hpp.

Friends And Related Function Documentation

◆ operator<<

template<typename Number >
template<typename OutputStream , typename N >
OutputStream& operator<< ( OutputStream &  ostream,
FormatFloat< N > &  formatter 
)
friend

Friend function which allows a stream to act on the formatter to produce the formatted result. This works on normal c++ streams as well as TextStreams.

Parameters
ostream: the stream.
formatter: the formatter with prespecified format parameters and input value.
Returns
OutputStream& : return the stream that was utilised.

Definition at line 453 of file floats.hpp.

Member Data Documentation

◆ alignment_

template<typename Number >
ecl::Alignment* ecl::interfaces::FormatFloat< Number >::alignment_
protected

Definition at line 228 of file floats.hpp.

◆ base_

template<typename Number >
ecl::FloatBase* ecl::interfaces::FormatFloat< Number >::base_
protected

Definition at line 229 of file floats.hpp.

◆ precision_

template<typename Number >
int * ecl::interfaces::FormatFloat< Number >::precision_
protected

Definition at line 227 of file floats.hpp.

◆ prm_alignment

template<typename Number >
ecl::Alignment ecl::interfaces::FormatFloat< Number >::prm_alignment
protected

Definition at line 225 of file floats.hpp.

◆ prm_base

template<typename Number >
ecl::FloatBase ecl::interfaces::FormatFloat< Number >::prm_base
protected

Definition at line 226 of file floats.hpp.

◆ prm_precision

template<typename Number >
int ecl::interfaces::FormatFloat< Number >::prm_precision
protected

Definition at line 224 of file floats.hpp.

◆ prm_width

template<typename Number >
int ecl::interfaces::FormatFloat< Number >::prm_width
protected

Definition at line 223 of file floats.hpp.

◆ ready_to_format

template<typename Number >
bool ecl::interfaces::FormatFloat< Number >::ready_to_format
protected

Definition at line 230 of file floats.hpp.

◆ tmp_alignment

template<typename Number >
ecl::Alignment ecl::interfaces::FormatFloat< Number >::tmp_alignment
protected

Definition at line 225 of file floats.hpp.

◆ tmp_base

template<typename Number >
ecl::FloatBase ecl::interfaces::FormatFloat< Number >::tmp_base
protected

Definition at line 226 of file floats.hpp.

◆ tmp_precision

template<typename Number >
int ecl::interfaces::FormatFloat< Number >::tmp_precision
protected

Definition at line 224 of file floats.hpp.

◆ tmp_width

template<typename Number >
int ecl::interfaces::FormatFloat< Number >::tmp_width
protected

Definition at line 223 of file floats.hpp.

◆ value_

template<typename Number >
Number ecl::interfaces::FormatFloat< Number >::value_
protected

Definition at line 231 of file floats.hpp.

◆ width_

template<typename Number >
int* ecl::interfaces::FormatFloat< Number >::width_
protected

Definition at line 227 of file floats.hpp.


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


ecl_formatters
Author(s): Daniel Stonier
autogenerated on Wed Mar 2 2022 00:16:27