Zen
A cross-platform functional programming language
Public Member Functions | Private Attributes

Separator Class Reference

Class for encapsulating various list separators. More...

List of all members.

Public Member Functions

 Separator (const z::string &first, const z::string &next)
 Default constructor.
z::streamwrite (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::stringgetSep () 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.

Detailed Description

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.


Constructor & Destructor Documentation

Separator ( const z::string first,
const z::string next 
) [inline]

Default constructor.

Parameters:
firstThe initial separator
nextThe subsequent separators

Member Function Documentation

const z::string& getSep ( ) const [inline]

Returns the value of the current separator.

Returns:
The separator string
void reset ( const z::string first,
const z::string next 
) [inline]

Resets the separator strings to new values and restarts from first.

Parameters:
firstNew initial separator
nextNew subsequent separator
z::stream& write ( z::stream os) [inline]

Writes the current separator to the output stream.

Parameters:
osThe output stream
Returns:
The output stream

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines