DotNetDupe 4.0.6
C++17/20 Implementation of the .NET Base Class Library (BCL)
Loading...
Searching...
No Matches
DotNetDupe::System::Uri Class Reference

Represents an object representation of a Uniform Resource Identifier (URI) and provides easy access to the parts of the URI. More...

#include <Uri.h>

Inheritance diagram for DotNetDupe::System::Uri:

Public Member Functions

 Uri (const String &uriString)
 Initializes a new instance of the Uri class with the specified URI string.
String GetAbsolutePath () const
 Gets the absolute path of the URI.
String GetAbsoluteUri () const
 Gets the absolute URI string representation.
String GetAuthority () const
 Gets the authority (host, optional port, and optional user information).
String GetFragment () const
 Gets the escaped URI fragment.
String GetHost () const
 Gets the host component of this instance.
String GetOriginalString () const
 Gets the original URI string passed to the constructor.
int GetPort () const
 Gets the port number of this URI.
String GetQuery () const
 Gets any query information included in the specified URI.
String GetScheme () const
 Gets the scheme name for this URI.
String GetUserInfo () const
 Gets the user name, password, or other user-specific information associated with the specified URI.
bool IsDefaultPort () const
 Determines whether the port value of the URI is the default for this scheme.
bool IsFile () const
 Determines whether the specified Uri is a file URI.
bool IsLoopback () const
 Determines whether the specified Uri references the local host.
String ToString () const
 Gets the canonical string representation for the specified Uri instance.
Public Member Functions inherited from DotNetDupe::System::Object
virtual ~Object ()=default
 Virtual destructor ensuring polymorphic cleanup.
virtual bool Equals (const Object &obj) const
 Determines whether the specified Object is equal to the current Object.
virtual int GetHashCode () const
 Serves as the default hash function.
bool operator== (const Object &obj) const
 Determines reference equality between two objects.
char * ToStringA () const
 Returns narrow-character string representation.
wchar_t * ToStringW () const
 Returns wide-character string representation.

Static Public Member Functions

static String EscapeDataString (const String &stringToEscape)
 Converts a string to its escaped representation according to RFC 3986.
static String UnescapeDataString (const String &stringToUnescape)
 Converts a string to its unescaped representation according to RFC 3986.
Static Public Member Functions inherited from DotNetDupe::System::Object
static bool Equals (const Object &obj1, const Object &obj2)
 Static helper determining whether two object instances are equal.

Detailed Description

Represents an object representation of a Uniform Resource Identifier (URI) and provides easy access to the parts of the URI.

Modeled after .NET System.Uri and adhering to the IETF RFC 3986 Uniform Resource Identifier specification. Parses scheme, authority, host, port, path, query, and fragment parts with percent-encoding and unescaping facilities.

Note
Thread Safety: Uri instances are immutable after construction and thread-safe for concurrent inspection.

Definition at line 21 of file Uri.h.

Constructor & Destructor Documentation

◆ Uri()

DotNetDupe::System::Uri::Uri ( const String & uriString)

Initializes a new instance of the Uri class with the specified URI string.

Parameters
uriStringA string representing the URI to parse.

Parse components of URI string upon construction.

Definition at line 9 of file Uri.cpp.

Referenced by DotNetDupe::System::Net::Http::HttpClient::Delete(), DotNetDupe::System::Net::Http::HttpClient::Get(), DotNetDupe::System::Net::Http::HttpClient::GetByteArray(), DotNetDupe::System::Net::Http::HttpClient::GetString(), DotNetDupe::System::UriBuilder::GetUri(), DotNetDupe::System::Net::Http::HttpClient::Post(), and DotNetDupe::System::Net::Http::HttpClient::Put().

Member Function Documentation

◆ EscapeDataString()

String DotNetDupe::System::Uri::EscapeDataString ( const String & stringToEscape)
static

Converts a string to its escaped representation according to RFC 3986.

Parameters
stringToEscapeThe string to escape.
Returns
An escaped string where non-alphanumeric characters are percent-encoded.

Step: Percent-encode non-unreserved ASCII characters per RFC 3986.

Definition at line 135 of file Uri.cpp.

References DotNetDupe::System::String::String().

◆ GetAbsolutePath()

String DotNetDupe::System::Uri::GetAbsolutePath ( ) const

Gets the absolute path of the URI.

Returns
A string containing the path component of the URI.

Definition at line 107 of file Uri.cpp.

◆ GetAbsoluteUri()

String DotNetDupe::System::Uri::GetAbsoluteUri ( ) const

Gets the absolute URI string representation.

Returns
The fully qualified URI string.

Definition at line 103 of file Uri.cpp.

Referenced by DotNetDupe::System::UriParser::GetComponents().

◆ GetAuthority()

String DotNetDupe::System::Uri::GetAuthority ( ) const

Gets the authority (host, optional port, and optional user information).

Returns
The authority string.

Definition at line 104 of file Uri.cpp.

◆ GetFragment()

String DotNetDupe::System::Uri::GetFragment ( ) const

Gets the escaped URI fragment.

Returns
The fragment portion of the URI excluding the leading '#'.

Definition at line 109 of file Uri.cpp.

◆ GetHost()

String DotNetDupe::System::Uri::GetHost ( ) const

Gets the host component of this instance.

Returns
The host name or IP address.

Definition at line 105 of file Uri.cpp.

◆ GetOriginalString()

String DotNetDupe::System::Uri::GetOriginalString ( ) const

Gets the original URI string passed to the constructor.

Returns
The raw unmodified input string.

Definition at line 111 of file Uri.cpp.

◆ GetPort()

int DotNetDupe::System::Uri::GetPort ( ) const

Gets the port number of this URI.

Returns
An integer containing the port number assigned to this URI.

Definition at line 106 of file Uri.cpp.

◆ GetQuery()

String DotNetDupe::System::Uri::GetQuery ( ) const

Gets any query information included in the specified URI.

Returns
The query string excluding the leading question mark.

Definition at line 108 of file Uri.cpp.

◆ GetScheme()

String DotNetDupe::System::Uri::GetScheme ( ) const

Gets the scheme name for this URI.

Returns
The protocol scheme (e.g., "http", "https", "file").

Definition at line 102 of file Uri.cpp.

Referenced by DotNetDupe::System::Net::Http::HttpClient::Send().

◆ GetUserInfo()

String DotNetDupe::System::Uri::GetUserInfo ( ) const

Gets the user name, password, or other user-specific information associated with the specified URI.

Returns
The user information string.

Definition at line 110 of file Uri.cpp.

◆ IsDefaultPort()

bool DotNetDupe::System::Uri::IsDefaultPort ( ) const

Determines whether the port value of the URI is the default for this scheme.

Returns
True if the port is default for the scheme (e.g. 80 for HTTP, 443 for HTTPS); otherwise false.

Step: Check if configured port matches standard scheme default.

Definition at line 118 of file Uri.cpp.

◆ IsFile()

bool DotNetDupe::System::Uri::IsFile ( ) const

Determines whether the specified Uri is a file URI.

Returns
True if scheme is "file"; otherwise false.

Step: Check if scheme matches file protocol.

Definition at line 125 of file Uri.cpp.

References DotNetDupe::System::String::Equals().

◆ IsLoopback()

bool DotNetDupe::System::Uri::IsLoopback ( ) const

Determines whether the specified Uri references the local host.

Returns
True if host is loopback ("localhost", "127.0.0.1", "::1"); otherwise false.

Step: Check if host corresponds to loopback address or localhost.

Definition at line 130 of file Uri.cpp.

◆ ToString()

String DotNetDupe::System::Uri::ToString ( ) const

Gets the canonical string representation for the specified Uri instance.

Returns
The canonical URI string.

Return original URI string.

Definition at line 113 of file Uri.cpp.

Referenced by DotNetDupe::System::UriBuilder::UriBuilder().

◆ UnescapeDataString()

String DotNetDupe::System::Uri::UnescapeDataString ( const String & stringToUnescape)
static

Converts a string to its unescaped representation according to RFC 3986.

Parameters
stringToUnescapeThe percent-encoded string to decode.
Returns
The decoded string with hexadecimal percent sequences restored to characters.

Step: Iterate through string and unescape percent-encoded hex sequences.

Definition at line 166 of file Uri.cpp.

References DotNetDupe::System::String::String(), and DotNetDupe::System::UnescapePercentChar().


The documentation for this class was generated from the following files: