...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
and attr_cast
, and Karma
rule
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
)
or the embedded component (for attr_cast
).
#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 Enable> struct transform_attribute { typedef <unspecified> type; static type pre(Exposed& val); static void post(Exposed& val, type attr); // 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 |
|
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
).
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>::pre(exposed)
|
Do |
void transform_attribute<Exposed, Transformed>::post(exposed, transformed)
|
Do |
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
.
TBD