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) |
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 41 of file strings.hpp.
ecl::Format< std::string >::Format | ( | int | w = -1 , |
Alignment | a = NoAlign |
||
) | [inline] |
Default constructor. Initialises the format tags for width, alignment and base.
w | : width (default - no width constraints) |
a | : the textual alignment (default - no alignment constraints) |
Definition at line 51 of file strings.hpp.
virtual ecl::Format< std::string >::~Format | ( | ) | [inline, virtual] |
Definition at line 52 of file strings.hpp.
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.
a | : the aligning property for the output text. |
Definition at line 67 of file strings.hpp.
void ecl::Format< std::string >::format | ( | OutputStream & | ostream | ) | const [private] |
Internal function that does the actual formatting of a format object into a stream.
ostream | : the stream to be inserted into. |
Definition at line 173 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.
w | : the total width of the text output. |
a | : the aligning property for the output text. |
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.
input_string | : the string to be formatted. |
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.
input_string | : the string to be formatted. |
w | : the width to be used. |
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.
input_string | : the string to be formatted. |
w | : the width to be used. |
a | : the alignment to be used. |
Definition at line 55 of file strings.cpp.
void ecl::Format< std::string >::pad | ( | int | n, |
OutputStream & | ostream | ||
) | const [private] |
Internally used to pad the output with spaces when requested.
n | : the number of spaces to pad. |
ostream | : the streaming operator the formatter is conencted to. |
Definition at line 209 of file strings.hpp.
void ecl::Format< std::string >::postPad | ( | int | n, |
OutputStream & | ostream | ||
) | const [private] |
Postpad the output with spaces when requested.
n | : the number of spaces to pad. |
ostream | : the streaming operator the formatter is conencted to. |
Definition at line 196 of file strings.hpp.
void ecl::Format< std::string >::prePad | ( | int | n, |
OutputStream & | ostream | ||
) | const [private] |
Prepad the output with spaces when requested.
n | : the number of spaces to pad. |
ostream | : the streaming operator the formatter is conencted to. |
Definition at line 183 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.
w | : the total width of the text output. |
Definition at line 61 of file strings.hpp.
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.
ostream | : the stream to insert the formatted object into. |
formatter | : the format context. |
StandardException | : throws if the formatter is used multiply in one stream operation [debug mode only]. |
Definition at line 222 of file strings.hpp.
Alignment ecl::Format< std::string >::alignment_ [private] |
Definition at line 132 of file strings.hpp.
bool ecl::Format< std::string >::ready_to_format [private] |
Definition at line 133 of file strings.hpp.
std::string ecl::Format< std::string >::s [private] |
Definition at line 134 of file strings.hpp.
int ecl::Format< std::string >::width_ [private] |
Definition at line 131 of file strings.hpp.