boost::urls::params_base::get_or
Return the value for a key or a fallback
Synopsis
Declared in <boost/url/params_base.hpp>
std::string
get_or(
core::string_view key,
core::string_view value = {},
ignore_case_param ic = {}) const;
Description
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.
Example
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" );
Parameters
| 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. |
Created with MrDocs