Qore Programming Language 2.1.1
Loading...
Searching...
No Matches
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 - 2024 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_MAINTAIN_CASE (1 << 3)
42#define QURL_DECODE_ANY (QURL_DECODE | QURL_DECODE_PATH)
43
45class QoreURL {
46public:
48
50 DLLEXPORT QoreURL();
51
53
56 DLLEXPORT QoreURL(const char* url);
57
59
62 DLLEXPORT QoreURL(const QoreString* url);
63
65
70 DLLEXPORT QoreURL(const char* url, bool keep_brackets);
71
73
78 DLLEXPORT QoreURL(const QoreString* url, bool keep_brackets);
79
81
91 DLLEXPORT QoreURL(const QoreString* url, bool keep_brackets, ExceptionSink* xsink);
92
94
101 DLLEXPORT QoreURL(const char* url, int options);
102
104
111 DLLEXPORT QoreURL(const QoreString& url, int options = 0);
112
114
121 DLLEXPORT QoreURL(const std::string& url, int options = 0);
122
124
132 DLLEXPORT QoreURL(ExceptionSink* xsink, const char* url, int options);
133
135
142 DLLEXPORT QoreURL(ExceptionSink* xsink, const QoreString& url, int options = 0);
143
145
153 DLLEXPORT QoreURL(ExceptionSink* xsink, const std::string& url, int options = 0);
154
156 DLLEXPORT ~QoreURL();
157
159
164 DLLEXPORT int parse(const char* url);
165
167
172 DLLEXPORT int parse(const QoreString* url);
173
175
184 DLLEXPORT int parse(const char* url, bool keep_brackets);
185
187
196 DLLEXPORT int parse(const QoreString* url, bool keep_brackets);
197
199
213 DLLEXPORT int parse(const QoreString* url, bool keep_brackets, ExceptionSink* xsink);
214
216
225 DLLEXPORT int parse(const char* url, int options);
226
228
237 DLLEXPORT int parse(const QoreString& url, int options = 0);
238
240
249 DLLEXPORT int parse(const std::string& url, int options = 0);
250
252
262 DLLEXPORT int parse(ExceptionSink* xsink, const char* url, int options = 0);
263
265
275 DLLEXPORT int parse(ExceptionSink* xsink, const QoreString& url, int options = 0);
276
278
288 DLLEXPORT int parse(ExceptionSink* xsink, const std::string& url, int options = 0);
289
291
293 DLLEXPORT bool isValid() const;
294
296
308 DLLEXPORT QoreHashNode* getHash();
309
311
313 DLLEXPORT const QoreString* getHost() const;
314
316
318 DLLEXPORT const QoreString* getUserName() const;
319
321
323 DLLEXPORT const QoreString* getPassword() const;
324
326
328 DLLEXPORT const QoreString* getPath() const;
329
331 DLLEXPORT const QoreString* getProtocol() const;
332
334
336 DLLEXPORT int getPort() const;
337
338 // the "take" methods return the char* pointers for the data
339 // the caller owns the memory
340
342
345 DLLEXPORT char* take_path();
346
348
351 DLLEXPORT char* take_username();
352
354
357 DLLEXPORT char* take_password();
358
360
363 DLLEXPORT char* take_host();
364
365private:
367 hashdecl qore_url_private* priv;
368
369 DLLLOCAL void zero();
370 DLLLOCAL void reset();
371 DLLLOCAL void parseIntern(const char* url, ExceptionSink* xsink);
372
374 DLLLOCAL QoreURL(const QoreURL&);
375
377 DLLLOCAL QoreURL& operator=(const QoreURL&);
378};
379
380#endif
container for holding Qore-language exception information and also for registering a "thread_exit" ca...
Definition ExceptionSink.h:50
This is the hash or associative list container type in Qore, dynamically allocated only,...
Definition QoreHashNode.h:51
Qore's string type supported by the QoreEncoding class.
Definition QoreString.h:93
helps with parsing URLs and provides access to URL components through Qore data structures
Definition QoreURL.h:45
DLLEXPORT QoreURL(const char *url)
parses the URL string passed
DLLEXPORT QoreURL(ExceptionSink *xsink, const char *url, int options)
parses the URL string passed
DLLEXPORT int parse(const QoreString *url, bool keep_brackets, ExceptionSink *xsink)
parses the URL string passed
DLLEXPORT char * take_password()
returns a pointer to the password in the URL (0 if none present), caller owns the memory returned
DLLEXPORT const QoreString * getProtocol() const
returns the protocol component of the URL or 0 if none given
DLLEXPORT char * take_host()
returns a pointer to the hostname in the URL (0 if none present), caller owns the memory returned
DLLEXPORT int parse(const char *url, bool keep_brackets)
parses the URL string passed
DLLEXPORT const QoreString * getHost() const
returns the hostname of the URL
DLLEXPORT int parse(const QoreString *url, bool keep_brackets)
parses the URL string passed
DLLEXPORT int parse(const char *url)
parses the URL string passed
DLLEXPORT QoreURL(const std::string &url, int options=0)
parses the URL string passed
DLLEXPORT const QoreString * getPath() const
returns the path component of the URL or 0 if none given
DLLEXPORT char * take_username()
returns a pointer to the username in the URL (0 if none present), caller owns the memory returned
DLLEXPORT QoreURL(ExceptionSink *xsink, const QoreString &url, int options=0)
parses the URL string passed
DLLEXPORT int parse(ExceptionSink *xsink, const char *url, int options=0)
parses the URL string passed
DLLEXPORT QoreURL(const QoreString &url, int options=0)
parses the URL string passed
DLLEXPORT int parse(ExceptionSink *xsink, const QoreString &url, int options=0)
parses the URL string passed
DLLEXPORT int parse(ExceptionSink *xsink, const std::string &url, int options=0)
parses the URL string passed
DLLEXPORT bool isValid() const
returns true if the URL string parsed is valid
DLLEXPORT int parse(const char *url, int options)
parses the URL string passed
DLLEXPORT QoreURL(const char *url, int options)
parses the URL string passed
DLLEXPORT QoreURL(const QoreString *url, bool keep_brackets)
parses the URL string passed
DLLEXPORT char * take_path()
returns a pointer to the path (0 if none present), caller owns the memory returned
DLLEXPORT QoreURL(const QoreString *url, bool keep_brackets, ExceptionSink *xsink)
parses the URL string passed
DLLEXPORT ~QoreURL()
frees all memory and destroys the structure
DLLEXPORT QoreURL()
creates an empty structure
DLLEXPORT QoreURL(const QoreString *url)
parses the URL string passed
DLLEXPORT QoreURL(ExceptionSink *xsink, const std::string &url, int options=0)
parses the URL string passed
DLLEXPORT QoreURL(const char *url, bool keep_brackets)
parses the URL string passed
DLLEXPORT int parse(const QoreString *url)
parses the URL string passed
DLLEXPORT const QoreString * getUserName() const
returns the user name in 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 int parse(const std::string &url, int options=0)
parses the URL string passed
DLLEXPORT QoreHashNode * getHash()
returns a hash of the parameters parsed, destructive: zeros out all elements, caller owns the referen...
DLLEXPORT const QoreString * getPassword() const
returns the password in the URL or 0 if none given
DLLEXPORT int parse(const QoreString &url, int options=0)
parses the URL string passed