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 {
46 class URI
47 {
48 public:
50 typedef enum
51 {
52 SCHEME_NONE,
53 SCHEME_DATA,
54 SCHEME_HTTP,
55 SCHEME_FTP,
56 SCHEME_FILE,
57 SCHEME_LDAP,
58 SCHEME_MAILTO,
59 SCHEME_NEWS,
60 SCHEME_TELNET
61 } SchemeTypes;
63 /**
64 *
65 */
66 URI();
68 /**
69 *
70 */
71 URI(const DOMString &str);
74 /**
75 *
76 */
77 URI(const char *str);
79 /**
80 *
81 */
82 URI(const URI &other);
84 /**
85 *
86 */
87 virtual ~URI();
89 /**
90 *
91 */
92 virtual bool parse(const DOMString &str);
94 /**
95 *
96 */
97 virtual DOMString toString();
99 /**
100 *
101 */
102 virtual int getScheme();
104 /**
105 *
106 */
107 virtual DOMString getSchemeStr();
109 /**
110 *
111 */
112 virtual DOMString getAuthority();
114 /**
115 *
116 */
117 virtual DOMString getPath();
119 /**
120 *
121 */
122 virtual bool getIsAbsolute();
124 /**
125 *
126 */
127 virtual DOMString getQuery();
129 /**
130 *
131 */
132 virtual DOMString getFragment();
134 private:
136 void init();
138 int scheme;
140 DOMString schemeStr;
142 DOMString authority;
144 DOMString path;
146 bool absolute;
148 DOMString query;
150 DOMString fragment;
152 void error(const char *fmt, ...);
154 void trace(const char *fmt, ...);
157 int peek(int p);
159 int match(int p, char *key);
161 int parseScheme(int p);
163 int parseHierarchicalPart(int p0);
165 int parseQuery(int p0);
167 int parseFragment(int p0);
169 int parse(int p);
171 char *parsebuf;
173 int parselen;
175 };
179 } //namespace dom
180 } //namespace w3c
181 } //namespace org
185 #endif /* __URI_H__ */