Template Class Format< std::string >
Defined in File strings.hpp
Class Documentation
-
template<>
class 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.
Public Functions
-
inline Format(int w = -1, Alignment a = NoAlign)
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)
-
inline virtual ~Format()
-
inline Format<std::string> &width(int w)
Sets the width format parameter. Setting this to -1 will turn off width formatting constraints.
- Parameters:
w – : the total width of the text output.
-
inline Format<std::string> &align(Alignment a)
Sets the alignment format parameter. This aligns the text output in the text window which has a width specified by the width parameter.
See also
- Parameters:
a – : the aligning property for the output text.
-
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).
-
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.
-
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.
-
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.
Friends
-
template<typename OutputStream>
friend OutputStream &operator<<(OutputStream &ostream, Format<std::string> &formatter) 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.
- Throws:
StandardException – : throws if the formatter is used multiply in one stream operation [debug mode only].
- Returns:
OutputStream : a handle to the resultant stream.
-
inline Format(int w = -1, Alignment a = NoAlign)