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

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 - 2022 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
38 #define QURL_KEEP_BRACKETS (1 << 0)
39 #define QURL_DECODE (1 << 1)
40 #define QURL_DECODE_PATH (1 << 2)
41 #define QURL_DECODE_ANY (QURL_DECODE | QURL_DECODE_PATH)
42
44 class QoreURL {
45 public:
47
49 DLLEXPORT QoreURL();
50
52
55 DLLEXPORT QoreURL(const char* url);
56
58
61 DLLEXPORT QoreURL(const QoreString* url);
62
64
69 DLLEXPORT QoreURL(const char* url, bool keep_brackets);
70
72
77 DLLEXPORT QoreURL(const QoreString* url, bool keep_brackets);
78
80
90 DLLEXPORT QoreURL(const QoreString* url, bool keep_brackets, ExceptionSink* xsink);
91
93
100 DLLEXPORT QoreURL(const char* url, int options);
101
103
110 DLLEXPORT QoreURL(const QoreString& url, int options = 0);
111
113
120 DLLEXPORT QoreURL(const std::string& url, int options = 0);
121
123
131 DLLEXPORT QoreURL(ExceptionSink* xsink, const char* url, int options);
132
134
141 DLLEXPORT QoreURL(ExceptionSink* xsink, const QoreString& url, int options = 0);
142
144
152 DLLEXPORT QoreURL(ExceptionSink* xsink, const std::string& url, int options = 0);
153
155 DLLEXPORT ~QoreURL();
156
158
163 DLLEXPORT int parse(const char* url);
164
166
171 DLLEXPORT int parse(const QoreString* url);
172
174
183 DLLEXPORT int parse(const char* url, bool keep_brackets);
184
186
195 DLLEXPORT int parse(const QoreString* url, bool keep_brackets);
196
198
212 DLLEXPORT int parse(const QoreString* url, bool keep_brackets, ExceptionSink* xsink);
213
215
224 DLLEXPORT int parse(const char* url, int options);
225
227
236 DLLEXPORT int parse(const QoreString& url, int options = 0);
237
239
248 DLLEXPORT int parse(const std::string& url, int options = 0);
249
251
261 DLLEXPORT int parse(ExceptionSink* xsink, const char* url, int options = 0);
262
264
274 DLLEXPORT int parse(ExceptionSink* xsink, const QoreString& url, int options = 0);
275
277
287 DLLEXPORT int parse(ExceptionSink* xsink, const std::string& url, int options = 0);
288
290
292 DLLEXPORT bool isValid() const;
293
295
307 DLLEXPORT QoreHashNode* getHash();
308
310
312 DLLEXPORT const QoreString* getHost() const;
313
315
317 DLLEXPORT const QoreString* getUserName() const;
318
320
322 DLLEXPORT const QoreString* getPassword() const;
323
325
327 DLLEXPORT const QoreString* getPath() const;
328
330 DLLEXPORT const QoreString* getProtocol() const;
331
333
335 DLLEXPORT int getPort() const;
336
337 // the "take" methods return the char* pointers for the data
338 // the caller owns the memory
339
341
344 DLLEXPORT char* take_path();
345
347
350 DLLEXPORT char* take_username();
351
353
356 DLLEXPORT char* take_password();
357
359
362 DLLEXPORT char* take_host();
363
364 private:
366 struct qore_url_private* priv;
367
368 DLLLOCAL void zero();
369 DLLLOCAL void reset();
370 DLLLOCAL void parseIntern(const char* url, ExceptionSink* xsink);
371
373 DLLLOCAL QoreURL(const QoreURL&);
374
376 DLLLOCAL QoreURL& operator=(const QoreURL&);
377 };
378
379 #endif
ExceptionSink
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition: ExceptionSink.h:48
QoreHashNode
This is the hash or associative list container type in Qore, dynamically allocated only,...
Definition: QoreHashNode.h:50
QoreString
Qore's string type supported by the QoreEncoding class.
Definition: QoreString.h:93
QoreURL
helps with parsing URLs and provides access to URL components through Qore data structures
Definition: QoreURL.h:44
QoreURL::getPassword
DLLEXPORT const QoreString * getPassword() const
returns the password in the URL or 0 if none given
QoreURL::getHost
DLLEXPORT const QoreString * getHost() const
returns the hostname of the URL
QoreURL::getProtocol
DLLEXPORT const QoreString * getProtocol() const
returns the protocol component of the URL or 0 if none given
QoreURL::parse
DLLEXPORT int parse(const char *url)
parses the URL string passed
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
QoreURL::getHash
DLLEXPORT QoreHashNode * getHash()
returns a hash of the parameters parsed, destructive: zeros out all elements, caller owns the referen...
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::isValid
DLLEXPORT bool isValid() const
returns true if the URL string parsed is valid
QoreURL::getPath
DLLEXPORT const QoreString * getPath() const
returns the path component of the URL or 0 if none given
QoreURL::~QoreURL
DLLEXPORT ~QoreURL()
frees all memory and destroys the structure
QoreURL::QoreURL
DLLEXPORT QoreURL()
creates an empty structure
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::getUserName
DLLEXPORT const QoreString * getUserName() const
returns the user name in 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
QoreURL::take_path
DLLEXPORT char * take_path()
returns a pointer to the path (0 if none present), caller owns the memory returned