57c5c5554e68b35109bfede589b05d2912cd9037
1 #ifndef __URI_H__
2 #define __URI_H__
4 /**
5 * Phoebe DOM Implementation.
6 *
7 * This is a C++ approximation of the W3C DOM model, which follows
8 * fairly closely the specifications in the various .idl files, copies of
9 * which are provided for reference. Most important is this one:
10 *
11 * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html
12 *
13 * Authors:
14 * Bob Jamison
15 *
16 * Copyright (C) 2005-2007 Bob Jamison
17 *
18 * This library is free software; you can redistribute it and/or
19 * modify it under the terms of the GNU Lesser General Public
20 * License as published by the Free Software Foundation; either
21 * version 2.1 of the License, or (at your option) any later version.
22 *
23 * This library is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26 * Lesser General Public License for more details.
27 *
28 * You should have received a copy of the GNU Lesser General Public
29 * License along with this library; if not, write to the Free Software
30 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
31 */
33 #include "dom.h"
36 namespace org
37 {
38 namespace w3c
39 {
40 namespace dom
41 {
44 /**
45 * A class that implements the W3C URI resource reference.
46 */
47 class URI
48 {
49 public:
51 typedef enum
52 {
53 SCHEME_NONE =0,
54 SCHEME_DATA,
55 SCHEME_HTTP,
56 SCHEME_HTTPS,
57 SCHEME_FTP,
58 SCHEME_FILE,
59 SCHEME_LDAP,
60 SCHEME_MAILTO,
61 SCHEME_NEWS,
62 SCHEME_TELNET
63 } SchemeTypes;
65 /**
66 *
67 */
68 URI();
70 /**
71 *
72 */
73 URI(const DOMString &str);
76 /**
77 *
78 */
79 URI(const char *str);
81 /**
82 * Copy constructor
83 */
84 URI(const URI &other);
86 /**
87 * Assignment
88 */
89 URI &operator=(const URI &other);
91 /**
92 *
93 */
94 virtual ~URI();
96 /**
97 *
98 */
99 virtual bool parse(const DOMString &str);
101 /**
102 *
103 */
104 virtual DOMString toString() const;
106 /**
107 *
108 */
109 virtual int getScheme() const;
111 /**
112 *
113 */
114 virtual DOMString getSchemeStr() const;
116 /**
117 *
118 */
119 virtual DOMString getAuthority() const;
121 /**
122 * Same as getAuthority, but if the port has been specified
123 * as host:port , the port will not be included
124 */
125 virtual DOMString getHost() const;
127 /**
128 *
129 */
130 virtual int getPort() const;
132 /**
133 *
134 */
135 virtual DOMString getPath() const;
137 /**
138 *
139 */
140 virtual DOMString getNativePath() const;
142 /**
143 *
144 */
145 virtual bool isAbsolute() const;
147 /**
148 *
149 */
150 virtual bool isOpaque() const;
152 /**
153 *
154 */
155 virtual DOMString getQuery() const;
157 /**
158 *
159 */
160 virtual DOMString getFragment() const;
162 /**
163 *
164 */
165 virtual URI resolve(const URI &other) const;
167 /**
168 *
169 */
170 virtual void normalize();
172 private:
174 void init();
176 //assign values of other to this. used by copy constructor
177 void assign(const URI &other);
179 int scheme;
181 DOMString schemeStr;
183 DOMString authority;
185 bool portSpecified;
187 int port;
189 DOMString path;
191 bool absolute;
193 bool opaque;
195 DOMString query;
197 DOMString fragment;
199 void error(const char *fmt, ...)
200 #ifdef G_GNUC_PRINTF
201 G_GNUC_PRINTF(2, 3)
202 #endif
203 ;
205 void trace(const char *fmt, ...)
206 #ifdef G_GNUC_PRINTF
207 G_GNUC_PRINTF(2, 3)
208 #endif
209 ;
211 int peek(int p);
213 int match(int p, char *key);
215 int parseHex(int p, int &result);
217 int parseEntity(int p, int &result);
219 int parseAsciiEntity(int p, int &result);
221 int parseScheme(int p);
223 int parseHierarchicalPart(int p0);
225 int parseQuery(int p0);
227 int parseFragment(int p0);
229 int parse(int p);
231 char *parsebuf;
233 int parselen;
235 };
239 } //namespace dom
240 } //namespace w3c
241 } //namespace org
245 #endif /* __URI_H__ */