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

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

#include <formatters.hpp>

List of all members.

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)
FloatContainerFormatteroperator() (const unsigned int p, const int w)
FloatContainerFormatteroperator() (const Container &c)
FloatContainerFormatteroperator() (Container &c, const unsigned int p, const int w)
FloatContainerFormatterprecision (const unsigned int p)
 Sets the precision format parameter.
unsigned int precision () const
 Access the current precision used by this formatter.
FloatContainerFormatterwidth (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_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) ecl_assert_throw_decl(StandardException)
 Insertion operator for sending the formatter to an output stream.

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 67 of file common/formatters.hpp.


Member Typedef Documentation

template<typename Container>
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.


Constructor & Destructor Documentation

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 80 of file common/formatters.hpp.

template<typename Container>
virtual ecl::formatters::FloatContainerFormatter< Container >::~FloatContainerFormatter ( ) [inline, virtual]

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


Member Function Documentation

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 193 of file common/formatters.hpp.

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 126 of file common/formatters.hpp.

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 137 of file common/formatters.hpp.

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 151 of file common/formatters.hpp.

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 100 of file common/formatters.hpp.

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 118 of file common/formatters.hpp.

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 111 of file common/formatters.hpp.


Friends And Related Function Documentation

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 216 of file common/formatters.hpp.


Member Data Documentation

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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


ecl_containers
Author(s): Daniel Stonier
autogenerated on Wed Aug 26 2015 11:27:29