QoreURL Class Reference

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

#include <QoreURL.h>

List of all members.

Public Member Functions

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


Detailed Description

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

Constructor & Destructor Documentation

DLLEXPORT QoreURL::QoreURL (  ) 

creates an empty structure

See also:
QoreURL::parse()

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:
url the URL string to parse

DLLEXPORT QoreURL::QoreURL ( const class QoreString url  ) 

parses the URL string passed

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

Parameters:
url the URL string to parse


Member Function Documentation

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 a QoreBigIntNode
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

DLLEXPORT const QoreString* QoreURL::getHost (  )  const

returns the hostname of the URL

Returns:
the hostname of the URL

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

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

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

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

DLLEXPORT bool QoreURL::isValid (  )  const

returns true if the URL string parsed is valid

Returns:
true if the URL string parsed is valid

DLLEXPORT int QoreURL::parse ( const class 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:
url the URL string to parse

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:
url the URL string to parse

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

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

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

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:

doxygen