File: url.h

package info (click to toggle)
wxpython3.0 3.0.2.0%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 482,760 kB
  • ctags: 518,293
  • sloc: cpp: 2,127,226; python: 294,045; makefile: 51,942; ansic: 19,033; sh: 3,013; xml: 1,629; perl: 17
file content (128 lines) | stat: -rw-r--r-- 3,861 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/////////////////////////////////////////////////////////////////////////////
// Name:        url.h
// Purpose:     interface of wxURL
// Author:      wxWidgets team
// Licence:     wxWindows licence
/////////////////////////////////////////////////////////////////////////////

/**
    Error types returned from wxURL::GetError().
*/
typedef enum {
    wxURL_NOERR = 0,    ///< No error.
    wxURL_SNTXERR,      ///< Syntax error in the URL string.
    wxURL_NOPROTO,      ///< Found no protocol which can get this URL.
    wxURL_NOHOST,       ///< A host name is required for this protocol.
    wxURL_NOPATH,       ///< A path is required for this protocol.
    wxURL_CONNERR,      ///< Connection error.
    wxURL_PROTOERR      ///< An error occurred during negotiation.
} wxURLError;

/**
    @class wxURL

    wxURL is a specialization of wxURI for parsing URLs. Please look at wxURI
    documentation for more info about the functions you can use to retrieve the
    various parts of the URL (scheme, server, port, etc).

    Supports standard assignment operators, copy constructors, and comparison
    operators.

    @library{wxnet}
    @category{net}

    @see wxSocketBase, wxProtocol
*/
class wxURL : public wxURI
{
public:
    /**
        Constructs a URL object from the string. The URL must be valid
        according to RFC 1738. In particular, file URLs must be of the format
        @c "file://hostname/path/to/file", otherwise GetError() will return a
        value different from ::wxURL_NOERR.

        It is valid to leave out the hostname but slashes must remain in place,
        in other words, a file URL without a hostname must contain three
        consecutive slashes (e.g. @c "file:///somepath/myfile").

        @param url
            Url string to parse.
    */
    wxURL(const wxString& url = wxEmptyString);

    /**
        Destroys the URL object.
    */
    virtual ~wxURL();

    /**
        Returns the last error. This error refers to the URL parsing or to the
        protocol. It can be one of ::wxURLError.
    */
    wxURLError GetError() const;

    /**
        Creates a new input stream on the specified URL. You can use all but
        seek functionality of wxStream. Seek isn't available on all streams.
        For example, HTTP or FTP streams don't deal with it.

        Note that this method is somewhat deprecated, all future wxWidgets
        applications should use wxFileSystem instead.

        Example:

        @code
        wxURL url("http://a.host/a.dir/a.file");
        if (url.GetError() == wxURL_NOERR)
        {
            wxInputStream *in_stream;

            in_stream = url.GetInputStream();
            // Then, you can use all IO calls of in_stream (See wxStream)
        }
        @endcode

        @return Returns the initialized stream. You will have to delete it
                 yourself.

        @see wxInputStream
    */
    wxInputStream* GetInputStream();

    /**
        Returns a reference to the protocol which will be used to get the URL.
    */
    wxProtocol& GetProtocol();

    /**
        Returns @true if this object is correctly initialized, i.e.\ if
        GetError() returns ::wxURL_NOERR.
    */
    bool IsOk() const;

    /**
        Sets the default proxy server to use to get the URL. The string
        specifies the proxy like this: @c "<hostname>:<port number>".

        @param url_proxy
            Specifies the proxy to use.

        @see SetProxy()
    */
    static void SetDefaultProxy(const wxString& url_proxy);

    /**
        Sets the proxy to use for this URL.

        @see SetDefaultProxy()
    */
    void SetProxy(const wxString& url_proxy);

    /**
        Initializes this object with the given URL and returns ::wxURL_NOERR if
        it's valid (see GetError() for more info).
    */
    wxURLError SetURL(const wxString& url);
};