Store an Attribute after a Parser Produced a Pair of Iterators (Qi)

| Home | Libraries | People | FAQ | More

##### Store an Attribute after a Parser Produced a Pair of Iterators (Qi)

###### assign_to_attribute_from_iterators

The template `assign_to_attribute_from_iterators` is a type used as an attribute customization point. It is invoked by the those Qi parsers not producing any attribute value but returning a pair of iterators pointing to the matched input sequence. It is used to either store the iterator pair into the attribute instance provided by the user or to convert the iterator pair into an attribute as provided by the user.

###### Module Headers

    #include <boost/spirit/home/qi/detail/assign_to.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.

###### Namespace

Name
`boost::spirit::traits`

###### Synopsis

    template <typename Attrib, typename Iterator, typename Enable>
    struct assign_to_attribute_from_iterators
    {
        static void call(Iterator const& first, Iterator const& last, Attrib& attr);
    };

###### Template parameters

Parameter | Description | Default
--- | --- | ---
`Attrib` | The type, `Attrib` is the type of the attribute as passed in by the user. | none
`Iterator` | The type, `Iterator` is the type of the iterators as produced by the parser. | none
`Enable` | Helper template parameter usable to selectively enable or disable certain specializations of `assign_to_attribute_from_value` utilizing SFINAE (i.e. `boost::enable_if` or `boost::disable_if`). | `void`

Notation

`Attrib`

  A type to be used as the target to store the attribute value in.

`attr`

  An attribute instance of type `Attrib`.

`Iterator`

  The iterator type used by the parser. This type usually corresponds to the iterators as passed in by the user.

`begin`, `end`

  Iterator instances of type `Iterator` pointing to the begin and the end of the matched input sequence.

###### Expression Semantics

Expression | Semantics
--- | ---

    assign_to_attribute_from_iterators<Attrib, Iterator>::call(b, e, attr)

Use the iterators `begin` and `end` to initialize the attribute `attr`.

###### Predefined Specializations

Template Parameters | Semantics
--- | ---
`Attrib`, `Iterator` | Execute an assignment `attr = Attrib(begin, end)`.
`unused_type`, `T` | Do nothing.

###### When to implement

The customization point `assign_to_attribute_from_iterators` 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 `Attrib` is not constructible from the pair of iterators.