]> git.saurik.com Git - wxWidgets.git/blob - include/wx/url.h
Don't define __STRICT_ANSI__, we should build both with and without it.
[wxWidgets.git] / include / wx / url.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/url.h
3 // Purpose: URL parser
4 // Author: Guilhem Lavaux
5 // Modified by: Ryan Norton
6 // Created: 20/07/1997
7 // Copyright: (c) 1997, 1998 Guilhem Lavaux
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _WX_URL_H
12 #define _WX_URL_H
13
14 #include "wx/defs.h"
15
16 #if wxUSE_URL
17
18 #include "wx/uri.h"
19 #include "wx/protocol/protocol.h"
20
21 #if wxUSE_PROTOCOL_HTTP
22 #include "wx/protocol/http.h"
23 #endif
24
25 typedef enum {
26 wxURL_NOERR = 0,
27 wxURL_SNTXERR,
28 wxURL_NOPROTO,
29 wxURL_NOHOST,
30 wxURL_NOPATH,
31 wxURL_CONNERR,
32 wxURL_PROTOERR
33 } wxURLError;
34
35 #if wxUSE_URL_NATIVE
36 class WXDLLIMPEXP_FWD_NET wxURL;
37
38 class WXDLLIMPEXP_NET wxURLNativeImp : public wxObject
39 {
40 public:
41 virtual ~wxURLNativeImp() { }
42 virtual wxInputStream *GetInputStream(wxURL *owner) = 0;
43 };
44 #endif // wxUSE_URL_NATIVE
45
46 class WXDLLIMPEXP_NET wxURL : public wxURI
47 {
48 public:
49 wxURL(const wxString& sUrl = wxEmptyString);
50 wxURL(const wxURI& uri);
51 wxURL(const wxURL& url);
52 virtual ~wxURL();
53
54 wxURL& operator = (const wxString& url);
55 wxURL& operator = (const wxURI& uri);
56 wxURL& operator = (const wxURL& url);
57
58 wxProtocol& GetProtocol() { return *m_protocol; }
59 wxURLError GetError() const { return m_error; }
60 wxString GetURL() const { return m_url; }
61
62 wxURLError SetURL(const wxString &url)
63 { *this = url; return m_error; }
64
65 bool IsOk() const
66 { return m_error == wxURL_NOERR; }
67
68 wxInputStream *GetInputStream();
69
70 #if wxUSE_PROTOCOL_HTTP
71 static void SetDefaultProxy(const wxString& url_proxy);
72 void SetProxy(const wxString& url_proxy);
73 #endif // wxUSE_PROTOCOL_HTTP
74
75 protected:
76 static wxProtoInfo *ms_protocols;
77
78 #if wxUSE_PROTOCOL_HTTP
79 static wxHTTP *ms_proxyDefault;
80 static bool ms_useDefaultProxy;
81 wxHTTP *m_proxy;
82 bool m_useProxy;
83 #endif // wxUSE_PROTOCOL_HTTP
84
85 #if wxUSE_URL_NATIVE
86 friend class wxURLNativeImp;
87 // pointer to a native URL implementation object
88 wxURLNativeImp *m_nativeImp;
89 // Creates on the heap and returns a native
90 // implementation object for the current platform.
91 static wxURLNativeImp *CreateNativeImpObject();
92 #endif // wxUSE_URL_NATIVE
93
94 wxProtoInfo *m_protoinfo;
95 wxProtocol *m_protocol;
96
97 wxURLError m_error;
98 wxString m_url;
99
100 void Init(const wxString&);
101 bool ParseURL();
102 void CleanData();
103 void Free();
104 bool FetchProtocol();
105
106 friend class wxProtoInfo;
107 friend class wxURLModule;
108
109 private:
110 DECLARE_DYNAMIC_CLASS(wxURL)
111 };
112
113 #endif // wxUSE_URL
114
115 #endif // _WX_URL_H
116