#include <URL.h>
class URL {URL(std::string uri);
URL(const URL& rhs);
URL& operator=(const URL& url);
const bool operator==(const URL& rhs);
const bool operator!=(const URL& rhs);
const std::string getProto();
const std::string getHostName();
int getPort();
const std::string getPath();
const std::string operator std::string();
}
Objects of this class parse Universal Resource Identifiers (URIs). Methods of this class return the components of a URI.
Constructors.
URL(std::string uri);
Constructs a
URL
object by parsing uri
.
The constructor may throw a
CURIFormatException
exception.
see Exceptions below for more information.
URL(const URL& rhs);
Constructs a
URL
object that is an exact duplicate of the
rhs
object.
Other canonical functions.
The
URL
class implements assignment, and comparison for equality and
inequality. Equality holds if all the components of the parsed
URI are identical.
Inequality holds if equality does not hold.
Other methods.
const std::string getProto();
Returns the protocol component of the URI. The protocol component describes the mechanism used to access the resource.
const std::string getHostName();
Returns the hostname component of the URI. The hostname describes where in the network the resource described by the URI is located.
int getPort();
Returns the port number part of the URI. While port numbers are optional on real URI's they are not optional for NSCL URIs. The port determines where the server for the resource is listening for connections.
const std::string getPath();
Returns the path component of the URI. The path component tells the client and server where within the namespaces for the protocol the component is located. The path component is optional. If not provided, it defaults to /.
const std::string operator std::string();
Re-constructs and returns the stringified URL. This should be very close to the string that was used to construct this object, or the object from which the object was copied.
Not all strings are valid URIs. If a URL
object
is constructed with a string that is not a valid URI, the constructor
will throw a
CURIFormatException
.
CURIFormatException
is derived from the
CExeption
common exception base class.
The NSCL Exception class library
chapter describes the exception class hierarchy, how to use it and
its common set of interfaces.
The CException
reference
page describes the CException
class.
The CURIFormatException
reference page describes the
CUIRFormatException
class.