Module: Internet Protocols Module Package: Internet Basics
Does not inherit
getData() getError() getHost() getMailAddress() getNewsArticle() |
getNewsGroup() getPassword() getPath() getPort() getScheme() |
getSearch() getType() getUser() isKnown() isValid() |
operator==() RWURL() |
#include <rw/internet/RWURL.h>
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 has implicit knowledge of common URL schemes, that 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.
You must properly encode any unsafe characters in the URL. See RFC1738 or subsequent documents for proper encoding methods and syntactical questions.
#include <rw/rstream.h> #include <rw/network/RWWinSockInfo.h> #include <rw/internet/RWURL.h> int main() { RWWinSockInfo info; RWURL url("http://www.roguewave.com/tools.txt"); cout << url.getScheme() << endl; cout << url.getHost() << endl; cout << url.getPath() << endl; return 0; }
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.
bool operator==(const RWURL& url) const;
Returns true if self and the input url represent the same URL.
RWCString getData() 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. The RWCString should contain 7-bit US-ASCII data.
RWCString getError() const;
Returns a textual explanation of a false response from either the isValid() or the isKnown() method.
RWCString getHost() 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. The RWCString should contain 7-bit US-ASCII data.
RWCString getMailAddress() 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 do not contain email information return an empty string. The RWCString should contain 7-bit US-ASCII data.
RWCString getNewsArticle() 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 do not contain explicit news article information return an empty string. The RWCString should contain 7-bit US-ASCII data.
RWCString getNewsGroup() 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. The RWCString should contain 7-bit US-ASCII data.
RWCString getPassword() 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. The RWCString should contain 7-bit US-ASCII data.
RWCString getPath() const;
Returns the path portion of the URL, if applicable. In the example URL ftp://ftp.roguewave.com/pub, it returns pub. 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. The RWCString should contain 7-bit US-ASCII data.
RWCString getPort() 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 do not contain explicit port information return an empty string. The RWCString should contain 7-bit US-ASCII data.
RWCString getSearch() 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 do not contain explicit search information return an empty string. The RWCString should contain 7-bit US-ASCII data.
RWCString getScheme() const;
Returns the scheme portion of the URL. In the example URL http://www.roguewave.com, it returns http. The RWCString should contain 7-bit US-ASCII data.
RWCString getType() 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 do not contain explicit type information return an empty string. The RWCString should contain 7-bit US-ASCII data.
RWCString getUser() 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 do not contain explicit user information return an empty string. The RWCString should contain 7-bit US-ASCII data.
bool isKnown() const;
Returns true for URL schemes specifically recognized by the class.
bool 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. This method also returns false if the URL scheme is not specifically known.
ostream& operator<<(ostream& strm, const RWURL& url);
Outputs an RWURL object to an ostream.
NOTE -- This class does not have an extraction (>>) operator.
© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.