Networking Tools: Thread-hot Internet Classes (int library)
data() error() host() isKnown() isValid() |
mailAddress() newsArticle() newsGroup() operator<<() operator==() |
password() path() port() scheme() search() |
type() user() |
#include <rw/toolpro/url.h> RWURL url("http://www.roguewave.com");
thr, net, int, tls (and possibly std)
RWURL is a convenience class that encapsulates parsing and component management of URL information. URLs are assumed to be in RFC1738 format:
<scheme>:<scheme data>
RWURL implicitly has knowledge of some URL schemes. These include URLs supported by the thread-hot internet classes, as well as some other common URL schemes. Specific URL schemes known to the RWURL class include: HTTP, FTP, MAILTO, NEWS, NNTP, and FILE.
URL schemes not known to RWURL return FALSE from the isKnown method. URL schemes that are known but have basic syntactical errors return FALSE from the isValid method.
It is important to properly encode any unsafe characters in the URL. See RFC1738 or subsequent documents for proper encoding methods and syntactical questions.
#include <iostream.h> #include <rw/toolpro/winsock.h> #include <rw/toolpro/url.h> void main() { RWWinSockInfo info; RWURL url("http://www.roguewave.com/tools.txt"); cout << url.scheme() << endl; cout << url.host() << endl; cout << url.path() << endl; }
Program Output
http www.roguewave.com tools.txt
RWURL();
Constructs a default empty RWURL object. Self needs to be initialized using the assignment operator.
RWURL(const RWCString& urlString);
Constructs an RWURL from a const RWCString reference. The URL is expected to be in RFC1738 form.
RWBoolean operator==(const RWURL& url) const;
Returns TRUE if self and the input url represent the same URL.
RWCString data() const;
Returns the whole URL string used to construct the RWURL object. This method is useful if the isKnown method returns FALSE, indicating it is an unknown URL type.
RWCString error() const;
Returns a textual explanation of a FALSE response from either the isValid or the isKnown method.
RWCString host() const;
Returns the host portion of the URL, if applicable. In the example URL ftp://ftp.roguewave.com, the method returns ftp.roguewave.com. URLs that do not contain host information, such as mailto: me@roguewave.com, return an empty string.
RWBoolean isKnown() const;
Returns TRUE for URL schemes specifically recognized by the class.
RWBoolean isValid() const;
Returns FALSE if the URL scheme is specifically a recognized format, but a syntactical error exists during parsing. A call to the data method returns the url string used during attempted construction. A call to the error method returns a descriptive text string describing why the input URL string could not be parsed successfully. Note that it also returns FALSE if the URL scheme is not specifically known.
RWCString mailAddress() const;
Returns the email address portion of the URL, if applicable. In the example URL mailto: me@roguewave.com, the method returns me@roguewave.com. URLs that contain no email information return an empty string.
RWCString newsArticle() const;
Returns the news article portion of the URL, if applicable. In the example URL nntp://comp.windows/4u7lb0$t5s@roguewave.com, it returns 4u7lb0$t5s@roguewave.com. URLs that contain no explicit news article information return an empty string.
RWCString newsGroup() const;
Returns the specified newsgroup portion of the URL, if applicable. In the example URL news:comp.windows, it returns comp.windows. URLs that contain no explicit newsgroup information return an empty string.
RWCString password() const;
Returns the password portion of the URL, if applicable. In the example URL ftp://fred:pluto@ftp.roguewave.com:21/pub, it returns pluto. URLs that contain no explicit password information return an empty string.
RWCString path() const;
Returns the path portion of the URL, if applicable. In the example URL ftp://ftp.roguewave.com/pub, it returns pub. Note that the single slash / before pub in the example is NOT part of the path information. If a leading slash is required for the path information, consult RFC1738 or subsequent documents about proper unsafe character encoding techniques. URLs that do not contain path information, such as mailto: me@roguewave.com, return an empty string.
RWCString port() const;
Returns the port portion of the URL, if applicable. In the example URL ftp://ftp.roguewave.com:21/pub, it returns 21. URLs that contain no explicit port information return an empty string.
RWCString search() const;
Returns the search string portion of the URL, if applicable. In the example URL http://www.roguewave.com/pub?archive=mswin95, it returns archive=mswin95. URLs that contain no explicit search information return an empty string.
RWCString scheme() const;
Returns the scheme portion of the URL. In the example URL http://www.roguewave.com, it returns http.
RWCString type() const;
Returns the transfer type portion of the URL, if applicable. In the example URL ftp://www.roguewave.com/doc.txt;type=a, it returns a. URLs that contain no explicit type information return an empty string.
RWCString user() const;
Returns the user portion of the URL, if applicable. In the example URL ftp://fred:pluto@ftp.roguewave.com:21/pub, it returns fred. URLs that contain no explicit user information return an empty string.
ostream& operator<<(ostream& strm, const RWURL& url);
Outputs an RWURL object to an ostream.
Note: This class does not have an extraction (>>) operator.
©Copyright 2000, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.