...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
The library implements a special API returning a generator instance for a supplied attribute type. This function finds the best matching generator type for the attribute based on a set of simple matching rules (as outlined in the table below) applied recursively to the attribute type. The returned generator can be utilized to emit output for the provided attribute.
// forwards to <boost/spirit/home/karma/auto.hpp> #include <boost/spirit/include/karma_auto.hpp>
Also, see Include Structure.
Name |
---|
|
|
namespace boost { namespace spirit { namespace karma { template <typename Attr> inline <unspecified> create_generator(); }}}
The returned instance can be directly passed as the generator (or the
delimiting generator) to any of the Spirit.Karma
API functions. Additionally it can be assigned to a rule as the rules
right hand side expression. This function will return a valid generator
type only if the meta function traits::create_generator_exists
returns mpl::true_
. Otherwise it will fail compiling.
namespace boost { namespace spirit { namespace traits { template <typename Attr> struct create_generator_exists; }}}
The meta function evaluates to mpl::true_
if create_generator
would
return a valid generator for the given type Attr
.
The following table outlines the mapping rules from the attribute type to the generator type. These rules are applied recursively to create the generator type which can be used to generate output from the given attribute type.
Attribute type |
Generator type |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Any string ( |
|
Any (STL) container |
Kleene Star (unary |
Any Fusion sequence |
Sequence operator ( |
|
Optional operator (unary |
|
Alternative operator ( |
Important | |
---|---|
The mapping for the generators |
Parameter |
Description |
---|---|
|
An attribute type utilized to create the corresponding generator type from. |