Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

Extract an Attribute Value to Generate Output (Karma)

extract_from

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] Note

The interface of this customization point has been changed with Boost V1.44. We added the Exposed template parameter to allow for more fine grained specializations of the required Spirit.Karma attribute transformations.

Module Headers
#include <boost/spirit/home/karma/detail/extract_from.hpp>

Also, see Include Structure.

[Note] 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.

Namespace

Name

boost::spirit::traits

Synopsis
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);
};
Template parameters

Parameter

Description

Default

Exposed

The type, Exposed of the attribute natively exposed by the component the extract_from_attribute is invoked from.

none

Attrib

The type, Attrib of the attribute to be used to generate output from.

none

Enable

Helper template parameter usable to selectively enable or disable certain specializations of clear_value utilizing SFINAE (i.e. boost::enable_if or boost::disable_if).

void

Context

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

Expression

Semantics

extract_from_attribute<Exposed, Attrib>::call(attr, ctx)

Extract the value to generate output from attr and return it to the caller.

Predefined Specializations

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

Attrib

The exposed typedef type is defined to Attrib const&. The function call() returns the argument by reference without change.

boost::optional<Attrib>

The exposed typedef type is defined to Attrib const&. The function call() returns the value held by the optional<> argument by reference without change.

boost::reference_wrapper<Attrib>

The exposed typedef type is defined to Attrib const&. The function call() returns the value held by the reference_wrapper<> argument by reference without change.

unused_type

The exposed typedef type is defined to unused_type. The function call() returns an instance of unused_type.

When to implement

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.


PrevUpHomeNext