Return the value for a key or a fallback
<boost/url/params_base.hpp>std::string
get_or(
core::string_view key,
core::string_view value = {},
ignore_case_param ic = {}) const;
This convenience function searches for the first parameter matching key and returns its decoded value. If no parameter with the specified key exists, the provided fallback value is returned instead. When the key is found but the parameter has no value, an empty string is returned.
url_view u( "/path?first=John&last=Doe" );
assert( u.params().get_or( "first", "n/a" ) == "John" );
assert( u.params().get_or( "missing", "n/a" ) == "n/a" );
Linear in this->buffer().size().
Calls to allocate may throw.
| Name | Description |
|---|---|
| key | The key to match. |
| value | The fallback string returned when no matching key exists. If this parameter is omitted, an empty string is used. |
| ic | Optional case-insensitive compare indicator. |