...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
The matches[]
directive executes the embedded parser and returns whether it succeeded
matching.
// forwards to <boost/spirit/home/qi/directive/matches.hpp> #include <boost/spirit/include/qi_matches.hpp>
Also, see Include Structure.
Name |
---|
|
Notation
a
A Parser
.
Semantics of an expression is defined only where it differs from, or
is not defined in UnaryParser
.
Expression |
Semantics |
---|---|
|
Execute the subject parser |
Expression |
Attribute |
---|---|
|
|
The complexity is defined by the complexity of the subject parser,
a
Note | |
---|---|
The test harness for the example(s) below is presented in the Basics Examples section. |
Some using declarations:
using boost::spirit::qi::matches; using boost::spirit::qi::int_;
This parser tries to match an int
and returns true
a its attribute
as it succeeded matching:
bool result = false; test_parser_attr("345", matches[int_], result); std::cout << std::boolalpha << result << std::endl; // should print: true
This parser tries to match an int
as well and returns false
as its attribute as it fails matching:
result = true; test_parser_attr("abc", matches[int_], result); std::cout << std::boolalpha << result << std::endl; // should print: false