Qore Programming Language - C/C++ Library  0.8.12.2
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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 - 2015 David Nichols
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);
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  DLLEXPORT ~QoreURL();
88 
90 
94  DLLEXPORT int parse(const char* url);
95 
97 
101  DLLEXPORT int parse(const QoreString* url);
102 
104 
110  DLLEXPORT int parse(const char* url, bool keep_brackets);
111 
113 
119  DLLEXPORT int parse(const QoreString* url, bool keep_brackets);
120 
122 
124  DLLEXPORT bool isValid() const;
125 
127 
139  DLLEXPORT QoreHashNode* getHash();
140 
142 
144  DLLEXPORT const QoreString* getHost() const;
145 
147 
149  DLLEXPORT const QoreString* getUserName() const;
150 
152 
154  DLLEXPORT const QoreString* getPassword() const;
155 
157 
159  DLLEXPORT const QoreString* getPath() const;
160 
162  DLLEXPORT const QoreString* getProtocol() const;
163 
165 
167  DLLEXPORT int getPort() const;
168 
169  // the "take" methods return the char* pointers for the data
170  // the caller owns the memory
171 
173 
176  DLLEXPORT char* take_path();
177 
179 
182  DLLEXPORT char* take_username();
183 
185 
188  DLLEXPORT char* take_password();
189 
191 
194  DLLEXPORT char* take_host();
195 };
196 
197 #endif
DLLEXPORT char * take_username()
returns a pointer to the username in the URL (0 if none present), caller owns the memory returned ...
DLLEXPORT ~QoreURL()
frees all memory and destroys the structure
DLLEXPORT bool isValid() const
returns true if the URL string parsed is valid
This is the hash or associative list container type in Qore, dynamically allocated only...
Definition: QoreHashNode.h:49
DLLEXPORT const QoreString * getProtocol() const
returns the protocol component of the URL or 0 if none given
DLLEXPORT int parse(const char *url)
parses the URL string passed
DLLEXPORT QoreHashNode * getHash()
returns a hash of the parameters parsed, destructive: zeros out all elements, caller owns the referen...
helps with parsing URLs and provides access to URL components through Qore data structures ...
Definition: QoreURL.h:39
DLLEXPORT const QoreString * getUserName() const
returns the user name in the URL or 0 if none given
DLLEXPORT const QoreString * getHost() const
returns the hostname of the URL
DLLEXPORT char * take_password()
returns a pointer to the password in the URL (0 if none present), caller owns the memory returned ...
DLLEXPORT int getPort() const
returns the port number given in the URL or 0 if none present
Qore's string type supported by the QoreEncoding class.
Definition: QoreString.h:82
DLLEXPORT const QoreString * getPath() const
returns the path component of the URL or 0 if none given
DLLEXPORT char * take_path()
returns a pointer to the path (0 if none present), caller owns the memory returned ...
DLLEXPORT const QoreString * getPassword() const
returns the password in 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 QoreURL()
creates an empty structure