4#include <ada/url_search_params.h>
30 Uri(
const std::string& uri);
42 Uri(
const Uri& base,
const std::string& relative,
bool useBaseQuery =
false);
58 operator bool()
const {
return this->
isValid(); }
108 void setQuery(
const std::string_view& queryString);
128 const std::string& base,
129 const std::string& relative,
130 bool useBaseQuery =
false,
131 bool assumeHttpsDefault =
true);
151 const std::string& uri,
152 const std::string& key,
153 const std::string& value);
201 const std::string& templateUri,
202 const std::function<SubstitutionCallbackSignature>& substitutionCallback);
210 static std::string
escape(
const std::string& s);
312 static std::string
getPath(
const std::string& uri);
327 setPath(
const std::string& uri,
const std::string& newPath);
330 std::optional<ada::url_aggregator> _url = std::nullopt;
331 bool _hasScheme =
false;
348 UriQuery(
const std::string_view& queryString) : _params(queryString) {}
370 std::optional<std::string_view>
getValue(
const std::string& key) {
371 return this->_params.get(key);
382 void setValue(
const std::string& key,
const std::string& value) {
383 this->_params.set(key, value);
392 bool hasValue(
const std::string& key) {
return this->_params.has(key); }
403 inline auto begin()
const {
return this->_params.begin(); }
405 inline auto end()
const {
return this->_params.end(); }
407 inline auto front()
const {
return this->_params.front(); }
409 inline auto back()
const {
return this->_params.back(); }
412 ada::url_search_params _params;
A class for parsing and manipulating the query string of a URI.
auto back() const
Returns the last element in the query parameters.
auto end() const
Returns an iterator pointing to the end of the query parameters.
auto begin() const
Returns an iterator pointing to the beginning of the query parameters.
std::optional< std::string_view > getValue(const std::string &key)
Obtains the value of the given key from the query parameters, if possible.
UriQuery(const std::string_view &queryString)
Creates a UriQuery object from a query string.
void setValue(const std::string &key, const std::string &value)
Sets the given key in the query parameters to the given value. If the key doesn't exist already,...
UriQuery(const Uri &uri)
Creates a UriQuery object from a Uri instance.
std::string toQueryString() const
Converts this object back into a query string, including all modifications that have been made....
auto front() const
Returns the first element in the query parameters.
bool hasValue(const std::string &key)
Returns true if this query string contains a value for the given key, or false otherwise.
A class for parsing and manipulating Uniform Resource Identifiers (URIs).
static std::string getPath(const std::string &uri)
Gets the path portion of the URI. This will not include path parameters, if present.
static std::string uriPathToWindowsPath(const std::string &uriPath)
Converts the path portion of a URI to a Windows file system path. Percent-encoded characters in the U...
static std::string resolve(const std::string &base, const std::string &relative, bool useBaseQuery=false, bool assumeHttpsDefault=true)
Attempts to resolve a relative URI using a base URI.
static std::string addQuery(const std::string &uri, const std::string &key, const std::string &value)
Adds the given key and value to the query string of a URI. For example, addQuery("https://api....
std::string_view getQuery() const
Gets the query portion of the URI.
static std::string setPath(const std::string &uri, const std::string &newPath)
Sets the path portion of a URI to a new value. The other portions of the URI are left unmodified,...
std::string_view getPath() const
Gets the path portion of the URI. This will not include query parameters, if present.
static std::string nativePathToUriPath(const std::string &nativePath)
Converts a file system path on the current system to a string suitable for use as the path portion of...
static std::string getQueryValue(const std::string &uri, const std::string &key)
Obtains the value of the given key from the query string of the URI, if possible.
static std::string windowsPathToUriPath(const std::string &windowsPath)
Converts a Windows file system path to a string suitable for use as the path portion of a URI....
void setPath(const std::string_view &path)
Sets the path portion of a URI to a new value. The other portions of the URI are left unmodified,...
static std::string substituteTemplateParameters(const std::string &templateUri, const std::function< SubstitutionCallbackSignature > &substitutionCallback)
Substitutes the placeholders in a templated URI with their appropriate values obtained using a specif...
static std::string uriPathToUnixPath(const std::string &uriPath)
Converts the path portion of a URI to a Unix file system path. Percent-encoded characters in the URI ...
std::string_view toString() const
Returns a string representation of the entire URI including path and query parameters.
static std::string escape(const std::string &s)
Escapes a portion of a URI, percent-encoding disallowed characters.
Uri(const Uri &base, const std::string &relative, bool useBaseQuery=false)
Attempts to create a new Uri from a base URI and a relative URI. If the base URI is invalid,...
std::string SubstitutionCallbackSignature(const std::string &placeholder)
A callback to fill-in a placeholder value in a URL.
std::string_view getScheme() const
Gets the scheme portion of the URI. If the URI was created without a scheme, this will return an empt...
static std::string unescape(const std::string &s)
Unescapes a portion of a URI, decoding any percent-encoded characters.
void setQuery(const std::string_view &queryString)
Sets the query portion of a URI to a new value. The other portions of the URI are left unmodified.
bool isValid() const
Returns true if this URI has been successfully parsed.
Uri(const std::string &uri)
Attempts to create a new Uri by parsing the given string. If the string fails to parse,...
static std::string uriPathToNativePath(const std::string &uriPath)
Converts the path portion of a URI to a file system path on the current system. Percent-encoded chara...
static std::string unixPathToUriPath(const std::string &unixPath)
Converts a Unix file system path to a string suitable for use as the path portion of a URI....
std::string_view getHost() const
Gets the host portion of the URI. If the URI also specifies a non-default port, it will be included i...
Utility classes for Cesium.