...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
The template transform_attribute
is a type used as an attribute customization point. It is invoked by Qi
rule
, semantic action and
attr_cast
, and Karma
rule
, semantic action and
attr_cast
. It is used to automatically
transform the user provided attribute to the attribute type expected by
the right hand side component (for rule
),
the semantic action, or the embedded component (for attr_cast
).
Note | |
---|---|
The interface of this customization point has been changed with Boost
V1.44. We added the |
#include <boost/spirit/home/support/attributes.hpp>
Also, see Include Structure.
Note | |
---|---|
This header file does not need to be included directly by any user program as it is normally included by other Spirit header files relying on its content. |
Name |
---|
|
template <typename Exposed, typename Transformed, typename Domain, typename Enable> struct transform_attribute { typedef <unspecified> type; static type pre(Exposed& val); static void post(Exposed& val, type attr); // Qi only static void fail(Exposed&); // Qi only };
Parameter |
Description |
Default |
---|---|---|
|
The attribute type supplied to the component which needs to be transformed. |
none |
|
The attribute type expected by the component to be provided as the result of the transformation. |
none |
|
The domain of the sub library the template is instantiated in.
Typically this is either |
none |
|
Helper template parameter usable to selectively enable or disable
certain specializations of |
|
Notation
Exposed
The type, Exposed
is the type of the attribute as passed in by the user.
Transformed
The type, Transformed
is the type of the attribute as passed along to the right hand side
of the rule
(embedded
component of attr_cast
).
Domain
The domain of the sub library the template is instantiated in. Typically
this is either qi::domain
or karma::domain
.
exposed
An instance of type Exposed
.
transformed
An instance of type Transformed
.
Expression |
Semantics |
---|---|
|
Evaluates to the type to be used as the result of the transformation
(to be passed to the right hand side of the |
type transform_attribute<Exposed, Transformed, Domain>::pre(exposed)
|
Do |
void transform_attribute<Exposed, Transformed, Domain>::post(exposed, transformed)
|
Do |
void transform_attribute<Exposed, Transformed, Domain>::fail(exposed)
|
Handling failing parse operations of the right hand side component
for |
Template parameters |
Semantics |
---|---|
|
|
|
|
|
|
|
|
|
(usind in Karma only) |
|
(usind in Karma only) |
|
(usind in Karma only) |
|
|
|
|
The customization point transform_attribute
needs to be implemented for a specific pair of types whenever the attribute
type supplied to a rule
or attr_cast
cannot automatically
transformed to the attribute type expected by the right hand side of the
rule
(embedded component
of the attr_cast
) because
the default implementation as shown above is not applicable. Examples for
this could be that the type Transformed
is not constructible from the type Exposed
.