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 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 */
34 #include "dom.h"
37 namespace org
38 {
39 namespace w3c
40 {
41 namespace dom
42 {
45 /**
46 * A class that implements the W3C URI resource reference.
47 */
48 class URI
49 {
50 public:
52 typedef enum
53 {
54 SCHEME_NONE =0,
55 SCHEME_DATA,
56 SCHEME_HTTP,
57 SCHEME_HTTPS,
58 SCHEME_FTP,
59 SCHEME_FILE,
60 SCHEME_LDAP,
61 SCHEME_MAILTO,
62 SCHEME_NEWS,
63 SCHEME_TELNET
64 } SchemeTypes;
66 /**
67 *
68 */
69 URI();
71 /**
72 *
73 */
74 URI(const DOMString &str);
77 /**
78 *
79 */
80 URI(const char *str);
82 /**
83 * Copy constructor
84 */
85 URI(const URI &other);
87 /**
88 * Assignment
89 */
90 URI &URI::operator=(const URI &other);
92 /**
93 *
94 */
95 virtual ~URI();
97 /**
98 *
99 */
100 virtual bool parse(const DOMString &str);
102 /**
103 *
104 */
105 virtual DOMString toString() const;
107 /**
108 *
109 */
110 virtual int getScheme() const;
112 /**
113 *
114 */
115 virtual DOMString getSchemeStr() const;
117 /**
118 *
119 */
120 virtual DOMString getAuthority() const;
122 /**
123 * Same as getAuthority, but if the port has been specified
124 * as host:port , the port will not be included
125 */
126 virtual DOMString getHost() const;
128 /**
129 *
130 */
131 virtual int getPort() const;
133 /**
134 *
135 */
136 virtual DOMString getPath() const;
138 /**
139 *
140 */
141 virtual DOMString getNativePath() const;
143 /**
144 *
145 */
146 virtual bool isAbsolute() const;
148 /**
149 *
150 */
151 virtual bool isOpaque() const;
153 /**
154 *
155 */
156 virtual DOMString getQuery() const;
158 /**
159 *
160 */
161 virtual DOMString getFragment() const;
163 /**
164 *
165 */
166 virtual URI resolve(const URI &other) const;
168 /**
169 *
170 */
171 virtual void normalize();
173 private:
175 void init();
177 //assign values of other to this. used by copy constructor
178 void assign(const URI &other);
180 int scheme;
182 DOMString schemeStr;
184 DOMString authority;
186 bool portSpecified;
188 int port;
190 DOMString path;
192 bool absolute;
194 bool opaque;
196 DOMString query;
198 DOMString fragment;
200 void error(const char *fmt, ...);
202 void trace(const char *fmt, ...);
205 int peek(int p);
207 int match(int p, char *key);
209 int parseScheme(int p);
211 int parseHierarchicalPart(int p0);
213 int parseQuery(int p0);
215 int parseFragment(int p0);
217 int parse(int p);
219 char *parsebuf;
221 int parselen;
223 };
227 } //namespace dom
228 } //namespace w3c
229 } //namespace org
233 #endif /* __URI_H__ */