Boost C++ Libraries

PrevUpHomeNext

Function match_uri_template

boost::taar::mcp::match_uri_template — Match uri against an RFC 6570 URI template (levels 1 to 3, plus the * and :n modifiers of level 4 in their matching-relevant form).

Synopsis

// In header: <boost/taar/mcp/arg.hpp>


std::optional< std::unordered_map< std::string, std::string > > 
match_uri_template(std::string_view tmpl, std::string_view uri);

Description

Supported expressions: {var} (one or more characters other than /, ?, # and ,), {+var} (reserved expansion: any characters, so paths with slashes), {#var} (fragment), {.var} (dot label), {/var} (path segment), {;var} (path parameter), {?a,b} and {&a,b} (query parameters, in any order; others are ignored). Several variables may share an expression ({a,b}); the prefixed forms are optional, so calc://x{?format} matches calc://x with no format argument, and {;a,b} / {?a,b} accept their pairs in any order. {var*} lets a / or . variable span several segments. {var:3} caps the value's length. Literal runs must match exactly.

Returns:

The captured variables (absent optional ones are left out), or std::nullopt on mismatch or on a malformed template.


PrevUpHomeNext