| Home | Libraries | People | FAQ | More

#### Qi Seek Parser Directive

###### Description

The `seek[]` parser-directive skips all input until the subject parser matches. On failure, the current position is the end of the input.

###### Header

    // forwards to <boost/spirit/repository/home/qi/directive/seek.hpp>
    #include <boost/spirit/repository/include/qi_seek.hpp>

Also, see Include Structure.

###### Namespace

Name
`boost::spirit::repository::qi::seek`

###### Model of

> `UnaryParser`

Notation

`a`

  A `Parser`.

###### Expression Semantics

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

Expression | Semantics
--- | ---
`seek[a]` | Advances until the parser `a` matches.

###### Attributes

See Compound Attribute Notation.

Expression | Attribute
--- | ---

`seek[a]`

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

###### Complexity

> The complexity is defined by the complexity of the subject parser, `a`

###### Example

The following example shows a simple use case of the `seek[]` directive, seeking all the ints preceding by `'#'`. (For the full source of the example, see seek.cpp)

Some namespace aliases:

    namespace qi = boost::spirit::qi;
    namespace ka = boost::spirit::karma;
    namespace repo = boost::spirit::repository;

The input iterators and the attribute to store the result:

    iterator it = line.begin();
    iterator end = line.end();
    std::vector<int> val;

Parsing and showing the result:

    if (qi::phrase_parse(it, end, +repo::qi::seek["#" >> qi::int_], qi::space, val))
    {
        std::cout << "-------------------------------- \n";
        std::cout << "Parsing succeeded, got: "
                  << ka::format("[ " << ka::int_ % ", " << " ]\n", val);
        std::cout << "---------------------------------\n";
    }

Input:

    1 will not be outputted while #2, ##3 and # 4 will.

Output:

    --------------------------------
    Parsing succeeded, got: [ 2, 3, 4 ]
    ---------------------------------