Code

a89f4ae7bf512d280ae9b847a8b4e9425e36bb14
[inkscape.git] / src / dom / uri.h
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 bool isAbsolute() const;
143     /**
144      *
145      */
146     virtual bool isOpaque() const;
148     /**
149      *
150      */
151     virtual DOMString getQuery() const;
153     /**
154      *
155      */
156     virtual DOMString getFragment() const;
158     /**
159      *
160      */
161     virtual URI resolve(const URI &other) const;
163     /**
164      *
165      */
166     virtual void normalize();
168 private:
170     void init();
172     //assign values of other to this. used by copy constructor
173     void assign(const URI &other);
175     int scheme;
177     DOMString schemeStr;
179     DOMString authority;
181     bool portSpecified;
183     int port;
185     DOMString path;
187     bool absolute;
189     bool opaque;
191     DOMString query;
193     DOMString fragment;
195     void error(const char *fmt, ...);
197     void trace(const char *fmt, ...);
200     int peek(int p);
202     int match(int p, char *key);
204     int parseScheme(int p);
206     int parseHierarchicalPart(int p0);
208     int parseQuery(int p0);
210     int parseFragment(int p0);
212     int parse(int p);
214     char *parsebuf;
216     int parselen;
218 };
222 }  //namespace dom
223 }  //namespace w3c
224 }  //namespace org
228 #endif /* __URI_H__ */