...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Match a repeating number of elements.
Defined in header <boost/url/grammar/range_rule.hpp>
template< class Rule1, class Rule2> constexpr implementation-defined range_rule( Rule1 first, Rule2 next, std::size_t N = 0, std::size_t M = std::size_t(-1));
Two rules are used for match. The rule first
is used for matching the first element, while the next
rule is used to match every subsequent element.
Normally when the rule returns an error, the range ends and the input is
rewound to one past the last character that matched successfully. However,
if the rule returns the special value error::end_of_range
, the input is not
rewound. This allows for rules which consume input without producing elements
in the range. For example, to relax the grammar for a comma-delimited list
by allowing extra commas in between elements.
using value_type = range< typename Rule::value_type >;
Rules are used with the function parse
.
// range = [ token ] *( "," token ) result< range< string_view > > rv = parse( "whiskey,tango,foxtrot", range_rule( token_rule( alpha_chars ), // first tuple_rule( // next squelch( delim_rule(',') ), token_rule( alpha_chars ) ) ) );
range = <1>*<1>first / first <N-1>*<M-1>next
Name |
Description |
---|---|
|
The rule to use for matching the first element. If this rule returns an error, the range is empty. |
|
The rule to use for matching each subsequent element. The range extends until this rule returns an error. |
|
The minimum number of elements for the range to be valid. If omitted, this defaults to zero. |
|
The maximum number of elements for the range to be valid. If omitted, this defaults to unlimited. |
alpha_chars
, delim_rule
, error::end_of_range
, parse
, range
, tuple_rule
, squelch
.
Convenience header <boost/url/grammar.hpp>