...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Before generating output for a value this value needs to extracted from
the attribute instance provided by the user. The customization point extract_from_attribute
is utilized to
adapt this extraction for any data type possibly used to store the values
to output.
Note | |
---|---|
The interface of this customization point has been changed with Boost
V1.44. We added the |
#include <boost/spirit/home/karma/detail/extract_from.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 Attrib, typename Enable> struct extract_from_attribute { typedef <unspecified> type; template <typename Context> static type call(Attrib const& attr, Context& context); };
Parameter |
Description |
Default |
---|---|---|
|
The type, |
none |
|
The type, |
none |
|
Helper template parameter usable to selectively enable or disable
certain specializations of |
|
|
This is the type of the current generator execution context. |
Notation
Exposed
A type exposed as the native attribute of a component.
Attrib
A type to be used to generate output from.
attr
An attribute instance of type Attrib
.
ctx
An instance of type Context
.
Expression |
Semantics |
---|---|
extract_from_attribute<Exposed, Attrib>::call(attr, ctx)
|
Extract the value to generate output from |
Spirit predefines specializations of this customization point for several types. The following table lists those types together with the types exposed and the corresponding semantics:
Template Parameters |
Semantics |
---|---|
|
The exposed typedef |
|
The exposed typedef |
|
The exposed typedef |
|
The exposed typedef |
The customization point extract_from_attribute
needs to be implemented for a specific type whenever the default implementation
as shown above is not applicable. Examples for this could be that the type
to be extracted is different from Attrib
and is not copy constructible.