url.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. #ifndef _WX_URL_H
  11. #define _WX_URL_H
  12. #include "wx/defs.h"
  13. #if wxUSE_URL
  14. #include "wx/uri.h"
  15. #include "wx/protocol/protocol.h"
  16. #if wxUSE_PROTOCOL_HTTP
  17. #include "wx/protocol/http.h"
  18. #endif
  19. typedef enum {
  20. wxURL_NOERR = 0,
  21. wxURL_SNTXERR,
  22. wxURL_NOPROTO,
  23. wxURL_NOHOST,
  24. wxURL_NOPATH,
  25. wxURL_CONNERR,
  26. wxURL_PROTOERR
  27. } wxURLError;
  28. #if wxUSE_URL_NATIVE
  29. class WXDLLIMPEXP_FWD_NET wxURL;
  30. class WXDLLIMPEXP_NET wxURLNativeImp : public wxObject
  31. {
  32. public:
  33. virtual ~wxURLNativeImp() { }
  34. virtual wxInputStream *GetInputStream(wxURL *owner) = 0;
  35. };
  36. #endif // wxUSE_URL_NATIVE
  37. class WXDLLIMPEXP_NET wxURL : public wxURI
  38. {
  39. public:
  40. wxURL(const wxString& sUrl = wxEmptyString);
  41. wxURL(const wxURI& uri);
  42. wxURL(const wxURL& url);
  43. virtual ~wxURL();
  44. wxURL& operator = (const wxString& url);
  45. wxURL& operator = (const wxURI& uri);
  46. wxURL& operator = (const wxURL& url);
  47. wxProtocol& GetProtocol() { return *m_protocol; }
  48. wxURLError GetError() const { return m_error; }
  49. wxString GetURL() const { return m_url; }
  50. wxURLError SetURL(const wxString &url)
  51. { *this = url; return m_error; }
  52. bool IsOk() const
  53. { return m_error == wxURL_NOERR; }
  54. wxInputStream *GetInputStream();
  55. #if wxUSE_PROTOCOL_HTTP
  56. static void SetDefaultProxy(const wxString& url_proxy);
  57. void SetProxy(const wxString& url_proxy);
  58. #endif // wxUSE_PROTOCOL_HTTP
  59. protected:
  60. static wxProtoInfo *ms_protocols;
  61. #if wxUSE_PROTOCOL_HTTP
  62. static wxHTTP *ms_proxyDefault;
  63. static bool ms_useDefaultProxy;
  64. wxHTTP *m_proxy;
  65. bool m_useProxy;
  66. #endif // wxUSE_PROTOCOL_HTTP
  67. #if wxUSE_URL_NATIVE
  68. friend class wxURLNativeImp;
  69. // pointer to a native URL implementation object
  70. wxURLNativeImp *m_nativeImp;
  71. // Creates on the heap and returns a native
  72. // implementation object for the current platform.
  73. static wxURLNativeImp *CreateNativeImpObject();
  74. #endif // wxUSE_URL_NATIVE
  75. wxProtoInfo *m_protoinfo;
  76. wxProtocol *m_protocol;
  77. wxURLError m_error;
  78. wxString m_url;
  79. void Init(const wxString&);
  80. bool ParseURL();
  81. void CleanData();
  82. void Free();
  83. bool FetchProtocol();
  84. friend class wxProtoInfo;
  85. friend class wxURLModule;
  86. private:
  87. DECLARE_DYNAMIC_CLASS(wxURL)
  88. };
  89. #endif // wxUSE_URL
  90. #endif // _WX_URL_H