Builder for constructing URIs incrementally.
More...
#include <uri_builder.h>
Public Member Functions
Creates a builder with an initially empty URI.
More...
Creates a builder with a existing URI object.
More...
const utility::string_t &
scheme () const
Get the scheme component of the URI as an encoded string.
More...
Get the user information component of the URI as an encoded string.
More...
const utility::string_t &
host () const
Get the host component of the URI as an encoded string.
More...
Get the port component of the URI. Returns -1 if no port is specified.
More...
const utility::string_t &
path () const
Get the path component of the URI as an encoded string.
More...
const utility::string_t &
query () const
Get the query component of the URI as an encoded string.
More...
const utility::string_t &
fragment () const
Get the fragment component of the URI as an encoded string.
More...
Set the user info component of the URI.
More...
Set the host component of the URI.
More...
Set the port component of the URI.
More...
Set the port component of the URI.
More...
Set the path component of the URI.
More...
Set the query component of the URI.
More...
Set the fragment component of the URI.
More...
Appends an relative uri (Path, Query and fragment) at the end of the current uri.
More...
template<typename T >
Appends another query to the query of this
uri_builder, encoding it first. This overload is useful when building a query segment of the form "element=10", where the right hand side of the query is stored as a type other than a string, for instance, an integral type.
More...
Combine and validate the URI components into a encoded string. An exception will be thrown if the URI is invalid.
More...
Combine and validate the URI components into a URI class instance. An exception will be thrown if the URI is invalid.
More...
Detailed Description
Builder for constructing URIs incrementally.
Constructor & Destructor Documentation
web::uri_builder::uri_builder
(
)
inline
Creates a builder with an initially empty URI.
web::uri_builder::uri_builder
(
const
uri &
uri_str )
inline
Creates a builder with a existing URI object.
- Parameters
-
uri_str Encoded string containing the URI.
Member Function Documentation
_ASYNCRTIMP
uri_builder& web::uri_builder::append
(
const
uri &
relative_uri )
Appends an relative uri (Path, Query and fragment) at the end of the current uri.
- Parameters
-
relative_uri The relative uri to append.
- Returns
- A reference to this uri_builder to support chaining.
_ASYNCRTIMP
uri_builder& web::uri_builder::append_path
(
const utility::string_t &
path,
bool
do_encoding = false
)
Appends another path to the path of this uri_builder.
- Parameters
-
path Path to append as a already encoded string.
do_encoding Specify whether to apply URI encoding to the given string.
- Returns
- A reference to this uri_builder to support chaining.
_ASYNCRTIMP
uri_builder& web::uri_builder::append_query
(
const utility::string_t &
query,
bool
do_encoding = false
)
Appends another query to the query of this uri_builder.
- Parameters
-
query Query to append as a decoded string.
do_encoding Specify whether to apply URI encoding to the given string.
- Returns
- A reference to this uri_builder to support chaining.
template<typename T >
uri_builder& web::uri_builder::append_query
(
const utility::string_t &
name,
const T &
value,
bool
do_encoding = true
)
inline
Appends another query to the query of this uri_builder, encoding it first. This overload is useful when building a query segment of the form "element=10", where the right hand side of the query is stored as a type other than a string, for instance, an integral type.
- Parameters
-
name The name portion of the query string
value The value portion of the query string
- Returns
- A reference to this uri_builder to support chaining.
void web::uri_builder::clear
(
)
inline
Clears all components of the underlying URI in this uri_builder.
const utility::string_t& web::uri_builder::fragment
(
)
const
inline
Get the fragment component of the URI as an encoded string.
- Returns
- The URI fragment as a string.
const utility::string_t& web::uri_builder::host
(
)
const
inline
Get the host component of the URI as an encoded string.
- Returns
- The URI host as a string.
_ASYNCRTIMP bool web::uri_builder::is_valid
(
)
Validate the generated URI from all existing components of this uri_builder.
- Returns
- Whether the URI is valid.
const utility::string_t& web::uri_builder::path
(
)
const
inline
Get the path component of the URI as an encoded string.
- Returns
- The URI path as a string.
int web::uri_builder::port
(
)
const
inline
Get the port component of the URI. Returns -1 if no port is specified.
- Returns
- The URI port as an integer.
const utility::string_t& web::uri_builder::query
(
)
const
inline
Get the query component of the URI as an encoded string.
- Returns
- The URI query as a string.
const utility::string_t& web::uri_builder::scheme
(
)
const
inline
Get the scheme component of the URI as an encoded string.
- Returns
- The URI scheme as a string.
uri_builder& web::uri_builder::set_fragment
(
const utility::string_t &
fragment,
bool
do_encoding = false
)
inline
Set the fragment component of the URI.
- Parameters
-
fragment Fragment as a decoded string.
do_encoding Specify whether to apply URI encoding to the given string.
- Returns
- A reference to this
uri_builder
to support chaining.
uri_builder& web::uri_builder::set_host
(
const utility::string_t &
host,
bool
do_encoding = false
)
inline
Set the host component of the URI.
- Parameters
-
host Host as a decoded string.
do_encoding Specify whether to apply URI encoding to the given string.
- Returns
- A reference to this
uri_builder
to support chaining.
uri_builder& web::uri_builder::set_path
(
const utility::string_t &
path,
bool
do_encoding = false
)
inline
Set the path component of the URI.
- Parameters
-
path Path as a decoded string.
do_encoding Specify whether to apply URI encoding to the given string.
- Returns
- A reference to this
uri_builder
to support chaining.
Set the port component of the URI.
- Parameters
-
port Port as an integer.
- Returns
- A reference to this
uri_builder
to support chaining.
uri_builder& web::uri_builder::set_port
(
const utility::string_t &
port )
inline
Set the port component of the URI.
- Parameters
-
port Port as a string.
- Returns
- A reference to this
uri_builder
to support chaining.
When string can't be converted to an integer the port is left unchanged.
uri_builder& web::uri_builder::set_query
(
const utility::string_t &
query,
bool
do_encoding = false
)
inline
Set the query component of the URI.
- Parameters
-
query Query as a decoded string.
do_encoding Specify whether apply URI encoding to the given string.
- Returns
- A reference to this
uri_builder
to support chaining.
uri_builder& web::uri_builder::set_scheme
(
const utility::string_t &
scheme )
inline
Set the scheme of the URI.
- Parameters
-
scheme Uri scheme.
- Returns
- A reference to this
uri_builder
to support chaining.
uri_builder& web::uri_builder::set_user_info
(
const utility::string_t &
user_info,
bool
do_encoding = false
)
inline
Set the user info component of the URI.
- Parameters
-
user_info User info as a decoded string.
do_encoding Specify whether to apply URI encoding to the given string.
- Returns
- A reference to this
uri_builder
to support chaining.
_ASYNCRTIMP utility::string_t web::uri_builder::to_string
(
)
Combine and validate the URI components into a encoded string. An exception will be thrown if the URI is invalid.
- Returns
- The created URI as a string.
_ASYNCRTIMP
uri web::uri_builder::to_uri
(
)
Combine and validate the URI components into a URI class instance. An exception will be thrown if the URI is invalid.
- Returns
- The create URI as a URI class instance.
const utility::string_t& web::uri_builder::user_info
(
)
const
inline
Get the user information component of the URI as an encoded string.
- Returns
- The URI user information as a string.
The documentation for this class was generated from the following file: