C++ Rest SDK
The C++ REST SDK is a Microsoft project for cloud-based client-server communication in native code using a modern asynchronous C++ API design. This project aims to help C++ developers connect to and interact with services.
Public Member Functions | List of all members
web::uri_builder Class Reference

Builder for constructing URIs incrementally. More...

#include <uri_builder.h>

Public Member Functions

 uri_builder ()
 Creates a builder with an initially empty URI. More...
 
 uri_builder (const uri &uri_str)
 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...
 
const utility::string_t & user_info () const
 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...
 
int port () const
 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...
 
uri_builderset_scheme (const utility::string_t &scheme)
 Set the scheme of the URI. More...
 
uri_builderset_user_info (const utility::string_t &user_info, bool do_encoding=false)
 Set the user info component of the URI. More...
 
uri_builderset_host (const utility::string_t &host, bool do_encoding=false)
 Set the host component of the URI. More...
 
uri_builderset_port (int port)
 Set the port component of the URI. More...
 
uri_builderset_port (const utility::string_t &port)
 Set the port component of the URI. More...
 
uri_builderset_path (const utility::string_t &path, bool do_encoding=false)
 Set the path component of the URI. More...
 
uri_builderset_query (const utility::string_t &query, bool do_encoding=false)
 Set the query component of the URI. More...
 
uri_builderset_fragment (const utility::string_t &fragment, bool do_encoding=false)
 Set the fragment component of the URI. More...
 
void clear ()
 Clears all components of the underlying URI in this uri_builder. More...
 
_ASYNCRTIMP uri_builderappend_path (const utility::string_t &path, bool do_encoding=false)
 Appends another path to the path of this uri_builder. More...
 
_ASYNCRTIMP uri_builderappend_query (const utility::string_t &query, bool do_encoding=false)
 Appends another query to the query of this uri_builder. More...
 
_ASYNCRTIMP uri_builderappend (const uri &relative_uri)
 Appends an relative uri (Path, Query and fragment) at the end of the current uri. More...
 
template<typename T >
uri_builderappend_query (const utility::string_t &name, const T &value, bool do_encoding=true)
 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...
 
_ASYNCRTIMP utility::string_t to_string ()
 Combine and validate the URI components into a encoded string. An exception will be thrown if the URI is invalid. More...
 
_ASYNCRTIMP uri to_uri ()
 Combine and validate the URI components into a URI class instance. An exception will be thrown if the URI is invalid. More...
 
_ASYNCRTIMP bool is_valid ()
 Validate the generated URI from all existing components of this uri_builder. 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_strEncoded 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_uriThe 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
pathPath to append as a already encoded string.
do_encodingSpecify 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
queryQuery to append as a decoded string.
do_encodingSpecify 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
nameThe name portion of the query string
valueThe 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
fragmentFragment as a decoded string.
do_encodingSpecify 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
hostHost as a decoded string.
do_encodingSpecify 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
pathPath as a decoded string.
do_encodingSpecify 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_port ( int  port)
inline

Set the port component of the URI.

Parameters
portPort 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
portPort 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
queryQuery as a decoded string.
do_encodingSpecify 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
schemeUri 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_infoUser info as a decoded string.
do_encodingSpecify 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: