Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
ecl::Format< std::string > Class Template Reference

Formatter for string types. More...

#include <strings.hpp>

Public Member Functions

Format< std::string > & align (Alignment a)
 
 Format (int w=-1, Alignment a=NoAlign)
 
Format< std::string > & operator() (int w, Alignment a)
 
Format< std::string > & operator() (const std::string &input_string)
 
Format< std::string > & operator() (const std::string &input_string, int w)
 
Format< std::string > & operator() (const std::string &input_string, int w, Alignment a)
 
Format< std::string > & width (int w)
 
virtual ~Format ()
 

Private Member Functions

template<typename OutputStream >
void format (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
 

Private Attributes

Alignment alignment_
 
bool ready_to_format
 
std::string s
 
int width_
 

Friends

template<typename OutputStream >
OutputStream & operator<< (OutputStream &ostream, Format< std::string > &formatter) ecl_assert_throw_decl(StandardException)
 

Detailed Description

template<>
class ecl::Format< std::string >

Formatter for string types.

Default formatter for string types. This is pretty slow since we're using strings, but its convenient when speed is not an issue.

Definition at line 42 of file strings.hpp.

Constructor & Destructor Documentation

ecl::Format< std::string >::Format ( int  w = -1,
Alignment  a = NoAlign 
)
inline

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

Parameters
w: width (default - no width constraints)
a: the textual alignment (default - no alignment constraints)

Definition at line 52 of file strings.hpp.

virtual ecl::Format< std::string >::~Format ( )
inlinevirtual

Definition at line 53 of file strings.hpp.

Member Function Documentation

Format<std::string>& ecl::Format< std::string >::align ( Alignment  a)
inline

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 68 of file strings.hpp.

template<typename OutputStream >
void ecl::Format< std::string >::format ( OutputStream &  ostream) const
private

Internal function that does the actual formatting of a format object into a stream.

Parameters
ostream: the stream to be inserted into.

Definition at line 174 of file strings.hpp.

Format< std::string > & ecl::Format< std::string >::operator() ( int  w,
Alignment  a 
)

Convenient stream format parameter setter. This one permanently configures the width and alignment as specfied.

Parameters
w: the total width of the text output.
a: the aligning property for the output text.
Returns
Format<String>& : this formatter (for use with streams).

Definition at line 31 of file strings.cpp.

Format< std::string > & ecl::Format< std::string >::operator() ( const std::string &  input_string)

Insert an input value to be formatted when passed to a stream.

Parameters
input_string: the string to be formatted.
Returns
Format<string> : formatting object to be passed back to the stream.

Definition at line 38 of file strings.cpp.

Format< std::string > & ecl::Format< std::string >::operator() ( const std::string &  input_string,
int  w 
)

Temporarily configure the formatter with a width, base combination along with a value to be formatted.

Parameters
input_string: the string to be formatted.
w: the width to be used.
Returns
Format<string> : formatting object to be passed back to the stream.

Definition at line 48 of file strings.cpp.

Format< std::string > & ecl::Format< std::string >::operator() ( const std::string &  input_string,
int  w,
Alignment  a 
)

Temporarily configure the formatter with a complete parameter set along with a value to be formatted.

Parameters
input_string: the string to be formatted.
w: the width to be used.
a: the alignment to be used.
Returns
Format<string> : formatting object to be passed back to the stream.

Definition at line 55 of file strings.cpp.

template<typename OutputStream >
void ecl::Format< std::string >::pad ( int  n,
OutputStream &  ostream 
) const
private

Internally used to pad the output with spaces when requested.

Parameters
n: the number of spaces to pad.
ostream: the streaming operator the formatter is conencted to.

Definition at line 210 of file strings.hpp.

template<typename OutputStream >
void ecl::Format< std::string >::postPad ( int  n,
OutputStream &  ostream 
) const
private

Postpad the output with spaces when requested.

Parameters
n: the number of spaces to pad.
ostream: the streaming operator the formatter is conencted to.

Definition at line 197 of file strings.hpp.

template<typename OutputStream >
void ecl::Format< std::string >::prePad ( int  n,
OutputStream &  ostream 
) const
private

Prepad the output with spaces when requested.

Parameters
n: the number of spaces to pad.
ostream: the streaming operator the formatter is conencted to.

Definition at line 184 of file strings.hpp.

Format<std::string>& ecl::Format< std::string >::width ( int  w)
inline

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 62 of file strings.hpp.

Friends And Related Function Documentation

template<typename OutputStream >
OutputStream& operator<< ( OutputStream &  ostream,
Format< std::string > &  formatter 
)
friend

Insertion operator for formatters. It takes a customised formatter and inserts its current context into the stream. If two formatters are used in succession, it will throw an error (c++ cannot handle two in a single line of streaming). This works on normal c++ streams as well as TextStreams.

Parameters
ostream: the stream to insert the formatted object into.
formatter: the format context.
Returns
OutputStream : a handle to the resultant stream.
Exceptions
StandardException: throws if the formatter is used multiply in one stream operation [debug mode only].

Definition at line 223 of file strings.hpp.

Member Data Documentation

Alignment ecl::Format< std::string >::alignment_
private

Definition at line 133 of file strings.hpp.

bool ecl::Format< std::string >::ready_to_format
private

Definition at line 134 of file strings.hpp.

std::string ecl::Format< std::string >::s
private

Definition at line 135 of file strings.hpp.

int ecl::Format< std::string >::width_
private

Definition at line 132 of file strings.hpp.


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


ecl_formatters
Author(s): Daniel Stonier
autogenerated on Mon Jun 10 2019 13:08:24