| Qore Programming Language - C/C++ Library 1.0.8

QoreURL.h
1 /* -*- mode: c++; indent-tabs-mode: nil -*- */
2 /*
3 QoreURL.h
4
5 Network functions and macros
6
7 Qore Programming Language
8
9 Copyright (C) 2003 - 2019 Qore Technologies, s.r.o.
10
11 Permission is hereby granted, free of charge, to any person obtaining a
12 copy of this software and associated documentation files (the "Software"),
13 to deal in the Software without restriction, including without limitation
14 the rights to use, copy, modify, merge, publish, distribute, sublicense,
15 and/or sell copies of the Software, and to permit persons to whom the
16 Software is furnished to do so, subject to the following conditions:
17
18 The above copyright notice and this permission notice shall be included in
19 all copies or substantial portions of the Software.
20
21 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27 DEALINGS IN THE SOFTWARE.
28
29 Note that the Qore library is released under a choice of three open-source
30 licenses: MIT (as above), LGPL 2+, or GPL 2+; see README-LICENSE for more
31 information.
32 */
33
34 #ifndef _QORE_QOREURL_H
35
36 #define _QORE_QOREURL_H
37
39 class QoreURL {
40 private:
42 struct qore_url_private* priv;
43
44 DLLLOCAL void zero();
45 DLLLOCAL void reset();
46 DLLLOCAL void parseIntern(const char* url, ExceptionSink* xsink);
47
49 DLLLOCAL QoreURL(const QoreURL&);
50
52 DLLLOCAL QoreURL& operator=(const QoreURL&);
53
54 public:
56
58 DLLEXPORT QoreURL();
59
61
64 DLLEXPORT QoreURL(const char* url);
65
67
70 DLLEXPORT QoreURL(const QoreString* url);
71
73
77 DLLEXPORT QoreURL(const char* url, bool keep_brackets);
78
80
84 DLLEXPORT QoreURL(const QoreString* url, bool keep_brackets);
85
87
97 DLLEXPORT QoreURL(const QoreString* url, bool keep_brackets, ExceptionSink* xsink);
98
100 DLLEXPORT ~QoreURL();
101
103
107 DLLEXPORT int parse(const char* url);
108
110
114 DLLEXPORT int parse(const QoreString* url);
115
117
125 DLLEXPORT int parse(const char* url, bool keep_brackets);
126
128
136 DLLEXPORT int parse(const QoreString* url, bool keep_brackets);
137
139
152 DLLEXPORT int parse(const QoreString* url, bool keep_brackets, ExceptionSink* xsink);
153
155
157 DLLEXPORT bool isValid() const;
158
160
172 DLLEXPORT QoreHashNode* getHash();
173
175
177 DLLEXPORT const QoreString* getHost() const;
178
180
182 DLLEXPORT const QoreString* getUserName() const;
183
185
187 DLLEXPORT const QoreString* getPassword() const;
188
190
192 DLLEXPORT const QoreString* getPath() const;
193
195 DLLEXPORT const QoreString* getProtocol() const;
196
198
200 DLLEXPORT int getPort() const;
201
202 // the "take" methods return the char* pointers for the data
203 // the caller owns the memory
204
206
209 DLLEXPORT char* take_path();
210
212
215 DLLEXPORT char* take_username();
216
218
221 DLLEXPORT char* take_password();
222
224
227 DLLEXPORT char* take_host();
228 };
229
230 #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:39
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:81
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