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. | |
Public Member Functions | |
FloatContainerFormatter (const unsigned int p=2, const int w=-1) | |
FloatContainerFormatter & | operator() (const unsigned int p, const int w) |
FloatContainerFormatter & | operator() (const Container &c) |
FloatContainerFormatter & | operator() (Container &c, const unsigned int p, const int w) |
FloatContainerFormatter & | precision (const unsigned int p) |
Sets the precision format parameter. | |
unsigned int | precision () const |
Access the current precision used by this formatter. | |
FloatContainerFormatter & | width (const int w) |
Sets the width format parameter. | |
virtual | ~FloatContainerFormatter () |
Private Member Functions | |
long | digits (value_type min_coeff, value_type max_coeff) |
Private Attributes | |
const Container * | container |
Format< value_type > | format |
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) ecl_assert_throw_decl(StandardException) |
Insertion operator for sending the formatter to an output stream. |
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
Container | : the underlying fixed size float or double array. |
Note, the above don't link properly to the partial specialisations. Look for them in the ecl::formatters namespace.
Definition at line 67 of file common/formatters.hpp.
typedef Container::value_type ecl::formatters::FloatContainerFormatter< Container >::value_type |
Catches the container element's type.
Definition at line 72 of file common/formatters.hpp.
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.
p | : the number of decimal places of precision [default : 2]. |
w | : width [default : no width constraint] |
Definition at line 80 of file common/formatters.hpp.
virtual ecl::formatters::FloatContainerFormatter< Container >::~FloatContainerFormatter | ( | ) | [inline, virtual] |
Definition at line 90 of file common/formatters.hpp.
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.
min_coeff | : the minimum value in the array. |
max_coeff | : the maximum value in the array. |
Definition at line 193 of file common/formatters.hpp.
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.
p | : the number of decimal places of precision. |
w | : the width to use for the inserted float. |
Definition at line 126 of file common/formatters.hpp.
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.
c | : the input container to be formatted. |
Definition at line 137 of file common/formatters.hpp.
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).
c | : the input container to be formatted. |
p | : the number of decimal places of precision. |
w | : the width to use for the inserted float. |
Definition at line 151 of file common/formatters.hpp.
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.
p | : the number of decimal places of precision. |
Definition at line 100 of file common/formatters.hpp.
unsigned int ecl::formatters::FloatContainerFormatter< Container >::precision | ( | ) | const [inline] |
Access the current precision used by this formatter.
Returns the current precision setting.
Definition at line 118 of file common/formatters.hpp.
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.
w | : the width to use for the inserted float [-1 for automatic resizing of cells]. |
Definition at line 111 of file common/formatters.hpp.
OutputStream& operator<< | ( | OutputStream & | ostream, |
FloatContainerFormatter< Container_ > & | formatter | ||
) | [friend] |
Insertion operator for sending the formatter to an output stream.
ostream | : the output stream. |
formatter | : the formatter to be inserted. |
StandardException | : throws if the formatter is used multiply in one stream operation [debug mode only]. |
Definition at line 216 of file common/formatters.hpp.
const Container* ecl::formatters::FloatContainerFormatter< Container >::container [private] |
Definition at line 180 of file common/formatters.hpp.
Format< value_type > ecl::formatters::FloatContainerFormatter< Container >::format [private] |
Definition at line 179 of file common/formatters.hpp.
int ecl::formatters::FloatContainerFormatter< Container >::old_precision [private] |
Definition at line 176 of file common/formatters.hpp.
int ecl::formatters::FloatContainerFormatter< Container >::prm_width [private] |
Definition at line 177 of file common/formatters.hpp.
bool ecl::formatters::FloatContainerFormatter< Container >::ready_to_format [private] |
Definition at line 181 of file common/formatters.hpp.
int ecl::formatters::FloatContainerFormatter< Container >::tmp_width [private] |
Definition at line 177 of file common/formatters.hpp.
int* ecl::formatters::FloatContainerFormatter< Container >::width_ptr [private] |
Definition at line 178 of file common/formatters.hpp.