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
Define a Custom Attribute Mapping for a Parser
create_parser

The template create_parser is a type used as an customization point. It is invoked by the Qi create_parser API function in order to create a custom mapping of the given data type to a parser expression. This parser expression will be returned from create_parser whenever the given data type is encountered.

Module Headers
// forwards to <boost/spirit/home/qi/auto.hpp>
#include <boost/spirit/include/qi_auto.hpp>

Also, see Include Structure.

Namespace

Name

boost::spirit::traits

Synopsis
template <typename T, typename Enable>
struct create_parser
{
    typedef <unspecified> type;
    static type const& call();
};
Template parameters

Parameter

Description

Default

T

The type, T for which a custom mapping to a parser should be established.

none

Enable

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

void

Notation

T

An arbitrary type.

Expression Semantics

Expression

Semantics

create_parser<T>::type

Defines the type of the parser expression returned from call.

create_parser<T>::call()

Returns a parser expression (usually this is a proto::expression) to be used as the default parser for the given type, T.

Predefined Specializations

Spirit predefines specializations of this customization point for several types. All predefined mappings are listed here: Additional Attribute Requirements for Parsers.

[Note] Note

It is possible to overload the predefined mappings for the listed types by providing your own specialization of the create_parser customization point for the type to modify.

When to implement

The customization point create_parser needs to be implemented for a specific type whenever this type should be usable with the API function create_parser (which includes using the qi::auto_ parser and the special API functions based on the automatic creation of the matching parser type).

Example

For an example of how to use the customization point create_parser please see here: Example for Using the qi::auto_ Parser.


PrevUpHomeNext