String format. More...
#include <strutils.h>
Public Member Functions | |
| format (const std::string &source) | |
| Constructor. | |
| std::string | str () const |
| Format a string. | |
| template<class T > | |
| format & | operator% (const T &x) |
| Assign the formatting parameter. | |
Friends | |
| std::ostream & | operator<< (std::ostream &, format &) |
| Format a string. | |
String format.
The format class formats a string by replacing of parameter markers by parameter values. Each parameter marker should be in the following format: {x}, where "x" - is a parameter number as passed to the class. Parameters are assigned by % operator, for example:
int i = 1; // prints "The 1-st test string" cout << dbp::format("The {0}-st {1} string") % i % "test";
| dbp::format::format | ( | const std::string & | source | ) | [inline] |
Constructor.
| source | a string to format |
| format& dbp::format::operator% | ( | const T & | x | ) | [inline] |
Assign the formatting parameter.
| x | a formatting parameter |
| std::string dbp::format::str | ( | ) | const |
Format a string.
| std::ostream& operator<< | ( | std::ostream & | , | |
| format & | ||||
| ) | [friend] |
Format a string.
Formats a string and outputs to ostream-compatible class.