|
| | Query (const std::string_view raw) |
| auto | raw () const -> std::string_view |
| auto | at (const std::string_view name) const -> std::optional< std::string_view > |
A non-owning, zero-copy view over the RFC 3986 query component of a URI. Provides convenience access to query parameters formatted as name=value pairs separated by &. For example:
#include <sourcemeta/core/uri.h>
#include <cassert>
uri{"https://www.sourcemeta.com/?foo=bar"};
assert(
query.has_value());
assert(
query.value().raw() ==
"foo=bar");
auto query() const -> std::optional< Query >
◆ Query()
| sourcemeta::core::URI::Query::Query |
( |
const std::string_view | raw | ) |
|
|
explicit |
Construct a query view over a raw RFC 3986 query string, without a leading ?. The view borrows the input and does not own it. For example:
#include <sourcemeta/core/uri.h>
#include <cassert>
assert(
query.at(
"foo").value() ==
"bar");
◆ at()
| auto sourcemeta::core::URI::Query::at |
( |
const std::string_view | name | ) |
const -> std::optional< std::string_view > |
|
nodiscard |
Look up the value of a query parameter by name. Returns std::nullopt if no matching parameter exists. If multiple parameters share the given name, the value of the first one is returned. The returned value is not percent-decoded. For example:
#include <sourcemeta/core/uri.h>
#include <cassert>
uri{"https://www.sourcemeta.com/?foo=bar"};
assert(
query.has_value());
assert(
query.value().at(
"foo").value() ==
"bar");
◆ raw()
| auto sourcemeta::core::URI::Query::raw |
( |
| ) |
const -> std::string_view |
|
nodiscard |
Get the raw RFC 3986 query string this view was constructed from. For example:
#include <sourcemeta/core/uri.h>
#include <cassert>
uri{"https://www.sourcemeta.com/?foo=bar&baz=qux"};
assert(uri.
query().value().raw() ==
"foo=bar&baz=qux");
The documentation for this class was generated from the following file:
- /__w/core/core/src/core/uri/include/sourcemeta/core/uri.h