SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches

A convenience class that encapsulates parsing and component management of URL information. More...

#include <rw/internet/RWURL.h>

Public Member Functions

 RWURL (const RWCString &urlString)
 
 RWURL (void)
 
RWCString getData (void) const
 
RWCString getError (void) const
 
RWCString getHost (void) const
 
RWCString getMailAddress (void) const
 
RWCString getNewsArticle (void) const
 
RWCString getNewsGroup (void) const
 
RWCString getPassword (void) const
 
RWCString getPath (void) const
 
RWCString getPort (void) const
 
RWCString getScheme (void) const
 
RWCString getSearch (void) const
 
RWCString getType (void) const
 
RWCString getUser (void) const
 
bool isKnown (void) const
 
bool isValid (void) const
 
bool operator== (const RWURL &url) const
 

Friends

std::ostream & operator<< (std::ostream &str, const RWURL &url)
 

Detailed Description

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.

Example
#include <rw/internet/RWURL.h>
#include <rw/network/RWWinSockInfo.h>
#include <rw/rstream.h>
int main() {
RWURL url("http://www.roguewave.com/tools.txt");
cout << url.getScheme() << endl;
cout << url.getHost() << endl;
cout << url.getPath() << endl;
return 0;
}
A convenience class that encapsulates parsing and component management of URL information.
Definition RWURL.h:87
Initializes the Winsock DLL on Windows platforms.
Definition RWWinSockInfo.h:49

Program Output

http
www.roguewave.com
tools.txt

Constructor & Destructor Documentation

◆ RWURL() [1/2]

RWURL::RWURL ( void )

Constructs a default empty RWURL object. Self needs to be initialized using the assignment operator.

◆ RWURL() [2/2]

RWURL::RWURL ( const RWCString & urlString)

Constructs an RWURL from a const RWCString reference. The URL is expected to be in RFC1738 form.

Member Function Documentation

◆ getData()

RWCString RWURL::getData ( void ) 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.

◆ getError()

RWCString RWURL::getError ( void ) const

Returns a textual explanation of a false response from either the isValid() or the isKnown() method.

◆ getHost()

RWCString RWURL::getHost ( void ) 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.

◆ getMailAddress()

RWCString RWURL::getMailAddress ( void ) 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.

◆ getNewsArticle()

RWCString RWURL::getNewsArticle ( void ) 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.

◆ getNewsGroup()

RWCString RWURL::getNewsGroup ( void ) 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.

◆ getPassword()

RWCString RWURL::getPassword ( void ) 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.

◆ getPath()

RWCString RWURL::getPath ( void ) 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.

◆ getPort()

RWCString RWURL::getPort ( void ) 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.

◆ getScheme()

RWCString RWURL::getScheme ( void ) 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.

◆ getSearch()

RWCString RWURL::getSearch ( void ) 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.

◆ getType()

RWCString RWURL::getType ( void ) 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.

◆ getUser()

RWCString RWURL::getUser ( void ) 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.

◆ isKnown()

bool RWURL::isKnown ( void ) const

Returns true for URL schemes specifically recognized by the class.

◆ isValid()

bool RWURL::isValid ( void ) 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.

◆ operator==()

bool RWURL::operator== ( const RWURL & url) const

Returns true if self and the input url represent the same URL.

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream & str,
const RWURL & url )
friend

Outputs an RWURL object to an std::ostream.

Copyright © 2024 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.