Cocos2d-x  v3.17
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Groups Pages
Uri Class Reference

Class representing a URI. More...

Public Member Functions

 Uri ()
 Default constructor.
 
 Uri ()
 Default constructor.
 
 Uri ()
 Default constructor.
 
 Uri (const Uri &o)
 Copy constructor.
 
 Uri ( var o)
 Copy constructor.
 
 Uri ( local o)
 Copy constructor.
 
 Uri (Uri &&o)
 Move constructor.
 
 Uri ( var o)
 Move constructor.
 
 Uri ( local o)
 Move constructor.
 
Urioperator= (const Uri &o)
 Copy assignment.
 
var operator= ( var o)
 Copy assignment.
 
local operator= ( local o)
 Copy assignment.
 
Urioperator= (Uri &&o)
 Move assignment.
 
var operator= ( var o)
 Move assignment.
 
local operator= ( local o)
 Move assignment.
 
bool operator== (const Uri &o) const
 Checks whether two Uri instances contain the same values.
 
var operator== ( var o)
 Checks whether two Uri instances contain the same values.
 
local operator== ( local o)
 Checks whether two Uri instances contain the same values.
 
bool isValid () const
 Checks wether it's a valid URI.
 
var isValid ()
 Checks wether it's a valid URI.
 
local isValid ()
 Checks wether it's a valid URI.
 
bool isSecure () const
 Checks whether it's a SSL connection.
 
var isSecure ()
 Checks whether it's a SSL connection.
 
local isSecure ()
 Checks whether it's a SSL connection.
 
const std::string & getScheme () const
 Gets the scheme name for this URI. More...
 
var getScheme ()
 Gets the scheme name for this URI. More...
 
local getScheme ()
 Gets the scheme name for this URI. More...
 
const std::string & getUserName () const
 Gets the user name with the specified URI. More...
 
const std::string & getPassword () const
 Gets the password with the specified URI. More...
 
const std::string & getHost () const
 Get host part of URI. More...
 
local getHost ()
 Get host part of URI. More...
 
const std::string & getHostName () const
 Get host part of URI. More...
 
uint16_t getPort () const
 Gets the port number of the URI. More...
 
var getPort ()
 Gets the port number of the URI. More...
 
local getPort ()
 Gets the port number of the URI. More...
 
const std::string & getPath () const
 Gets the path part of the URI. More...
 
const std::string & getPathEtc () const
 Gets the path, query and fragment parts of the URI.
 
const std::string & getQuery () const
 Gets the query part of the URI. More...
 
local getQuery ()
 Gets the query part of the URI. More...
 
const std::string & getFragment () const
 Gets the fragment part of the URI.
 
const std::string & getAuthority () const
 Gets the authority part (userName, password, host and port) of the URI. More...
 
local getAuthority ()
 Gets the authority part (userName, password, host and port) of the URI. More...
 
std::string toString () const
 Gets a string representation of the URI. More...
 
var toString ()
 Gets a string representation of the URI. More...
 
local toString ()
 Gets a string representation of the URI. More...
 
const std::vector< std::pair
< std::string, std::string > > & 
getQueryParams ()
 Get query parameters as key-value pairs. More...
 
local getQueryParams ()
 Get query parameters as key-value pairs. More...
 
void clear ()
 Clears all parts of the URI. More...
 
local clear ()
 Clears all parts of the URI. More...
 

Static Public Member Functions

static Uri parse (const std::string &str)
 Parse a Uri from a string. More...
 
local parse ( local str)
 Parse a Uri from a string. More...
 

Detailed Description

Class representing a URI.

Consider http://www.facebook.com/foo/bar?key=foo#anchor

The URI is broken down into its parts: scheme ("http"), authority (ie. host and port, in most cases: "www.facebook.com"), path ("/foo/bar"), query ("key=foo") and fragment ("anchor"). The scheme is lower-cased.

If this Uri represents a URL, note that, to prevent ambiguity, the component parts are NOT percent-decoded; you should do this yourself with uriUnescape() (for the authority and path) and uriUnescape(..., UriEscapeMode::QUERY) (for the query, but probably only after splitting at '&' to identify the individual parameters).

Member Function Documentation

static Uri parse ( const std::string &  str)
static

Parse a Uri from a string.

Throws std::invalid_argument on parse error.

var parse ( var  str)
static

Parse a Uri from a string.

Throws std::invalid_argument on parse error.

local parse ( local  str)
static

Parse a Uri from a string.

Throws std::invalid_argument on parse error.

const std::string& getScheme ( ) const
inline

Gets the scheme name for this URI.

var getScheme ( )
inline

Gets the scheme name for this URI.

local getScheme ( )
inline

Gets the scheme name for this URI.

const std::string& getUserName ( ) const
inline

Gets the user name with the specified URI.

var getUserName ( )
inline

Gets the user name with the specified URI.

local getUserName ( )
inline

Gets the user name with the specified URI.

const std::string& getPassword ( ) const
inline

Gets the password with the specified URI.

var getPassword ( )
inline

Gets the password with the specified URI.

local getPassword ( )
inline

Gets the password with the specified URI.

const std::string& getHost ( ) const
inline

Get host part of URI.

If host is an IPv6 address, square brackets will be returned, for example: "[::1]".

var getHost ( )
inline

Get host part of URI.

If host is an IPv6 address, square brackets will be returned, for example: "[::1]".

local getHost ( )
inline

Get host part of URI.

If host is an IPv6 address, square brackets will be returned, for example: "[::1]".

const std::string& getHostName ( ) const
inline

Get host part of URI.

If host is an IPv6 address, square brackets will not be returned, for exmaple "::1"; otherwise it returns the same thing as getHost().

getHostName() is what one needs to call if passing the host to any other tool or API that connects to that host/port; e.g. getaddrinfo() only understands IPv6 host without square brackets

var getHostName ( )
inline

Get host part of URI.

If host is an IPv6 address, square brackets will not be returned, for exmaple "::1"; otherwise it returns the same thing as getHost().

getHostName() is what one needs to call if passing the host to any other tool or API that connects to that host/port; e.g. getaddrinfo() only understands IPv6 host without square brackets

local getHostName ( )
inline

Get host part of URI.

If host is an IPv6 address, square brackets will not be returned, for exmaple "::1"; otherwise it returns the same thing as getHost().

getHostName() is what one needs to call if passing the host to any other tool or API that connects to that host/port; e.g. getaddrinfo() only understands IPv6 host without square brackets

uint16_t getPort ( ) const
inline

Gets the port number of the URI.

var getPort ( )
inline

Gets the port number of the URI.

local getPort ( )
inline

Gets the port number of the URI.

const std::string& getPath ( ) const
inline

Gets the path part of the URI.

var getPath ( )
inline

Gets the path part of the URI.

local getPath ( )
inline

Gets the path part of the URI.

const std::string& getQuery ( ) const
inline

Gets the query part of the URI.

var getQuery ( )
inline

Gets the query part of the URI.

local getQuery ( )
inline

Gets the query part of the URI.

const std::string& getAuthority ( ) const
inline

Gets the authority part (userName, password, host and port) of the URI.

Note
If the port number is a well-known port number for the given scheme (e.g., 80 for http), it is not included in the authority.
var getAuthority ( )
inline

Gets the authority part (userName, password, host and port) of the URI.

Note
If the port number is a well-known port number for the given scheme (e.g., 80 for http), it is not included in the authority.
local getAuthority ( )
inline

Gets the authority part (userName, password, host and port) of the URI.

Note
If the port number is a well-known port number for the given scheme (e.g., 80 for http), it is not included in the authority.
std::string toString ( ) const

Gets a string representation of the URI.

var toString ( )

Gets a string representation of the URI.

local toString ( )

Gets a string representation of the URI.

const std::vector<std::pair
<std::string, std::string>
>& getQueryParams
( )

Get query parameters as key-value pairs.

e.g. for URI containing query string: key1=foo&key2=&key3&=bar&=bar= In returned list, there are 3 entries: "key1" => "foo" "key2" => "" "key3" => "" Parts "=bar" and "=bar=" are ignored, as they are not valid query parameters. "=bar" is missing parameter name, while "=bar=" has more than one equal signs, we don't know which one is the delimiter for key and value.

Note, this method is not thread safe, it might update internal state, but only the first call to this method update the state. After the first call is finished, subsequent calls to this method are thread safe.

Returns
query parameter key-value pairs in a vector, each element is a pair of which the first element is parameter name and the second one is parameter value
var getQueryParams ( )

Get query parameters as key-value pairs.

e.g. for URI containing query string: key1=foo&key2=&key3&=bar&=bar= In returned list, there are 3 entries: "key1" => "foo" "key2" => "" "key3" => "" Parts "=bar" and "=bar=" are ignored, as they are not valid query parameters. "=bar" is missing parameter name, while "=bar=" has more than one equal signs, we don't know which one is the delimiter for key and value.

Note, this method is not thread safe, it might update internal state, but only the first call to this method update the state. After the first call is finished, subsequent calls to this method are thread safe.

Returns
query parameter key-value pairs in a vector, each element is a pair of which the first element is parameter name and the second one is parameter value
local getQueryParams ( )

Get query parameters as key-value pairs.

e.g. for URI containing query string: key1=foo&key2=&key3&=bar&=bar= In returned list, there are 3 entries: "key1" => "foo" "key2" => "" "key3" => "" Parts "=bar" and "=bar=" are ignored, as they are not valid query parameters. "=bar" is missing parameter name, while "=bar=" has more than one equal signs, we don't know which one is the delimiter for key and value.

Note, this method is not thread safe, it might update internal state, but only the first call to this method update the state. After the first call is finished, subsequent calls to this method are thread safe.

Returns
query parameter key-value pairs in a vector, each element is a pair of which the first element is parameter name and the second one is parameter value
void clear ( )

Clears all parts of the URI.

var clear ( )

Clears all parts of the URI.

local clear ( )

Clears all parts of the URI.


The documentation for this class was generated from the following file: