Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
ecl::formatters::FloatContainerFormatter< Container > Class Template Reference

Parent interface for formatters of fixed size float/double containers. More...

#include <formatters.hpp>

Public Types

typedef Container::value_type value_type
 Catches the container element's type. More...
 

Public Member Functions

 FloatContainerFormatter (const unsigned int p=2, const int w=-1)
 
FloatContainerFormatteroperator() (const Container &c)
 
FloatContainerFormatteroperator() (const unsigned int p, const int w)
 
FloatContainerFormatteroperator() (Container &c, const unsigned int p, const int w)
 
unsigned int precision () const
 Access the current precision used by this formatter. More...
 
FloatContainerFormatterprecision (const unsigned int p)
 Sets the precision format parameter. More...
 
FloatContainerFormatterwidth (const int w)
 Sets the width format parameter. More...
 
virtual ~FloatContainerFormatter ()
 

Private Member Functions

long digits (value_type min_coeff, value_type max_coeff)
 

Private Attributes

const Container * container
 
Format< value_typeformat
 
int old_precision
 
int prm_width
 
bool ready_to_format
 
int tmp_width
 
int * width_ptr
 

Friends

template<typename OutputStream , typename Container_ >
OutputStream & operator<< (OutputStream &ostream, FloatContainerFormatter< Container_ > &formatter)
 Insertion operator for sending the formatter to an output stream. More...
 

Detailed Description

template<typename Container>
class ecl::formatters::FloatContainerFormatter< Container >

Parent interface for formatters of fixed size float/double containers.

This defines the common interface to be shared by fixed size float/double containers. It only allows configuration of width and precision to be used to format the elements of the container. Note that if the width is set to -1 (the default), this class automatically configures an appropriate width by scanning the elements within and setting it to the minimum width necessary to display all elements properly.

Do not use this class directly, rather call it via either the Container type or Format classes explicitly. This makes the code more readable. e.g.

Array<float>::Formatter format_array_1;
Format< Array<float,4> > format_array_2; // same thing
Template Parameters
Container: the underlying fixed size float or double array.
See also
ecl::formatters::Format< Array<float,N>, ecl::formatters::Format<Array<double,N>>.

Note, the above don't link properly to the partial specialisations. Look for them in the ecl::formatters namespace.

Definition at line 79 of file common/formatters.hpp.

Member Typedef Documentation

◆ value_type

template<typename Container >
typedef Container::value_type ecl::formatters::FloatContainerFormatter< Container >::value_type

Catches the container element's type.

Definition at line 94 of file common/formatters.hpp.

Constructor & Destructor Documentation

◆ FloatContainerFormatter()

template<typename Container >
ecl::formatters::FloatContainerFormatter< Container >::FloatContainerFormatter ( const unsigned int  p = 2,
const int  w = -1 
)
inline

Constructor - can be used to define the precision required for the formatter's elements.

Parameters
p: the number of decimal places of precision [default : 2].
w: width [default : no width constraint]

Definition at line 102 of file common/formatters.hpp.

◆ ~FloatContainerFormatter()

template<typename Container >
virtual ecl::formatters::FloatContainerFormatter< Container >::~FloatContainerFormatter ( )
inlinevirtual

Definition at line 112 of file common/formatters.hpp.

Member Function Documentation

◆ digits()

template<typename Container >
long ecl::formatters::FloatContainerFormatter< Container >::digits ( value_type  min_coeff,
value_type  max_coeff 
)
private

Compute the integral width. This accepts the minimum and maximum values in the array from which a minimum width that provides a common width for every element in the array to be fully displayed is determined.

Parameters
min_coeff: the minimum value in the array.
max_coeff: the maximum value in the array.
Returns
long : the width to use for the integral part of the co-efficients.

Definition at line 205 of file common/formatters.hpp.

◆ operator()() [1/3]

template<typename Container >
FloatContainerFormatter& ecl::formatters::FloatContainerFormatter< Container >::operator() ( const Container &  c)
inline

Convenient stream formatter. This function directly readies the formatter with the specified container and the stored (permanent) settings.

Format< Array<float,N> > format;
cout << format(array) << endl;
Parameters
c: the input container to be formatted.
Returns
FormatFloat& : this formatter readied for use with a stream.

Definition at line 159 of file common/formatters.hpp.

◆ operator()() [2/3]

template<typename Container >
FloatContainerFormatter& ecl::formatters::FloatContainerFormatter< Container >::operator() ( const unsigned int  p,
const int  w 
)
inline

Permanently sets the stream's precision format. This is simply a convenient version of the precision(p) method.

Parameters
p: the number of decimal places of precision.
w: the width to use for the inserted float.
Returns
FloatContainerFormatter& : this formatter readied for use with a stream.

Definition at line 148 of file common/formatters.hpp.

◆ operator()() [3/3]

template<typename Container >
FloatContainerFormatter& ecl::formatters::FloatContainerFormatter< Container >::operator() ( Container &  c,
const unsigned int  p,
const int  w 
)
inline

Convenient stream formatter. This function directly readies the formatter with the specified container and configures a temporary setting for the precision (one-shot).

Format< Array<float,N> > format;
cout << format(array,2) << endl;
Parameters
c: the input container to be formatted.
p: the number of decimal places of precision.
w: the width to use for the inserted float.
Returns
FormatFloat& : this formatter readied for use with a stream.

Definition at line 173 of file common/formatters.hpp.

◆ precision() [1/2]

template<typename Container >
unsigned int ecl::formatters::FloatContainerFormatter< Container >::precision ( ) const
inline

Access the current precision used by this formatter.

Returns the current precision setting.

Returns
int : the number of decimal places of precision.

Definition at line 140 of file common/formatters.hpp.

◆ precision() [2/2]

template<typename Container >
FloatContainerFormatter& ecl::formatters::FloatContainerFormatter< Container >::precision ( const unsigned int  p)
inline

Sets the precision format parameter.

Use this to set the precision of the displayed output.

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

Definition at line 122 of file common/formatters.hpp.

◆ width()

template<typename Container >
FloatContainerFormatter& ecl::formatters::FloatContainerFormatter< Container >::width ( const int  w)
inline

Sets the width format parameter.

Use this to configure the width of the displayed output. The formatter can be instructed to automatically determine a width suitable for all elements by setting this value to -1.

Parameters
w: the width to use for the inserted float [-1 for automatic resizing of cells].
Returns
FloatContainerFormatter& : this formatter readied for use with a stream.

Definition at line 133 of file common/formatters.hpp.

Friends And Related Function Documentation

◆ operator<<

template<typename Container >
template<typename OutputStream , typename Container_ >
OutputStream& operator<< ( OutputStream &  ostream,
FloatContainerFormatter< Container_ > &  formatter 
)
friend

Insertion operator for sending the formatter to an output stream.

Parameters
ostream: the output stream.
formatter: the formatter to be inserted.
Returns
OutputStream : continue streaming with the updated output stream.
Exceptions
StandardException: throws if the formatter is used multiply in one stream operation [debug mode only].

Definition at line 228 of file common/formatters.hpp.

Member Data Documentation

◆ container

template<typename Container >
const Container* ecl::formatters::FloatContainerFormatter< Container >::container
private

Definition at line 202 of file common/formatters.hpp.

◆ format

template<typename Container >
Format< value_type > ecl::formatters::FloatContainerFormatter< Container >::format
private

Definition at line 201 of file common/formatters.hpp.

◆ old_precision

template<typename Container >
int ecl::formatters::FloatContainerFormatter< Container >::old_precision
private

Definition at line 198 of file common/formatters.hpp.

◆ prm_width

template<typename Container >
int ecl::formatters::FloatContainerFormatter< Container >::prm_width
private

Definition at line 199 of file common/formatters.hpp.

◆ ready_to_format

template<typename Container >
bool ecl::formatters::FloatContainerFormatter< Container >::ready_to_format
private

Definition at line 203 of file common/formatters.hpp.

◆ tmp_width

template<typename Container >
int ecl::formatters::FloatContainerFormatter< Container >::tmp_width
private

Definition at line 199 of file common/formatters.hpp.

◆ width_ptr

template<typename Container >
int* ecl::formatters::FloatContainerFormatter< Container >::width_ptr
private

Definition at line 200 of file common/formatters.hpp.


The documentation for this class was generated from the following file:
ecl::formatters::FloatContainerFormatter::format
Format< value_type > format
Definition: common/formatters.hpp:201
ecl::Array::Formatter
formatters::ArrayFormatter< Type, Size > Formatter
Formatter for this class.
Definition: array_no_mem_check.hpp:129


ecl_containers
Author(s): Daniel Stonier
autogenerated on Wed Mar 2 2022 00:16:34