Uri

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 UriHostNameType CheckHostName(String)Determines the type of the specified host name.
static bool CheckSchemeName(const String&)Determines if the specified scheme is valid.
static int32_t Compare(const SharedPtr<Uri>&, const SharedPtr<Uri>&, UriComponents, UriFormat, StringComparison)Compares the specified Uri objects using the specified comparison rules.
bool Equals(SharedPtr<Object>) overrideDetermines if the URIs represented by the current and specified objects are equal.
virtual bool Equals(ptr)Compares objects using C# Object.Equals semantics.
static std::enable_if<IsSmartPtr<T1>::value&&IsSmartPtr<T2>::value, bool>::type Equals(T1 const&, T2 const&)Compares reference type objects in C# style.
static bool Equals(float const&, float const&)Emulates C#-style floating point comparison where two NaNs are considered equal even though according to IEC 60559:1989 NaN is not equal to any value, including NaN.
static bool Equals(double const&, double const&)Emulates C#-style floating point comparison where two NaNs are considered equal even though according to IEC 60559:1989 NaN is not equal to any value, including NaN.
static String EscapeDataString(const String&)Converts a string to its escaped representation.
static String EscapeUriString(const String&)Converts a URI string to its escaped representation.
virtual bool FastCast(const Details::FastRttiBase&, void **) constFor internal purposes only.
static int32_t FromHex(char16_t)Gets the decimal value of a hexadecimal digit.
String get_AbsolutePath() constReturns the absolute path of the URI.
String get_AbsoluteUri() constReturns the absolute URI.
String get_Authority() constReturns the host name and the port number for a server.
String get_DnsSafeHost() constReturns an unescaped host name.
String get_Fragment() constReturns the escaped URI fragment.
String get_Host() constReturns the host name.
UriHostNameType get_HostNameType() constReturns the host name type.
String get_IdnHost() constReturns an International Domain Name of the host.
bool get_IsAbsoluteUri() constDetermines if the URI represented by the current object is absolute.
bool get_IsDefaultPort() constDetermines if the URI represented by the current object has default port for the URI’s scheme.
bool get_IsFile() constDetermines if the URI represented by the current object is a file.
bool get_IsLoopback() constDetermines if the URI represented by the current object references a local host.
bool get_IsUnc() constDetermines if the URI represented by the current object is a UNC path.
String get_LocalPath() constReturns the operating system representation of the file name referenced by the URI represented by the current object.
String get_OriginalString() constReturns the URI string that was passed to the constructor when current object was constructed.
String get_PathAndQuery() constReturns the absolute path and query components of the URI represented by the current object separated by a question mark (?).
int32_t get_Port() constReturns the port number of the URI represented by the current object.
String get_Query() constReturns the query information included in the URI represented by the current object.
String get_Scheme() constReturns the scheme of the URI represented by the current object.
ArrayPtr<String> get_Segments() constReturns an array of strings containing the path segments of the URI represented by the current object.
bool get_UserEscaped() constDetermines if the URI string passed to the constructor of the current object was fully escaped.
String get_UserInfo() constReturns a uer name, password and other user information associated with the URI represented by the current object.
String GetComponents(UriComponents, UriFormat) constReturns the specified components of the URI represented by the current object using the specified escaping.
Detail::SmartPtrCounter * GetCounter()Gets reference counter data structure associated with the object.
int32_t GetHashCode() const overrideGets the hash code for the URI.
String GetLeftPart(UriPartial)Returns the specified portion of the URI represented by the current object.
virtual const TypeInfo& GetType() constGets actual type of object. Analog of C# System.Object.GetType() call.
static String HexEscape(char16_t)Returns a hexadecimal equivalent of the specified character.
static char16_t HexUnescape(const String&, int32_t&)Converts the specified hexadecimal representation of a character to a character.
virtual bool Is(const TypeInfo&) constCheck if object represents an instance of type described by targetType. Analog of C# ‘is’ operator.
bool 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 bool IsHexDigit(char16_t)Determines if the specified character represents a valid hexadecimal digit.
static bool IsHexEncoding(const String&, int32_t)Determines if a character in the specified string at the specified position is hexadecimal encoded.
bool IsWellFormedOriginalString() constIndicates whether the string used to construct this Uri was well-formed and is not required to be further escaped.
static bool IsWellFormedUriString(const String&, UriKind)Determines if the specified string is a well-formed URI.
void Lock()Implements C# lock() statement locking. Call directly or use LockContext sentry object.
String MakeRelative(const SharedPtr<Uri>&)Determines the difference between two Uri instances.
SharedPtr<Uri> MakeRelativeUri(const SharedPtr<Uri>&)Determines the difference between URIs represented by the current and the specified Uri objects.
virtual ptr MemberwiseClone() constAnalog of C# Object.MemberwiseClone() method. Enables cloning custom types.
Object()Creates object. Initializes all internal data structures.
Object(Object const&)Copy constructor. Doesn’t copy anything, really, just initializes new object and enables copy constructing subclasses.
Object& operator=(Object const&)Assignment operator. Doesn’t copy anything, really, just initializes new object and enables copy constructing subclasses.
static bool ReferenceEquals(ptr const&, ptr const&)Compares objects by reference.
static std::enable_if<!IsSmartPtr<T>::value, bool>::type ReferenceEquals(T const&, T const&)Compares objects by reference.
static std::enable_if<!IsSmartPtr<T>::value, bool>::type ReferenceEquals(T const&, std::nullptr_t)Reference-compares value type object with nullptr.
bool ReferenceEquals(String const&, std::nullptr_t)Specialization of Object::ReferenceEquals for case of string and nullptr.
bool ReferenceEquals(String const&, String const&)Specialization of Object::ReferenceEquals for case of strings.
int RemovedSharedRefs(int)Decreases shared reference count by specified value.
virtual void SetTemplateWeakPtr(uint32_t)Set n’th template argument a weak pointer (rather than shared). Allows switching pointers in containers to weak mode.
int SharedCount() constGets current value of shared reference counter.
Object * SharedRefAdded()Increments shared reference count. Shouldn’t be called directly; instead, use smart pointers or ThisProtector.
int SharedRefRemovedSafe()Decrements and returns shared reference count. Shouldn’t be called directly; instead, use smart pointers or ThisProtector.
String ToString() const overrideReturns the string representation of the URI represented by the current object.
static bool TryCreate(const String&, UriKind, SharedPtr<Uri>&)Constructs a Uri object that represents the specified URI; an argument specifies the URI kind.
static bool 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 bool TryCreate(const SharedPtr<Uri>&, const SharedPtr<Uri>&, SharedPtr<Uri>&)Constructs an Uri abject from the specified base and relative URIs.
static const TypeInfo& Type()Implements C# typeof(System.Object) construct.
static String UnescapeDataString(const String&)Unescapes the specified escaped string.
void Unlock()Implements C# lock() statement unlocking. Call directly or use LockContext sentry object.
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.
Detail::SmartPtrCounter * WeakRefAdded()Increments weak reference count. Shouldn’t be called directly; instead, use smart pointers or ThisProtector.
void WeakRefRemoved()Decrements weak reference count. Shouldn’t be called directly; instead, use smart pointers or ThisProtector.
virtual ~Object()Destroys object. Frees all internal data structures.

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