Qore Programming Language  1.12.0
QoreURL Class Reference

helps with parsing URLs and provides access to URL components through Qore data structures More...

#include <QoreURL.h>

Public Member Methods

DLLEXPORT QoreURL ()
 creates an empty structure More...
 
DLLEXPORT QoreURL (const char *url)
 parses the URL string passed More...
 
DLLEXPORT QoreURL (const char *url, bool keep_brackets)
 parses the URL string passed More...
 
DLLEXPORT QoreURL (const char *url, int options)
 parses the URL string passed More...
 
DLLEXPORT QoreURL (const QoreString &url, int options=0)
 parses the URL string passed More...
 
DLLEXPORT QoreURL (const QoreString *url)
 parses the URL string passed More...
 
DLLEXPORT QoreURL (const QoreString *url, bool keep_brackets)
 parses the URL string passed More...
 
DLLEXPORT QoreURL (const QoreString *url, bool keep_brackets, ExceptionSink *xsink)
 parses the URL string passed More...
 
DLLEXPORT QoreURL (const std::string &url, int options=0)
 parses the URL string passed More...
 
DLLEXPORT QoreURL (ExceptionSink *xsink, const char *url, int options)
 parses the URL string passed More...
 
DLLEXPORT QoreURL (ExceptionSink *xsink, const QoreString &url, int options=0)
 parses the URL string passed More...
 
DLLEXPORT QoreURL (ExceptionSink *xsink, const std::string &url, int options=0)
 parses the URL string passed More...
 
DLLEXPORT ~QoreURL ()
 frees all memory and destroys the structure
 
DLLEXPORT QoreHashNodegetHash ()
 returns a hash of the parameters parsed, destructive: zeros out all elements, caller owns the reference count returned More...
 
DLLEXPORT const QoreStringgetHost () const
 returns the hostname of the URL More...
 
DLLEXPORT const QoreStringgetPassword () const
 returns the password in the URL or 0 if none given More...
 
DLLEXPORT const QoreStringgetPath () const
 returns the path component of the URL or 0 if none given More...
 
DLLEXPORT int getPort () const
 returns the port number given in the URL or 0 if none present More...
 
DLLEXPORT const QoreStringgetProtocol () const
 returns the protocol component of the URL or 0 if none given
 
DLLEXPORT const QoreStringgetUserName () const
 returns the user name in the URL or 0 if none given More...
 
DLLEXPORT bool isValid () const
 returns true if the URL string parsed is valid More...
 
DLLEXPORT int parse (const char *url)
 parses the URL string passed More...
 
DLLEXPORT int parse (const char *url, bool keep_brackets)
 parses the URL string passed More...
 
DLLEXPORT int parse (const char *url, int options)
 parses the URL string passed More...
 
DLLEXPORT int parse (const QoreString &url, int options=0)
 parses the URL string passed More...
 
DLLEXPORT int parse (const QoreString *url)
 parses the URL string passed More...
 
DLLEXPORT int parse (const QoreString *url, bool keep_brackets)
 parses the URL string passed More...
 
DLLEXPORT int parse (const QoreString *url, bool keep_brackets, ExceptionSink *xsink)
 parses the URL string passed More...
 
DLLEXPORT int parse (const std::string &url, int options=0)
 parses the URL string passed More...
 
DLLEXPORT int parse (ExceptionSink *xsink, const char *url, int options=0)
 parses the URL string passed More...
 
DLLEXPORT int parse (ExceptionSink *xsink, const QoreString &url, int options=0)
 parses the URL string passed More...
 
DLLEXPORT int parse (ExceptionSink *xsink, const std::string &url, int options=0)
 parses the URL string passed More...
 
DLLEXPORT char * take_host ()
 returns a pointer to the hostname in the URL (0 if none present), caller owns the memory returned More...
 
DLLEXPORT char * take_password ()
 returns a pointer to the password in the URL (0 if none present), caller owns the memory returned More...
 
DLLEXPORT char * take_path ()
 returns a pointer to the path (0 if none present), caller owns the memory returned More...
 
DLLEXPORT char * take_username ()
 returns a pointer to the username in the URL (0 if none present), caller owns the memory returned More...
 

Detailed Description

helps with parsing URLs and provides access to URL components through Qore data structures

Constructor & Destructor Documentation

◆ QoreURL() [1/12]

DLLEXPORT QoreURL::QoreURL ( )

creates an empty structure

See also
QoreURL::parse()

◆ QoreURL() [2/12]

DLLEXPORT QoreURL::QoreURL ( const char *  url)

parses the URL string passed

you can check if the URL was valid by calling QoreURL::isValid() after this call

Parameters
urlthe URL string to parse

◆ QoreURL() [3/12]

DLLEXPORT QoreURL::QoreURL ( const QoreString url)

parses the URL string passed

you can check if the URL was valid by calling QoreURL::isValid() after this call

Parameters
urlthe URL string to parse

◆ QoreURL() [4/12]

DLLEXPORT QoreURL::QoreURL ( const char *  url,
bool  keep_brackets 
)

parses the URL string passed

you can check if the URL was valid by calling QoreURL::isValid() after this call

Parameters
urlthe URL string to parse
keep_bracketsif this argument is true then if the hostname or address is enclosed in square brackets, then the brackets will be included in the "host" key output as well

◆ QoreURL() [5/12]

DLLEXPORT QoreURL::QoreURL ( const QoreString url,
bool  keep_brackets 
)

parses the URL string passed

you can check if the URL was valid by calling QoreURL::isValid() after this call

Parameters
urlthe URL string to parse
keep_bracketsif this argument is true then if the hostname or address is enclosed in square brackets, then the brackets will be included in the "host" key output as well

◆ QoreURL() [6/12]

DLLEXPORT QoreURL::QoreURL ( const QoreString url,
bool  keep_brackets,
ExceptionSink xsink 
)

parses the URL string passed

you can check if the URL was valid by calling QoreURL::isValid() after this call

Parameters
urlthe URL string to parse
keep_bracketsif this argument is true then if the hostname or address is enclosed in square brackets, then the brackets will be included in the "host" key output as well
xsinkfor Qore-language exceptions
Note
the input string will be converted to UTF-8 before parsing
Since
Qore 0.8.12.8

◆ QoreURL() [7/12]

DLLEXPORT QoreURL::QoreURL ( const char *  url,
int  options 
)

parses the URL string passed

you can check if the URL was valid by calling QoreURL::isValid() after this call

Parameters
urlthe URL string to parse
optionsa bitfield of Qore URL options
Since
Qore 1.0.10

◆ QoreURL() [8/12]

DLLEXPORT QoreURL::QoreURL ( const QoreString url,
int  options = 0 
)

parses the URL string passed

you can check if the URL was valid by calling QoreURL::isValid() after this call

Parameters
urlthe URL string to parse
optionsa bitfield of Qore URL options
Since
Qore 1.0.10

◆ QoreURL() [9/12]

DLLEXPORT QoreURL::QoreURL ( const std::string &  url,
int  options = 0 
)

parses the URL string passed

you can check if the URL was valid by calling QoreURL::isValid() after this call

Parameters
urlthe URL string to parse
optionsa bitfield of Qore URL options
Since
Qore 1.0.10

◆ QoreURL() [10/12]

DLLEXPORT QoreURL::QoreURL ( ExceptionSink xsink,
const char *  url,
int  options 
)

parses the URL string passed

you can check if the URL was valid by calling QoreURL::isValid() after this call

Parameters
xsinkfor Qore-language exceptions
urlthe URL string to parse
optionsa bitfield of Qore URL options
Since
Qore 1.0.10

◆ QoreURL() [11/12]

DLLEXPORT QoreURL::QoreURL ( ExceptionSink xsink,
const QoreString url,
int  options = 0 
)

parses the URL string passed

you can check if the URL was valid by calling QoreURL::isValid() after this call

Parameters
xsinkfor Qore-language exceptions
urlthe URL string to parse
optionsa bitfield of Qore URL options
Since
Qore 1.0.10

◆ QoreURL() [12/12]

DLLEXPORT QoreURL::QoreURL ( ExceptionSink xsink,
const std::string &  url,
int  options = 0 
)

parses the URL string passed

you can check if the URL was valid by calling QoreURL::isValid() after this call

Parameters
xsinkfor Qore-language exceptions
urlthe URL string to parse
optionsa bitfield of Qore URL options
Since
Qore 1.0.10

Member Function Documentation

◆ getHash()

DLLEXPORT QoreHashNode* QoreURL::getHash ( )

returns a hash of the parameters parsed, destructive: zeros out all elements, caller owns the reference count returned

hash keys are:

  • protocol
  • path
  • username
  • password
  • host
  • port

each key is either a QoreStringNode or 0 except for port which is an integer

Note
the caller must call QoreHashNode::deref() manually on the value returned if it's not 0 (or use the ReferenceHolder helper class)
Returns
a hash of the parameters parsed

◆ getHost()

DLLEXPORT const QoreString* QoreURL::getHost ( ) const

returns the hostname of the URL

Returns
the hostname of the URL

◆ getPassword()

DLLEXPORT const QoreString* QoreURL::getPassword ( ) const

returns the password in the URL or 0 if none given

Returns
the password in the URL or 0 if none given

◆ getPath()

DLLEXPORT const QoreString* QoreURL::getPath ( ) const

returns the path component of the URL or 0 if none given

Returns
the path component of the URL or 0 if none given

◆ getPort()

DLLEXPORT int QoreURL::getPort ( ) const

returns the port number given in the URL or 0 if none present

Returns
the port number given in the URL or 0 if none present

◆ getUserName()

DLLEXPORT const QoreString* QoreURL::getUserName ( ) const

returns the user name in the URL or 0 if none given

Returns
the user name in the URL or 0 if none given

◆ isValid()

DLLEXPORT bool QoreURL::isValid ( ) const

returns true if the URL string parsed is valid

Returns
true if the URL string parsed is valid

◆ parse() [1/11]

DLLEXPORT int QoreURL::parse ( const char *  url)

parses the URL string passed

If a url was already parsed previously, all memory is freed before parsing the new string. You can check if the URL was valid by calling QoreURL::isValid() after this call

Parameters
urlthe URL string to parse

◆ parse() [2/11]

DLLEXPORT int QoreURL::parse ( const char *  url,
bool  keep_brackets 
)

parses the URL string passed

If a url was already parsed previously, all memory is freed before parsing the new string. You can check if the URL was valid by calling QoreURL::isValid() after this call

Parameters
urlthe URL string to parse
keep_bracketsif this argument is true then if the hostname or address is enclosed in square brackets, then the brackets will be included in the "host" key output as well
Returns
0 if the URL was parsed successfully, -1 if not

◆ parse() [3/11]

DLLEXPORT int QoreURL::parse ( const char *  url,
int  options 
)

parses the URL string passed

If a url was already parsed previously, all memory is freed before parsing the new string.

Parameters
urlthe URL string to parse
optionsa bitfield of Qore URL options
Returns
0 if the URL was parsed successfully, -1 if not
Since
Qore 1.0.10

◆ parse() [4/11]

DLLEXPORT int QoreURL::parse ( const QoreString url,
int  options = 0 
)

parses the URL string passed

If a url was already parsed previously, all memory is freed before parsing the new string.

Parameters
urlthe URL string to parse
optionsa bitfield of Qore URL options
Returns
0 if the URL was parsed successfully, -1 if not
Since
Qore 1.0.10

◆ parse() [5/11]

DLLEXPORT int QoreURL::parse ( const QoreString url)

parses the URL string passed

If a url was already parsed previously, all memory is freed before parsing the new string. You can check if the URL was valid by calling QoreURL::isValid() after this call

Parameters
urlthe URL string to parse

◆ parse() [6/11]

DLLEXPORT int QoreURL::parse ( const QoreString url,
bool  keep_brackets 
)

parses the URL string passed

If a url was already parsed previously, all memory is freed before parsing the new string. You can check if the URL was valid by calling QoreURL::isValid() after this call

Parameters
urlthe URL string to parse
keep_bracketsif this argument is true then if the hostname or address is enclosed in square brackets, then the brackets will be included in the "host" key output as well
Returns
0 if the URL was parsed successfully, -1 if not

◆ parse() [7/11]

DLLEXPORT int QoreURL::parse ( const QoreString url,
bool  keep_brackets,
ExceptionSink xsink 
)

parses the URL string passed

If a url was already parsed previously, all memory is freed before parsing the new string. You can check if the URL was valid by calling QoreURL::isValid() after this call

Parameters
urlthe URL string to parse
keep_bracketsif this argument is true then if the hostname or address is enclosed in square brackets, then the brackets will be included in the "host" key output as well
xsinkfor Qore-language exceptions
Returns
0 if the URL was parsed successfully, -1 if not
Note
the input string will be converted to UTF-8 before parsing
Since
Qore 0.8.12.8

◆ parse() [8/11]

DLLEXPORT int QoreURL::parse ( const std::string &  url,
int  options = 0 
)

parses the URL string passed

If a url was already parsed previously, all memory is freed before parsing the new string.

Parameters
urlthe URL string to parse
optionsa bitfield of Qore URL options
Returns
0 if the URL was parsed successfully, -1 if not
Since
Qore 1.0.10

◆ parse() [9/11]

DLLEXPORT int QoreURL::parse ( ExceptionSink xsink,
const char *  url,
int  options = 0 
)

parses the URL string passed

If a url was already parsed previously, all memory is freed before parsing the new string.

Parameters
xsinkfor Qore-language exceptions
urlthe URL string to parse
optionsa bitfield of Qore URL options
Returns
0 if the URL was parsed successfully, -1 if not
Since
Qore 1.0.10

◆ parse() [10/11]

DLLEXPORT int QoreURL::parse ( ExceptionSink xsink,
const QoreString url,
int  options = 0 
)

parses the URL string passed

If a url was already parsed previously, all memory is freed before parsing the new string.

Parameters
xsinkfor Qore-language exceptions
urlthe URL string to parse
optionsa bitfield of Qore URL options
Returns
0 if the URL was parsed successfully, -1 if not
Since
Qore 1.0.10

◆ parse() [11/11]

DLLEXPORT int QoreURL::parse ( ExceptionSink xsink,
const std::string &  url,
int  options = 0 
)

parses the URL string passed

If a url was already parsed previously, all memory is freed before parsing the new string.

Parameters
xsinkfor Qore-language exceptions
urlthe URL string to parse
optionsa bitfield of Qore URL options
Returns
0 if the URL was parsed successfully, -1 if not
Since
Qore 1.0.10

◆ take_host()

DLLEXPORT char* QoreURL::take_host ( )

returns a pointer to the hostname in the URL (0 if none present), caller owns the memory returned

if this function returns a non-zero pointer, the memory must be manually freed by the caller

Returns
a pointer to the hostname (0 if none present), caller owns the memory returned

◆ take_password()

DLLEXPORT char* QoreURL::take_password ( )

returns a pointer to the password in the URL (0 if none present), caller owns the memory returned

if this function returns a non-zero pointer, the memory must be manually freed by the caller

Returns
a pointer to the password (0 if none present), caller owns the memory returned

◆ take_path()

DLLEXPORT char* QoreURL::take_path ( )

returns a pointer to the path (0 if none present), caller owns the memory returned

if this function returns a non-zero pointer, the memory must be manually freed by the caller

Returns
a pointer to the path (0 if none present), caller owns the memory returned

◆ take_username()

DLLEXPORT char* QoreURL::take_username ( )

returns a pointer to the username in the URL (0 if none present), caller owns the memory returned

if this function returns a non-zero pointer, the memory must be manually freed by the caller

Returns
a pointer to the username (0 if none present), caller owns the memory returned

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