Directives Controlling Automatic Delimiting (verbatim[], delimit[])

| Home | Libraries | People | FAQ | More

##### Directives Controlling Automatic Delimiting (`verbatim[]`, `delimit[]`)

###### Description

The directives `delimit[]` and `verbatim[]` can be used to control automatic delimiting. The directive `verbatim[]` disables any automatic delimiting, while the directive `delimit[]` (re-)enables automatic delimiting.

###### Header

For the `verbatim[]` directive:

    // forwards to <boost/spirit/home/karma/directive/verbatim.hpp>
    #include <boost/spirit/include/karma_verbatim.hpp>

For the `delimit[]` directive:

    // forwards to <boost/spirit/home/karma/directive/delimit.hpp>
    #include <boost/spirit/include/karma_delimit.hpp>

Also, see Include Structure.

###### Namespace

Name
`boost::spirit::verbatim // alias: boost::spirit::karma::verbatim`
`boost::spirit::delimit // alias: boost::spirit::karma::delimit`

###### Model of

> `UnaryGenerator`

Notation

`a`

  A generator object

`d`

  A generator object, or a Lazy Argument that evaluates to a generator object

`A`, `D`

  Attribute types of the generators `a` and `d`

###### Expression Semantics

Semantics of an expression is defined only where it differs from, or is not defined in `UnaryGenerator`.

Expression | Semantics
--- | ---
`delimit[a]` | Enable automatic delimiting for the embedded generator `a` while using the `space` generator as the delimiting generator. If used inside a `verbatim[]` directive it re-enables the delimiter generator as used outside of this `verbatim[]` instead. The directive succeeds as long as the embedded generator succeeded (unless the underlying output stream reports an error).
`delimit(d)[a]` | Enable automatic delimiting for the embedded generator `a` while using the generator `d` as the delimiting generator. The directive succeeds as long as the embedded generator succeeded (unless the underlying output stream reports an error).
`verbatim[a]` | Disable automatic delimiting for the embedded generator `a`. The directive succeeds as long as the embedded generator succeeded (unless the underlying output stream reports an error). This directive it has no effect if it is used when no delimiting is active.

###### Attributes

See Compound Attribute Notation.

Expression | Attribute
--- | ---

`delimit[a]`

    a: A --> delimit[a]: A
    a: Unused --> delimit[a]: Unused

`delimit(d)[a]`

    a: A, d: D --> delimit(d)[a]: A
    a: Unused, d: D --> delimit(d)[a]: Unused

`verbatim[a]`

    a: A --> verbatim[a]: A
    a: Unused --> verbatim[a]: Unused

###### Complexity

> The overall complexity of the generator directives `delimit[]` and `verbatim[]` is defined by the complexity of its embedded generators. The complexity of the directives themselves is O(1).

###### Example

| Note
The test harness for the example(s) below is presented in the Basics Examples section.

Some includes:

    #include <boost/spirit/include/karma.hpp>
    #include <iostream>
    #include <string>

Some using declarations:

    using boost::spirit::karma::double_;
    using boost::spirit::karma::delimit;
    using boost::spirit::karma::verbatim;

Basic usage of `delimit` generator directive:

    test_generator_attr("[ 2.0 , 4.3 ] ",
        delimit['[' << double_ << ',' << double_ << ']'], 2.0, 4.3);
    test_generator_attr("[*2.0*,*4.3*]*",
        delimit('*')['[' << double_ << ',' << double_ << ']'], 2.0, 4.3);
    test_generator_attr("[2.0, 4.3 ] ",
        delimit[verbatim['[' << double_ << ','] << double_ << ']'], 2.0, 4.3);