]> git.saurik.com Git - wxWidgets.git/blame - include/wx/uri.h
Temporary fix for link error to ~wxZipOutputStream()
[wxWidgets.git] / include / wx / uri.h
CommitLineData
dd65d8c8
RN
1/////////////////////////////////////////////////////////////////////////////
2// Name: uri.h
ed6d7010 3// Purpose: wxURI - Class for parsing URIs
dd65d8c8 4// Author: Ryan Norton
ed6d7010 5// Modified By:
dd65d8c8
RN
6// Created: 07/01/2004
7// RCS-ID: $Id$
8// Licence: wxWindows
9/////////////////////////////////////////////////////////////////////////////
10
8404931e
VZ
11#ifndef _WX_URI_H_
12#define _WX_URI_H_
dd65d8c8 13
eebaafb5 14#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
dd65d8c8
RN
15#pragma interface "uri.h"
16#endif
17
18#include "wx/defs.h"
19#include "wx/object.h"
20#include "wx/string.h"
21
ce321570 22// Host Type that the server component can be
8404931e 23enum wxURIHostType
dd65d8c8 24{
ed6d7010
DS
25 wxURI_REGNAME, // Host is a normal register name (www.mysite.com etc.)
26 wxURI_IPV4ADDRESS, // Host is a version 4 ip address (192.168.1.100)
ce321570 27 wxURI_IPV6ADDRESS, // Host is a version 6 ip address [aa:aa:aa:aa::aa:aa]:5050
ed6d7010 28 wxURI_IPVFUTURE // Host is a future ip address (wxURI is unsure what kind)
8404931e 29};
dd65d8c8
RN
30
31// Component Flags
8404931e 32enum wxURIFieldType
dd65d8c8
RN
33{
34 wxURI_SCHEME = 1,
4860d40d 35 wxURI_USERINFO = 2,
dd65d8c8
RN
36 wxURI_SERVER = 4,
37 wxURI_PORT = 8,
38 wxURI_PATH = 16,
39 wxURI_QUERY = 32,
40 wxURI_FRAGMENT = 64
8404931e
VZ
41};
42
43// Miscellaneous other flags
44enum wxURIFlags
45{
46 wxURI_STRICT = 1
47};
48
dd65d8c8
RN
49
50// Generic class for parsing URIs.
51//
4cc52142 52// See RFC 3986
fd1017cd 53class WXDLLIMPEXP_BASE wxURI : public wxObject
dd65d8c8
RN
54{
55public:
56 wxURI();
57 wxURI(const wxString& uri);
58 wxURI(const wxURI& uri);
59
8404931e 60 virtual ~wxURI();
dd65d8c8 61
86470d43 62 const wxChar* Create(const wxString& uri);
dd65d8c8 63
b60b2ec8 64 bool HasScheme() const { return (m_fields & wxURI_SCHEME) == wxURI_SCHEME; }
4860d40d 65 bool HasUserInfo() const { return (m_fields & wxURI_USERINFO) == wxURI_USERINFO; }
b60b2ec8
RN
66 bool HasServer() const { return (m_fields & wxURI_SERVER) == wxURI_SERVER; }
67 bool HasPort() const { return (m_fields & wxURI_PORT) == wxURI_PORT; }
68 bool HasPath() const { return (m_fields & wxURI_PATH) == wxURI_PATH; }
69 bool HasQuery() const { return (m_fields & wxURI_QUERY) == wxURI_QUERY; }
70 bool HasFragment() const { return (m_fields & wxURI_FRAGMENT) == wxURI_FRAGMENT; }
ed6d7010 71
b60b2ec8
RN
72 const wxString& GetScheme() const { return m_scheme; }
73 const wxString& GetPath() const { return m_path; }
74 const wxString& GetQuery() const { return m_query; }
75 const wxString& GetFragment() const { return m_fragment; }
76 const wxString& GetPort() const { return m_port; }
4860d40d 77 const wxString& GetUserInfo() const { return m_userinfo; }
b60b2ec8
RN
78 const wxString& GetServer() const { return m_server; }
79 const wxURIHostType& GetHostType() const { return m_hostType; }
dd65d8c8 80
4860d40d
RN
81 //Note that the following two get functions are explicitly depreciated by RFC 2396
82 wxString GetUser() const;
83 wxString GetPassword() const;
ed6d7010 84
86470d43
RN
85 wxString BuildURI() const;
86 wxString BuildUnescapedURI() const;
dd65d8c8 87
8404931e 88 void Resolve(const wxURI& base, int flags = wxURI_STRICT);
dd65d8c8
RN
89 bool IsReference() const;
90
91 wxURI& operator = (const wxURI& uri);
b60b2ec8 92 wxURI& operator = (const wxString& string);
dd65d8c8 93 bool operator == (const wxURI& uri) const;
86470d43
RN
94
95 static wxString Unescape (const wxString& szEscapedURI);
ed6d7010 96
dd65d8c8 97protected:
b60b2ec8 98 wxURI& Assign(const wxURI& uri);
dd65d8c8
RN
99
100 void Clear();
101
102 const wxChar* Parse (const wxChar* uri);
103 const wxChar* ParseAuthority (const wxChar* uri);
104 const wxChar* ParseScheme (const wxChar* uri);
4860d40d 105 const wxChar* ParseUserInfo (const wxChar* uri);
dd65d8c8
RN
106 const wxChar* ParseServer (const wxChar* uri);
107 const wxChar* ParsePort (const wxChar* uri);
8404931e
VZ
108 const wxChar* ParsePath (const wxChar* uri,
109 bool bReference = false,
110 bool bNormalize = true);
dd65d8c8
RN
111 const wxChar* ParseQuery (const wxChar* uri);
112 const wxChar* ParseFragment (const wxChar* uri);
113
114
115 static bool ParseH16(const wxChar*& uri);
116 static bool ParseIPv4address(const wxChar*& uri);
117 static bool ParseIPv6address(const wxChar*& uri);
118 static bool ParseIPvFuture(const wxChar*& uri);
119
8404931e 120 static void Normalize(wxChar* uri, bool bIgnoreLeads = false);
dd65d8c8
RN
121 static void UpTree(const wxChar* uristart, const wxChar*& uri);
122
86470d43 123 static wxChar TranslateEscape(const wxChar* s);
dd65d8c8
RN
124 static void Escape (wxString& s, const wxChar& c);
125 static bool IsEscape(const wxChar*& uri);
126
409a7ba7 127 static wxChar CharToHex(const wxChar& c);
dd65d8c8
RN
128
129 static bool IsUnreserved (const wxChar& c);
130 static bool IsReserved (const wxChar& c);
131 static bool IsGenDelim (const wxChar& c);
132 static bool IsSubDelim (const wxChar& c);
133 static bool IsHex(const wxChar& c);
134 static bool IsAlpha(const wxChar& c);
135 static bool IsDigit(const wxChar& c);
136
137 wxString m_scheme;
138 wxString m_path;
139 wxString m_query;
140 wxString m_fragment;
141
4860d40d 142 wxString m_userinfo;
dd65d8c8
RN
143 wxString m_server;
144 wxString m_port;
145
146 wxURIHostType m_hostType;
147
148 size_t m_fields;
149
150 DECLARE_DYNAMIC_CLASS(wxURI)
8404931e
VZ
151};
152
153#endif // _WX_URI_H_
dd65d8c8 154