CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
uri.h
1
3#pragma once
4
5#include <system/uri_enum_types.h>
6#include <system/uri_host_name_type.h>
7#include <system/uri_partial.h>
8#include <system/string_comparison.h>
9#include <system/string.h>
10#include <system/shared_ptr.h>
11#include <system/object.h>
12#include <cstdint>
13
14namespace System {
15
16namespace UriDetails { class UriImpl; }
17
65class ASPOSECPP_SHARED_CLASS Uri : public Object
66{
67 typedef Uri ThisType;
68 typedef Object BaseType;
69
70 typedef BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
71 ASPOSECPP_SHARED_RTTI_INFO_DECL();
72
73 friend ASPOSECPP_SHARED_API bool operator ==(const SharedPtr<Uri>& uri1, const SharedPtr<Uri>& uri2);
74 friend ASPOSECPP_SHARED_API bool operator !=(const SharedPtr<Uri>& uri1, const SharedPtr<Uri>& uri2);
75
76public:
78 static const ASPOSECPP_SHARED_API String UriSchemeFile;
80 static const ASPOSECPP_SHARED_API String UriSchemeFtp;
82 static const ASPOSECPP_SHARED_API String UriSchemeGopher;
84 static const ASPOSECPP_SHARED_API String UriSchemeHttp;
86 static const ASPOSECPP_SHARED_API String UriSchemeHttps;
88 static const ASPOSECPP_SHARED_API String UriSchemeMailto;
90 static const ASPOSECPP_SHARED_API String UriSchemeNews;
92 static const ASPOSECPP_SHARED_API String UriSchemeNntp;
94 static const ASPOSECPP_SHARED_API String UriSchemeNetTcp;
96 static const ASPOSECPP_SHARED_API String UriSchemeNetPipe;
98 static const ASPOSECPP_SHARED_API String SchemeDelimiter;
99
101 ASPOSECPP_SHARED_API String get_AbsolutePath() const;
103 ASPOSECPP_SHARED_API String get_AbsoluteUri() const;
105 ASPOSECPP_SHARED_API String get_LocalPath() const;
107 ASPOSECPP_SHARED_API String get_Authority() const;
109 ASPOSECPP_SHARED_API UriHostNameType get_HostNameType() const;
111 ASPOSECPP_SHARED_API bool get_IsDefaultPort() const;
113 ASPOSECPP_SHARED_API bool get_IsFile() const;
115 ASPOSECPP_SHARED_API bool get_IsLoopback() const;
117 ASPOSECPP_SHARED_API String get_PathAndQuery() const;
119 ASPOSECPP_SHARED_API ArrayPtr<String> get_Segments() const;
121 ASPOSECPP_SHARED_API bool get_IsUnc() const;
123 ASPOSECPP_SHARED_API String get_Host() const;
125 ASPOSECPP_SHARED_API int32_t get_Port() const;
127 ASPOSECPP_SHARED_API String get_Query() const;
129 ASPOSECPP_SHARED_API String get_Fragment() const;
131 ASPOSECPP_SHARED_API String get_Scheme() const;
133 ASPOSECPP_SHARED_API String get_OriginalString() const;
135 ASPOSECPP_SHARED_API String get_DnsSafeHost() const;
137 ASPOSECPP_SHARED_API String get_IdnHost() const;
139 ASPOSECPP_SHARED_API bool get_IsAbsoluteUri() const;
141 ASPOSECPP_SHARED_API bool get_UserEscaped() const;
143 ASPOSECPP_SHARED_API String get_UserInfo() const;
144
147 ASPOSECPP_SHARED_API Uri(const String& uriString);
151 ASPOSECPP_SHARED_API Uri(const String& uriString, bool dontEscape);
157 ASPOSECPP_SHARED_API Uri(const SharedPtr<Uri>& baseUri, const String& relativeUri, bool dontEscape);
161 ASPOSECPP_SHARED_API Uri(const String& uriString, UriKind uriKind);
165 ASPOSECPP_SHARED_API Uri(const SharedPtr<Uri>& baseUri, const String& relativeUri);
169 ASPOSECPP_SHARED_API Uri(const SharedPtr<Uri>& baseUri, const SharedPtr<Uri>& relativeUri);
170
174 static ASPOSECPP_SHARED_API UriHostNameType CheckHostName(String name);
178 ASPOSECPP_SHARED_API String GetLeftPart(UriPartial part);
182 static ASPOSECPP_SHARED_API String HexEscape(char16_t character);
189 static ASPOSECPP_SHARED_API char16_t HexUnescape(const String& pattern, int32_t& index);
194 static ASPOSECPP_SHARED_API bool IsHexEncoding(const String& pattern, int32_t index);
198 static ASPOSECPP_SHARED_API bool CheckSchemeName(const String& schemeName);
202 static ASPOSECPP_SHARED_API bool IsHexDigit(char16_t character);
206 static ASPOSECPP_SHARED_API int32_t FromHex(char16_t digit);
209 virtual ASPOSECPP_SHARED_API int32_t GetHashCode() const override;
211 virtual ASPOSECPP_SHARED_API String ToString() const override;
215 virtual ASPOSECPP_SHARED_API bool Equals(SharedPtr<Object> comparand) override;
220 ASPOSECPP_SHARED_API SharedPtr<Uri> MakeRelativeUri(const SharedPtr<Uri>& uri);
225 ASPOSECPP_SHARED_API String MakeRelative(const SharedPtr<Uri>& toUri);
231 static ASPOSECPP_SHARED_API bool TryCreate(const String& uriString, UriKind uriKind, SharedPtr<Uri>& result);
238 static ASPOSECPP_SHARED_API bool TryCreate(const SharedPtr<Uri>& baseUri, const String& relativeUri, SharedPtr<Uri>& result);
244 static ASPOSECPP_SHARED_API bool TryCreate(const SharedPtr<Uri>& baseUri, const SharedPtr<Uri>& relativeUri, SharedPtr<Uri>& result);
249 ASPOSECPP_SHARED_API String GetComponents(UriComponents components, UriFormat format) const;
257 static ASPOSECPP_SHARED_API int32_t Compare(const SharedPtr<Uri>& uri1, const SharedPtr<Uri>& uri2,
258 UriComponents partsToCompare,
259 UriFormat compareFormat, StringComparison comparisonType);
261 ASPOSECPP_SHARED_API bool IsWellFormedOriginalString() const;
266 static ASPOSECPP_SHARED_API bool IsWellFormedUriString(const String& uriString, UriKind uriKind);
270 static ASPOSECPP_SHARED_API String UnescapeDataString(const String& stringToUnescape);
274 static ASPOSECPP_SHARED_API String EscapeUriString(const String& stringToEscape);
278 static ASPOSECPP_SHARED_API String EscapeDataString(const String& stringToEscape);
282 ASPOSECPP_SHARED_API bool IsBaseOf(const SharedPtr<Uri>& uri) const;
283
284protected:
286 virtual ASPOSECPP_SHARED_API void Parse();
288 virtual ASPOSECPP_SHARED_API void Canonicalize();
290 virtual ASPOSECPP_SHARED_API void Escape();
292 virtual ASPOSECPP_SHARED_API String Unescape(const String& path);
294 static ASPOSECPP_SHARED_API String EscapeString(const String& str);
296 virtual ASPOSECPP_SHARED_API void CheckSecurity();
298 virtual ASPOSECPP_SHARED_API bool IsReservedCharacter(char16_t character);
300 static ASPOSECPP_SHARED_API bool IsExcludedCharacter(char16_t character);
302 virtual ASPOSECPP_SHARED_API bool IsBadFileSystemCharacter(char16_t character);
303#ifdef ASPOSE_GET_SHARED_MEMBERS
305 ASPOSECPP_SHARED_API void GetSharedMembers(System::Object::shared_members_type& result) const override;
306#endif
307
308private:
309 explicit Uri(const SharedPtr<UriDetails::UriImpl>& impl);
310 MEMBER_FUNCTION_MAKE_OBJECT(Uri, CODEPORTING_ARGS(const SharedPtr<UriDetails::UriImpl>& impl), CODEPORTING_ARGS(impl));
311
312 static SharedPtr<UriDetails::UriImpl> GetImpl(const SharedPtr<Uri>& uri);
314};
315
320ASPOSECPP_SHARED_API bool operator ==(const SharedPtr<Uri>& uri1, const SharedPtr<Uri>& uri2);
325ASPOSECPP_SHARED_API bool operator !=(const SharedPtr<Uri>& uri1, const SharedPtr<Uri>& uri2);
326
327} // namespace System
Base class that enables using methods available for System.Object class in C#. All non-trivial classe...
Definition: object.h:62
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
String class used across the library. Is a substitute for C# System.String when translating code....
Definition: string.h:122
Unified resource identifier. Objects of this class should only be allocated using System::MakeObject(...
Definition: uri.h:66
virtual String Unescape(const String &path)
Obsolete method.
String get_OriginalString() const
Returns the URI string that was passed to the constructor when current object was constructed.
ArrayPtr< String > get_Segments() const
Returns an array of strings containing the path segments of the URI represented by the current object...
virtual void Canonicalize()
Obsolete method.
String GetLeftPart(UriPartial part)
Returns the specified portion of the URI represented by the current object.
static const String UriSchemeNetTcp
Specifies that the Uri is accessed through the NetTcp scheme used by Windows Communication Foundation...
Definition: uri.h:94
static String EscapeDataString(const String &stringToEscape)
Converts a string to its escaped representation.
Uri(const String &uriString, UriKind uriKind)
Constructs a Uri object that represents the specified URI; an argument specifies the URI kind.
static const String SchemeDelimiter
Specifies the characters that separate the communication protocol scheme from the address portion of ...
Definition: uri.h:98
Uri(const SharedPtr< Uri > &baseUri, const SharedPtr< Uri > &relativeUri)
Constructs an Uri abject from the specified base and relative URIs.
String get_LocalPath() const
Returns the operating system representation of the file name referenced by the URI represented by the...
static bool IsExcludedCharacter(char16_t character)
Obsolete method.
String get_Query() const
Returns the query information included in the URI represented by the current object.
static const String UriSchemeGopher
Specifies that the Uri is accessed through the Gopher protocol.
Definition: uri.h:82
static const String UriSchemeMailto
Specifies that the Uri is an email address and is accessed through the Simple Mail Transport Protocol...
Definition: uri.h:88
virtual void Escape()
Obsolete method.
Uri(const SharedPtr< Uri > &baseUri, const String &relativeUri, bool dontEscape)
Constructs an Uri abject from the specified Uri object representing the base URI and the string repre...
bool get_IsDefaultPort() const
Determines if the URI represented by the current object has default port for the URI's scheme.
static const String UriSchemeHttps
Specifies that the Uri is accessed through the Secure Hypertext Transfer Protocol.
Definition: uri.h:86
static char16_t HexUnescape(const String &pattern, int32_t &index)
Converts the specified hexadecimal representation of a character to a character.
virtual bool IsBadFileSystemCharacter(char16_t character)
Obsolete method.
static const String UriSchemeNetPipe
Specifies that the Uri is accessed through the NetPipe scheme used by Windows Communication Foundatio...
Definition: uri.h:96
String get_AbsolutePath() const
Returns the absolute path of the URI.
Uri(const String &uriString)
Constructs a Uri object that represents the specified URI.
bool get_IsUnc() const
Determines if the URI represented by the current object is a UNC path.
bool IsWellFormedOriginalString() const
Indicates whether the string used to construct this Uri was well-formed and is not required to be fur...
virtual String ToString() const override
Returns the string representation of the URI represented by the current object.
String get_Scheme() const
Returns the scheme of the URI represented by the current object.
String get_Host() const
Returns the host name.
bool get_UserEscaped() const
Determines if the URI string passed to the constructor of the current object was fully escaped.
virtual int32_t GetHashCode() const override
Gets the hash code for the URI.
Uri(const SharedPtr< Uri > &baseUri, const String &relativeUri)
Constructs an Uri abject from the specified base and relative URIs.
static String EscapeUriString(const String &stringToEscape)
Converts a URI string to its escaped representation.
UriHostNameType get_HostNameType() const
Returns the host name type.
static const String UriSchemeFile
Specifies that the Uri is a pointer to a file.
Definition: uri.h:78
static bool TryCreate(const SharedPtr< Uri > &baseUri, const SharedPtr< Uri > &relativeUri, SharedPtr< Uri > &result)
Constructs an Uri abject from the specified base and relative URIs.
static int32_t Compare(const SharedPtr< Uri > &uri1, const SharedPtr< Uri > &uri2, UriComponents partsToCompare, UriFormat compareFormat, StringComparison comparisonType)
Compares the specified Uri objects using the specified comparison rules.
static String HexEscape(char16_t character)
Returns a hexadecimal equivalent of the specified character.
bool get_IsLoopback() const
Determines if the URI represented by the current object references a local host.
bool get_IsFile() const
Determines if the URI represented by the current object is a file.
static bool CheckSchemeName(const String &schemeName)
Determines if the specified scheme is valid.
SharedPtr< Uri > MakeRelativeUri(const SharedPtr< Uri > &uri)
Determines the difference between URIs represented by the current and the specified Uri objects.
String get_PathAndQuery() const
Returns the absolute path and query components of the URI represented by the current object separated...
virtual void CheckSecurity()
Obsolete method.
String get_Authority() const
Returns the host name and the port number for a server.
Uri(const String &uriString, bool dontEscape)
Constructs a Uri object that represents the specified URI; an argument specifies if the URI should be...
String get_DnsSafeHost() const
Returns an unescaped host name.
static const String UriSchemeFtp
Specifies that the Uri is accessed through the File Transfer Protocol.
Definition: uri.h:80
virtual void Parse()
Obsolete method.
static const String UriSchemeHttp
Specifies that the Uri is accessed through the Hypertext Transfer Protocol.
Definition: uri.h:84
static bool IsHexEncoding(const String &pattern, int32_t index)
Determines if a character in the specified string at the specified position is hexadecimal encoded.
String get_AbsoluteUri() const
Returns the absolute URI.
virtual bool Equals(SharedPtr< Object > comparand) override
Determines if the URIs represented by the current and specified objects are equal.
static int32_t FromHex(char16_t digit)
Gets the decimal value of a hexadecimal digit.
static UriHostNameType CheckHostName(String name)
Determines the type of the specified host name.
String get_UserInfo() const
Returns a uer name, password and other user information associated with the URI represented by the cu...
static const String UriSchemeNews
Specifies that the Uri is an Internet news group and is accessed through the Network News Transport P...
Definition: uri.h:90
bool IsBaseOf(const SharedPtr< Uri > &uri) const
Determines of the URI represented by the current Uri object is a base of URI represented by the speci...
static String UnescapeDataString(const String &stringToUnescape)
Unescapes the specified escaped string.
int32_t get_Port() const
Returns the port number of the URI represented by the current object.
String get_Fragment() const
Returns the escaped URI fragment.
static bool IsHexDigit(char16_t character)
Determines if the specified character represents a valid hexadecimal digit.
String get_IdnHost() const
Returns an International Domain Name of the host.
bool get_IsAbsoluteUri() const
Determines if the URI represented by the current object is absolute.
static bool IsWellFormedUriString(const String &uriString, UriKind uriKind)
Determines if the specified string is a well-formed URI.
String GetComponents(UriComponents components, UriFormat format) const
Returns the specified components of the URI represented by the current object using the specified esc...
static bool TryCreate(const String &uriString, UriKind uriKind, SharedPtr< Uri > &result)
Constructs a Uri object that represents the specified URI; an argument specifies the URI kind.
virtual bool IsReservedCharacter(char16_t character)
Obsolete method.
static const String UriSchemeNntp
Specifies that the Uri is an Internet news group and is accessed through the Network News Transport P...
Definition: uri.h:92
String MakeRelative(const SharedPtr< Uri > &toUri)
Determines the difference between two Uri instances.
static bool TryCreate(const SharedPtr< Uri > &baseUri, const String &relativeUri, SharedPtr< Uri > &result)
Constructs an Uri abject from the specified Uri object representing the base URI and the string repre...
static String EscapeString(const String &str)
Obsolete method.
Definition: db_command.h:9
bool operator!=(ArraySegment< T > a, ArraySegment< T > b)
Definition: array_segment.h:157
UriKind
Represents the kinds of URIs.
Definition: uri_enum_types.h:13
StringComparison
Defines string comparison style.
Definition: string_comparison.h:13
UriHostNameType
Represents the type of host name.
Definition: uri_host_name_type.h:11
UriPartial
Represents the parts of a URI for the Uri.GetLeftPart method.
Definition: uri_partial.h:11
UriFormat
Specifies how the URI is escaped.
Definition: uri_enum_types.h:67
UriComponents
Represents URI components.
Definition: uri_enum_types.h:24
bool operator==(ArraySegment< T > a, ArraySegment< T > b)
Definition: array_segment.h:151