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(); }
138 void setQuery(
const std::string_view& queryString);
158 const std::string& base,
159 const std::string& relative,
160 bool useBaseQuery =
false,
161 bool assumeHttpsDefault =
true);
181 const std::string& uri,
182 const std::string& key,
183 const std::string& value);
231 const std::string& templateUri,
232 const std::function<SubstitutionCallbackSignature>& substitutionCallback);
240 static std::string
escape(
const std::string& s);
342 static std::string
getPath(
const std::string& uri);
357 setPath(
const std::string& uri,
const std::string& newPath);
360 std::optional<ada::url_aggregator> _url = std::nullopt;
361 bool _hasScheme =
false;
378 UriQuery(
const std::string_view& queryString) : _params(queryString) {}
404 std::optional<std::string_view>
getValue(
const std::string& key) {
405 return this->_params.get(key);
416 void setValue(
const std::string& key,
const std::string& value) {
417 this->_params.set(key, value);
426 bool hasValue(
const std::string& key) {
return this->_params.has(key); }
437 inline auto begin()
const {
return this->_params.begin(); }
439 inline auto end()
const {
return this->_params.end(); }
441 inline auto front()
const {
return this->_params.front(); }
443 inline auto back()
const {
return this->_params.back(); }
446 ada::url_search_params _params;
auto back() const
Returns the last element in the query parameters.
UriQuery()=default
Creates an empty UriQuery object.
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...
std::string_view getStem() const
Returns the filename portion of the URI without any extension.
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.
std::string_view getExtension() const
Returns the extension portion of the URI, if present.
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_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 SubstitutionCallbackSignature(const std::string &placeholder)
A callback to fill-in a placeholder value in a URL.
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...
std::string_view getFileName() const
Returns the filename portion of the URI.
Utility classes for Cesium.