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() (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 > & | operator() (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) |
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 48 of file strings.hpp.
|
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 66 of file strings.hpp.
|
inlinevirtual |
Definition at line 67 of file strings.hpp.
|
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 82 of file strings.hpp.
|
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 180 of file strings.hpp.
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 42 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 52 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 59 of file strings.cpp.
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 35 of file strings.cpp.
|
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 216 of file strings.hpp.
|
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 203 of file strings.hpp.
|
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 190 of file strings.hpp.
|
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 76 of file strings.hpp.
|
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 229 of file strings.hpp.
|
private |
Definition at line 147 of file strings.hpp.
|
private |
Definition at line 148 of file strings.hpp.
|
private |
Definition at line 149 of file strings.hpp.
|
private |
Definition at line 146 of file strings.hpp.