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 is utilized to adapt this extraction for any data type possibly used to store the values to output.

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

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

Notation

Attrib

A type to be used to generate output from.

attr

A attribute instance of type Attrib.

Expression Semantics

Expression

Semantics

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

Extract the value to generate output from 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

Value

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.

Example

TBD


PrevUpHomeNext