Zen
A cross-platform functional programming language
|
Class for encapsulating various list separators. More...
Public Member Functions | |
Separator (const z::string &first, const z::string &next) | |
Default constructor. | |
z::stream & | write (z::stream &os) |
Writes the current separator to the output stream. | |
void | restart () |
Restarts the separator sequence. | |
void | reset (const z::string &first, const z::string &next) |
Resets the separator strings to new values and restarts from first. | |
const z::string & | getSep () const |
Returns the value of the current separator. | |
Private Attributes | |
z::string | _sep |
The current separator string. | |
z::string | _first |
The initial separator. | |
z::string | _next |
The subsequent separator. |
Class for encapsulating various list separators.
This class allows one to easily manage separators between various lists being generated. It is provided two separators. The first time it is called, it outputs the first separator, then the next separator subsequently. For example:
Separator sep("", ", "); for(...) { const MyType& v = ...; _os << sep << v; }
Here, the output would be v1, v2, v3,... vn.
Default constructor.
first | The initial separator |
next | The subsequent separators |
const z::string& getSep | ( | ) | const [inline] |
Returns the value of the current separator.
Resets the separator strings to new values and restarts from first.
first | New initial separator |
next | New subsequent separator |
Writes the current separator to the output stream.
os | The output stream |