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