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