xbmc
|
Public Member Functions | |
NPT_Url () | |
Default constructor. More... | |
NPT_Url (const char *url, NPT_UInt16 default_port=0) | |
Construct a URL by parsing an input string in its fully encoded form. More... | |
NPT_Url (const char *scheme, const char *host, NPT_UInt16 port, const char *path, const char *query=NULL, const char *fragment=NULL) | |
Construct a URL from its components. More... | |
NPT_Result | Parse (const char *url, NPT_UInt16 default_port=0) |
Parse a URL from its fully encoded form. More... | |
NPT_Result | ParsePathPlus (const char *path_plus) |
Parse just the path plus optional query and fragment from a fully encoded form. More... | |
const NPT_String & | GetHost () const |
Returns the host part of the URL, in its encoded form. | |
NPT_UInt16 | GetPort () const |
Returns the port number of the URL. | |
const NPT_String & | GetPath () const |
Returns the path part of the URL, in its encoded form. | |
NPT_String | GetPath (bool decoded) const |
Returns the path part of the URL, in its encoded or decoded form. | |
const NPT_String & | GetQuery () const |
Returns the query part of the URL, in its encoded form. | |
const NPT_String & | GetFragment () const |
Returns the fragment part of the URL, in its encoded form. | |
virtual bool | IsValid () const |
Returns whether the URL is valid or not. More... | |
void | Reset () |
Resets a URL to an uninitialized state. | |
bool | HasQuery () const |
Returns whether the URL has a query part or not. More... | |
bool | HasFragment () const |
Returns whether the URL has a fragment part or not. More... | |
NPT_Result | SetHost (const char *host) |
Sets the host part of the URL. More... | |
NPT_Result | SetPort (NPT_UInt16 port) |
Sets the port number of the URL. More... | |
NPT_Result | SetPath (const char *path, bool encoded=false) |
Sets the path part of the URL. More... | |
NPT_Result | SetQuery (const char *query, bool encoded=false) |
Sets the query part of the URL. More... | |
NPT_Result | SetFragment (const char *fragment, bool encoded=false) |
Sets the fragment part of the URL. More... | |
virtual NPT_String | ToRequestString (bool with_fragment=false) const |
Return the string representation of the URL in a way that can be used in an HTTP request (i.e just the portion of the URL starting with the path) More... | |
virtual NPT_String | ToStringWithDefaultPort (NPT_UInt16 default_port, bool with_fragment=true) const |
Return the string representation of the URL. More... | |
virtual NPT_String | ToString (bool with_fragment=true) const |
Return the string representation of the URL. More... | |
![]() | |
const NPT_String & | GetScheme () const |
void | SetScheme (const char *scheme) |
NPT_Result | SetSchemeFromUri (const char *uri) |
SchemeId | GetSchemeId () const |
Protected Attributes | |
NPT_String | m_Host |
bool | m_HostIsIpv6Address |
NPT_UInt16 | m_Port |
NPT_String | m_Path |
bool | m_HasQuery |
NPT_String | m_Query |
bool | m_HasFragment |
NPT_String | m_Fragment |
![]() | |
NPT_String | m_Scheme |
SchemeId | m_SchemeId |
Additional Inherited Members | |
![]() | |
enum | SchemeId { SCHEME_ID_UNKNOWN, SCHEME_ID_HTTP, SCHEME_ID_HTTPS } |
![]() | |
static NPT_String | PercentEncode (const char *str, const char *chars, bool encode_percents=true) |
static NPT_String | PercentDecode (const char *str) |
static SchemeId | ParseScheme (const NPT_String &scheme) |
![]() | |
static const char *const | PathCharsToEncode = NPT_URI_ALWAYS_ENCODE "?#[]" |
static const char *const | QueryCharsToEncode = NPT_URI_ALWAYS_ENCODE "#[]" |
static const char *const | FragmentCharsToEncode = NPT_URI_ALWAYS_ENCODE "[]" |
static const char *const | UnsafeCharsToEncode = NPT_URI_ALWAYS_ENCODE |
NPT_Url::NPT_Url | ( | ) |
Default constructor.
This does not construct a valid URL, but an uninitialized one that can later be initialized to a valid URL by parsing or setting some of its fields.
NPT_Url::NPT_Url | ( | const char * | url, |
NPT_UInt16 | default_port = 0 |
||
) |
Construct a URL by parsing an input string in its fully encoded form.
If an error occurs during parsing (such as an invalid syntax), the URL will be in an invalid state (a call to IsValid() will return false).
url | The URL string in its encoded form |
default_port | The default port number, or 0 if not specified |
NPT_Url::NPT_Url | ( | const char * | scheme, |
const char * | host, | ||
NPT_UInt16 | port, | ||
const char * | path, | ||
const char * | query = NULL , |
||
const char * | fragment = NULL |
||
) |
Construct a URL from its components.
When constructing a URL from components, the components are assumed to be passed in their non-encoded form, and will thus be encoded automatically.
scheme | The URL scheme |
host | The host name (enclose with [ and ] for IPv6 addresses) |
port | The port number |
path | The path |
query | The query, if any, or NULL |
fragment | The fragment, if any, or NULL |
|
inline |
Returns whether the URL has a fragment part or not.
|
inline |
Returns whether the URL has a query part or not.
|
virtual |
Returns whether the URL is valid or not.
Invalid URLs are uninitialized or not fully initialized URLs.
NPT_Result NPT_Url::Parse | ( | const char * | url, |
NPT_UInt16 | default_port = 0 |
||
) |
Parse a URL from its fully encoded form.
url | The URL string in its encoded form |
default | port The defautl port number, or 0 if not specified |
NPT_Result NPT_Url::ParsePathPlus | ( | const char * | path_plus | ) |
Parse just the path plus optional query and fragment from a fully encoded form.
path_plus | The URL path plus optional query and fragment |
NPT_Result NPT_Url::SetFragment | ( | const char * | fragment, |
bool | encoded = false |
||
) |
Sets the fragment part of the URL.
query | The fragment part of the URL |
encoded | Boolean flag indicating whether the fragment parameter is already encoded or not. If it is not already encoded, it will be automatically encoded. |
NPT_Result NPT_Url::SetHost | ( | const char * | host | ) |
Sets the host part of the URL.
host | The host part of the URL (enclose with [ and ] for IPv6 addresses) |
NPT_Result NPT_Url::SetPath | ( | const char * | path, |
bool | encoded = false |
||
) |
Sets the path part of the URL.
path | The path part of the URL |
encoded | Boolean flag indicating whether the path parameter is already encoded or not. If it is not already encoded, it will be automatically encoded. |
NPT_Result NPT_Url::SetPort | ( | NPT_UInt16 | port | ) |
Sets the port number of the URL.
port | The port number of the URL |
NPT_Result NPT_Url::SetQuery | ( | const char * | query, |
bool | encoded = false |
||
) |
Sets the query part of the URL.
query | The query part of the URL |
encoded | Boolean flag indicating whether the query parameter is already encoded or not. If it is not already encoded, it will be automatically encoded. |
|
virtual |
Return the string representation of the URL in a way that can be used in an HTTP request (i.e just the portion of the URL starting with the path)
with_fragment | Boolean flag specifiying whether the fragment part of the URL should be included in the returned string or not. |
|
virtual |
Return the string representation of the URL.
with_fragment | Boolean flag specifiying whether the fragment part of the URL should be included in the returned string or not. |
Reimplemented in NPT_HttpUrl.
|
virtual |
Return the string representation of the URL.
default_port | default port number for the scheme. If the port number of the URL is not equal to the default port, then port number is explicitely included in the string representation of the URL. |
with_fragment | Boolean flag specifiying whether the fragment part of the URL should be included in the returned string or not. |