QoreURL.h
/* -*- mode: c++; indent-tabs-mode: nil -*- */
/*
QoreURL.h
Network functions and macros
Qore Programming Language
Copyright (C) 2003 - 2022 Qore Technologies, s.r.o.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
Note that the Qore library is released under a choice of three open-source
licenses: MIT (as above), LGPL 2+, or GPL 2+; see README-LICENSE for more
information.
*/
#ifndef _QORE_QOREURL_H
#define _QORE_QOREURL_H
#define QURL_KEEP_BRACKETS (1 << 0)
#define QURL_DECODE (1 << 1)
#define QURL_DECODE_PATH (1 << 2)
#define QURL_DECODE_ANY (QURL_DECODE | QURL_DECODE_PATH)
class QoreURL {
public:
DLLEXPORT QoreURL();
DLLEXPORT QoreURL(const char* url);
DLLEXPORT QoreURL(const QoreString* url);
DLLEXPORT QoreURL(const char* url, bool keep_brackets);
DLLEXPORT QoreURL(const QoreString* url, bool keep_brackets);
DLLEXPORT QoreURL(const QoreString* url, bool keep_brackets, ExceptionSink* xsink);
DLLEXPORT QoreURL(const char* url, int options);
DLLEXPORT QoreURL(const QoreString& url, int options = 0);
DLLEXPORT QoreURL(const std::string& url, int options = 0);
DLLEXPORT QoreURL(ExceptionSink* xsink, const char* url, int options);
DLLEXPORT QoreURL(ExceptionSink* xsink, const QoreString& url, int options = 0);
DLLEXPORT QoreURL(ExceptionSink* xsink, const std::string& url, int options = 0);
DLLEXPORT ~QoreURL();
DLLEXPORT int parse(const char* url);
DLLEXPORT int parse(const QoreString* url);
DLLEXPORT int parse(const char* url, bool keep_brackets);
DLLEXPORT int parse(const QoreString* url, bool keep_brackets);
DLLEXPORT int parse(const QoreString* url, bool keep_brackets, ExceptionSink* xsink);
DLLEXPORT int parse(const char* url, int options);
DLLEXPORT int parse(const QoreString& url, int options = 0);
DLLEXPORT int parse(const std::string& url, int options = 0);
DLLEXPORT int parse(ExceptionSink* xsink, const char* url, int options = 0);
DLLEXPORT int parse(ExceptionSink* xsink, const QoreString& url, int options = 0);
DLLEXPORT int parse(ExceptionSink* xsink, const std::string& url, int options = 0);
DLLEXPORT bool isValid() const;
DLLEXPORT QoreHashNode* getHash();
DLLEXPORT const QoreString* getHost() const;
DLLEXPORT const QoreString* getUserName() const;
DLLEXPORT const QoreString* getPassword() const;
DLLEXPORT const QoreString* getPath() const;
DLLEXPORT const QoreString* getProtocol() const;
DLLEXPORT int getPort() const;
// the "take" methods return the char* pointers for the data
// the caller owns the memory
DLLEXPORT char* take_path();
DLLEXPORT char* take_username();
DLLEXPORT char* take_password();
DLLEXPORT char* take_host();
private:
struct qore_url_private* priv;
DLLLOCAL void zero();
DLLLOCAL void reset();
DLLLOCAL void parseIntern(const char* url, ExceptionSink* xsink);
DLLLOCAL QoreURL(const QoreURL&);
DLLLOCAL QoreURL& operator=(const QoreURL&);
};
#endif
QoreURL::take_username
DLLEXPORT char * take_username()
returns a pointer to the username in the URL (0 if none present), caller owns the memory returned ...
QoreURL::~QoreURL
DLLEXPORT ~QoreURL()
frees all memory and destroys the structure
QoreHashNode
This is the hash or associative list container type in Qore, dynamically allocated only...
Definition: QoreHashNode.h:50
QoreURL::parse
DLLEXPORT int parse(const char *url)
parses the URL string passed
QoreURL::getHash
DLLEXPORT QoreHashNode * getHash()
returns a hash of the parameters parsed, destructive: zeros out all elements, caller owns the referen...
QoreURL
helps with parsing URLs and provides access to URL components through Qore data structures ...
Definition: QoreURL.h:44
QoreURL::isValid
DLLEXPORT bool isValid() const
returns true if the URL string parsed is valid
QoreURL::take_password
DLLEXPORT char * take_password()
returns a pointer to the password in the URL (0 if none present), caller owns the memory returned ...
QoreString
Qore&#39;s string type supported by the QoreEncoding class.
Definition: QoreString.h:93
ExceptionSink
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:48
QoreURL::getPassword
DLLEXPORT const QoreString * getPassword() const
returns the password in the URL or 0 if none given
QoreURL::take_path
DLLEXPORT char * take_path()
returns a pointer to the path (0 if none present), caller owns the memory returned ...
QoreURL::take_host
DLLEXPORT char * take_host()
returns a pointer to the hostname in the URL (0 if none present), caller owns the memory returned ...
QoreURL::QoreURL
DLLEXPORT QoreURL()
creates an empty structure
QoreURL::getHost
DLLEXPORT const QoreString * getHost() const
returns the hostname of the URL
QoreURL::getUserName
DLLEXPORT const QoreString * getUserName() const
returns the user name in the URL or 0 if none given
QoreURL::getPath
DLLEXPORT const QoreString * getPath() const
returns the path component of the URL or 0 if none given
QoreURL::getProtocol
DLLEXPORT const QoreString * getProtocol() const
returns the protocol component of the URL or 0 if none given
QoreURL::getPort
DLLEXPORT int getPort() const
returns the port number given in the URL or 0 if none present