]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/uri.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxURI - Class for parsing URIs
8 // Copyright: (c) Ryan Norton
9 // Licence: wxWindows Licence
10 /////////////////////////////////////////////////////////////////////////////
16 #include "wx/object.h"
17 #include "wx/string.h"
19 // Host Type that the server component can be
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)
24 wxURI_IPV6ADDRESS
, // Host is a version 6 ip address [aa:aa:aa:aa::aa:aa]:5050
25 wxURI_IPVFUTURE
// Host is a future ip address (wxURI is unsure what kind)
40 // Miscellaneous other flags
47 // Generic class for parsing URIs.
50 class WXDLLIMPEXP_BASE wxURI
: public wxObject
54 wxURI(const wxString
& uri
);
55 wxURI(const wxURI
& uri
);
59 const wxChar
* Create(const wxString
& uri
);
61 bool HasScheme() const { return (m_fields
& wxURI_SCHEME
) == wxURI_SCHEME
; }
62 bool HasUserInfo() const { return (m_fields
& wxURI_USERINFO
) == wxURI_USERINFO
; }
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
; }
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
; }
74 const wxString
& GetUserInfo() const { return m_userinfo
; }
75 const wxString
& GetServer() const { return m_server
; }
76 const wxURIHostType
& GetHostType() const { return m_hostType
; }
78 //Note that the following two get functions are explicitly depreciated by RFC 2396
79 wxString
GetUser() const;
80 wxString
GetPassword() const;
82 wxString
BuildURI() const;
83 wxString
BuildUnescapedURI() const;
85 void Resolve(const wxURI
& base
, int flags
= wxURI_STRICT
);
86 bool IsReference() const;
88 wxURI
& operator = (const wxURI
& uri
);
89 wxURI
& operator = (const wxString
& string
);
90 bool operator == (const wxURI
& uri
) const;
92 static wxString
Unescape (const wxString
& szEscapedURI
);
95 wxURI
& Assign(const wxURI
& uri
);
99 const wxChar
* Parse (const wxChar
* uri
);
100 const wxChar
* ParseAuthority (const wxChar
* uri
);
101 const wxChar
* ParseScheme (const wxChar
* uri
);
102 const wxChar
* ParseUserInfo (const wxChar
* uri
);
103 const wxChar
* ParseServer (const wxChar
* uri
);
104 const wxChar
* ParsePort (const wxChar
* uri
);
105 const wxChar
* ParsePath (const wxChar
* uri
,
106 bool bReference
= false,
107 bool bNormalize
= true);
108 const wxChar
* ParseQuery (const wxChar
* uri
);
109 const wxChar
* ParseFragment (const wxChar
* uri
);
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
);
117 static void Normalize(wxChar
* uri
, bool bIgnoreLeads
= false);
118 static void UpTree(const wxChar
* uristart
, const wxChar
*& uri
);
120 static wxChar
TranslateEscape(const wxChar
* s
);
121 static void Escape (wxString
& s
, const wxChar
& c
);
122 static bool IsEscape(const wxChar
*& uri
);
124 static wxChar
CharToHex(const wxChar
& c
);
126 static bool IsUnreserved (const wxChar
& c
);
127 static bool IsReserved (const wxChar
& c
);
128 static bool IsGenDelim (const wxChar
& c
);
129 static bool IsSubDelim (const wxChar
& c
);
130 static bool IsHex(const wxChar
& c
);
131 static bool IsAlpha(const wxChar
& c
);
132 static bool IsDigit(const wxChar
& c
);
143 wxURIHostType m_hostType
;
147 DECLARE_DYNAMIC_CLASS(wxURI
)