...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
The Generator is the most fundamental concept. A
Generator has a member function, generate
,
that accepts an OutputIterator
and returns bool as its result. The iterator receives the data being
generated. The Generator's generate
member function returns true
if the generator succeeds. Each Generator can represent a specific pattern
or algorithm, or it can be a more complex generator formed as a composition
of other Generators.
Notation
g
A Generator
.
G
A Generator
type.
OutIter
An OutputIterator
type.
sink
An OutputIterator
instance.
Context
The generator's Context type.
context
The generator's Context, or unused
.
delimit
A delimiter Generator, or unused
.
attrib
A Compatible Attributes, or unused
.
In the expressions below, the behavior of the generator, g
, as well as how delimit
and attrib
are handled
by g
, are left unspecified
in the base Generator
concept. These are specified in subsequent, more refined concepts and
by the actual models thereof.
For any Generator the following expressions must be valid:
Expression |
Semantics |
Return type |
---|---|---|
g.generate(sink, context, delimit, attrib)
|
Generate the output sequence by inserting the generated characters/tokens
into |
|
|
Get information about a Generator. |
|
Expression |
Description |
---|---|
|
The Generator's attribute. |
|
Metafunction that evaluates to |
|
An |
Upon return from g.generate
the following post conditions
should hold:
sink
receives the generated characters/tokens sequence.
delimit
characters/tokens will not be emitted in front of any other output.
attrib
has not been modified.
All generators in Spirit.Karma are models of the Generator concept.