System::Uri class

Uri class

Unified resource identifier. Objects of this class should only be allocated using System::MakeObject() function. Never create instance of this type on stack or using operator new, as it will result in runtime errors and/or assertion faults. Always wrap this class into System::SmartPtr pointer and use this pointer to pass it to functions as argument.

class Uri : public System::Object

Methods

MethodDescription
static CheckHostName(String)Determines the type of the specified host name.
static CheckSchemeName(const String&)Determines if the specified scheme is valid.
static Compare(const SharedPtr<Uri>&, const SharedPtr<Uri>&, UriComponents, UriFormat, StringComparison)Compares the specified Uri objects using the specified comparison rules.
Equals(SharedPtr<Object>) overrideDetermines if the URIs represented by the current and specified objects are equal.
static EscapeDataString(const String&)Converts a string to its escaped representation.
static EscapeUriString(const String&)Converts a URI string to its escaped representation.
static FromHex(char16_t)Gets the decimal value of a hexadecimal digit.
get_AbsolutePath() constReturns the absolute path of the URI.
get_AbsoluteUri() constReturns the absolute URI.
get_Authority() constReturns the host name and the port number for a server.
get_DnsSafeHost() constReturns an unescaped host name.
get_Fragment() constReturns the escaped URI fragment.
get_Host() constReturns the host name.
get_HostNameType() constReturns the host name type.
get_IdnHost() constReturns an International Domain Name of the host.
get_IsAbsoluteUri() constDetermines if the URI represented by the current object is absolute.
get_IsDefaultPort() constDetermines if the URI represented by the current object has default port for the URI’s scheme.
get_IsFile() constDetermines if the URI represented by the current object is a file.
get_IsLoopback() constDetermines if the URI represented by the current object references a local host.
get_IsUnc() constDetermines if the URI represented by the current object is a UNC path.
get_LocalPath() constReturns the operating system representation of the file name referenced by the URI represented by the current object.
get_OriginalString() constReturns the URI string that was passed to the constructor when current object was constructed.
get_PathAndQuery() constReturns the absolute path and query components of the URI represented by the current object separated by a question mark (?).
get_Port() constReturns the port number of the URI represented by the current object.
get_Query() constReturns the query information included in the URI represented by the current object.
get_Scheme() constReturns the scheme of the URI represented by the current object.
get_Segments() constReturns an array of strings containing the path segments of the URI represented by the current object.
get_UserEscaped() constDetermines if the URI string passed to the constructor of the current object was fully escaped.
get_UserInfo() constReturns a uer name, password and other user information associated with the URI represented by the current object.
GetComponents(UriComponents, UriFormat) constReturns the specified components of the URI represented by the current object using the specified escaping.
GetHashCode() const overrideGets the hash code for the URI.
GetLeftPart(UriPartial)Returns the specified portion of the URI represented by the current object.
static HexEscape(char16_t)Returns a hexadecimal equivalent of the specified character.
static HexUnescape(const String&, int32_t&)Converts the specified hexadecimal representation of a character to a character.
IsBaseOf(const SharedPtr<Uri>&) constDetermines of the URI represented by the current Uri object is a base of URI represented by the specified Uri object.
static IsHexDigit(char16_t)Determines if the specified character represents a valid hexadecimal digit.
static IsHexEncoding(const String&, int32_t)Determines if a character in the specified string at the specified position is hexadecimal encoded.
IsWellFormedOriginalString() constIndicates whether the string used to construct this Uri was well-formed and is not required to be further escaped.
static IsWellFormedUriString(const String&, UriKind)Determines if the specified string is a well-formed URI.
MakeRelative(const SharedPtr<Uri>&)Determines the difference between two Uri instances.
MakeRelativeUri(const SharedPtr<Uri>&)Determines the difference between URIs represented by the current and the specified Uri objects.
ToString() const overrideReturns the string representation of the URI represented by the current object.
static TryCreate(const String&, UriKind, SharedPtr<Uri>&)Constructs a Uri object that represents the specified URI; an argument specifies the URI kind.
static TryCreate(const SharedPtr<Uri>&, const String&, SharedPtr<Uri>&)Constructs an Uri abject from the specified Uri object representing the base URI and the string representation of relative URI.
static TryCreate(const SharedPtr<Uri>&, const SharedPtr<Uri>&, SharedPtr<Uri>&)Constructs an Uri abject from the specified base and relative URIs.
static UnescapeDataString(const String&)Unescapes the specified escaped string.
Uri(const String&)Constructs a Uri object that represents the specified URI.
Uri(const String&, bool)Constructs a Uri object that represents the specified URI; an argument specifies if the URI should be escaped.
Uri(const SharedPtr<Uri>&, const String&, bool)Constructs an Uri abject from the specified Uri object representing the base URI and the string representation of relative URI; an argument specifies if the URI should be escaped.
Uri(const String&, UriKind)Constructs a Uri object that represents the specified URI; an argument specifies the URI kind.
Uri(const SharedPtr<Uri>&, const String&)Constructs an Uri abject from the specified base and relative URIs.
Uri(const SharedPtr<Uri>&, const SharedPtr<Uri>&)Constructs an Uri abject from the specified base and relative URIs.

Fields

FieldDescription
static SchemeDelimiterSpecifies the characters that separate the communication protocol scheme from the address portion of the Uri.
static UriSchemeFileSpecifies that the Uri is a pointer to a file.
static UriSchemeFtpSpecifies that the Uri is accessed through the File Transfer Protocol.
static UriSchemeGopherSpecifies that the Uri is accessed through the Gopher protocol.
static UriSchemeHttpSpecifies that the Uri is accessed through the Hypertext Transfer Protocol.
static UriSchemeHttpsSpecifies that the Uri is accessed through the Secure Hypertext Transfer Protocol.
static UriSchemeMailtoSpecifies that the Uri is an email address and is accessed through the Simple Mail Transport Protocol.
static UriSchemeNetPipeSpecifies that the Uri is accessed through the NetPipe scheme used by Windows Communication Foundation.
static UriSchemeNetTcpSpecifies that the Uri is accessed through the NetTcp scheme used by Windows Communication Foundation.
static UriSchemeNewsSpecifies that the Uri is an Internet news group and is accessed through the Network News Transport Protocol.
static UriSchemeNntpSpecifies that the Uri is an Internet news group and is accessed through the Network News Transport Protocol.

Remarks

#include "system/smart_ptr.h"
#include "system/uri.h"
#include <iostream>

int main()
{
  const auto uri = System::MakeObject<System::Uri>(u"https://docs.codeporting.com/translator/cs2cpp/release-notes/2021/codeporting-translator-cs2cpp-21-9/");

std::cout <<
  "AbsolutePath: " << uri->get_AbsolutePath() << std::endl <<
  "AbsoluteUri: " << uri->get_AbsoluteUri() << std::endl <<
  "Authority: " << uri->get_Authority() << std::endl <<
  "DnsSafeHost: " << uri->get_DnsSafeHost() << std::endl <<
  "Fragment: " << uri->get_Fragment() << std::endl <<
  "Host: " << uri->get_Host() << std::endl <<
  "IdnHost: " << uri->get_IdnHost() << std::endl <<
  "LocalPath: " << uri->get_LocalPath() << std::endl <<
  "OriginalString: " << uri->get_OriginalString() << std::endl <<
  "PathAndQuery: " << uri->get_PathAndQuery() << std::endl <<
  "Port: " << uri->get_Port() << std::endl <<
  "Query: " << uri->get_Query() << std::endl <<
  "Scheme: " << uri->get_Scheme() << std::endl;

  return 0;
}
/*
This code example produces the following output:
AbsolutePath: /translator/cs2cpp/release-notes/2021/codeporting-translator-cs2cpp-21-9/
AbsoluteUri: https://docs.codeporting.com/translator/cs2cpp/release-notes/2021/codeporting-translator-cs2cpp-21-9/
Authority: docs.codeporting.com
DnsSafeHost: docs.codeporting.com
Fragment:
Host: docs.codeporting.com
IdnHost: docs.codeporting.com
LocalPath: /translator/cs2cpp/release-notes/2021/codeporting-translator-cs2cpp-21-9/
OriginalString: https://docs.codeporting.com/translator/cs2cpp/release-notes/2021/codeporting-translator-cs2cpp-21-9/
PathAndQuery: /translator/cs2cpp/release-notes/2021/codeporting-translator-cs2cpp-21-9/
Port: 443
Query:
Scheme: https
*/

See Also