CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
ip_address.h
1
2#pragma once
3
4#include <system/string.h>
5#include <system/shared_ptr.h>
6#include <system/object.h>
7#include <system/array.h>
8#include <cstdint>
9
10#include <net/sockets/address_family.h>
11
12namespace System {
13namespace Details {
14ASPOSECPP_3RD_PARTY_CLASS(ip_address_impl);
15} // namespace Details
16} // namespace System
17
18namespace System {
19namespace Net {
20
25class ASPOSECPP_SHARED_CLASS IPAddress : public System::Object
26{
28 typedef IPAddress ThisType;
31
33 typedef ::System::BaseTypesInfo<BaseType> ThisTypeBaseTypesInfo;
35 ASPOSECPP_SHARED_RTTI_INFO_DECL();
36
37public:
39 static ASPOSECPP_SHARED_API System::SharedPtr<IPAddress> Any;
41 static ASPOSECPP_SHARED_API System::SharedPtr<IPAddress> Loopback;
43 static ASPOSECPP_SHARED_API System::SharedPtr<IPAddress> Broadcast;
45 static ASPOSECPP_SHARED_API System::SharedPtr<IPAddress> None;
47 static ASPOSECPP_SHARED_API System::SharedPtr<IPAddress> IPv6Any;
49 static ASPOSECPP_SHARED_API System::SharedPtr<IPAddress> IPv6Loopback;
51 static ASPOSECPP_SHARED_API System::SharedPtr<IPAddress> IPv6None;
52
58 ASPOSECPP_SHARED_API int64_t get_ScopeId();
61 ASPOSECPP_SHARED_API void set_ScopeId(int64_t value);
64 ASPOSECPP_SHARED_API bool get_IsIPv6Multicast();
67 ASPOSECPP_SHARED_API bool get_IsIPv6LinkLocal();
70 ASPOSECPP_SHARED_API bool get_IsIPv6SiteLocal();
73 ASPOSECPP_SHARED_API bool get_IsIPv6Teredo();
76 ASPOSECPP_SHARED_API bool get_IsIPv4MappedToIPv6();
77
80 ASPOSECPP_SHARED_API IPAddress(int64_t newAddress);
84 ASPOSECPP_SHARED_API IPAddress(System::ArrayPtr<uint8_t> address, int64_t scopeid);
87 ASPOSECPP_SHARED_API IPAddress(System::ArrayPtr<uint8_t> address);
88
93 static ASPOSECPP_SHARED_API bool TryParse(String ipString, System::SharedPtr<IPAddress>& address);
97 static ASPOSECPP_SHARED_API System::SharedPtr<IPAddress> Parse(String ipString);
102 ASPOSECPP_SHARED_API String ToString() const override;
106 static ASPOSECPP_SHARED_API int64_t HostToNetworkOrder(int64_t host);
110 static ASPOSECPP_SHARED_API int32_t HostToNetworkOrder(int32_t host);
114 static ASPOSECPP_SHARED_API int16_t HostToNetworkOrder(int16_t host);
118 static ASPOSECPP_SHARED_API int64_t NetworkToHostOrder(int64_t network);
122 static ASPOSECPP_SHARED_API int32_t NetworkToHostOrder(int32_t network);
126 static ASPOSECPP_SHARED_API int16_t NetworkToHostOrder(int16_t network);
130 static ASPOSECPP_SHARED_API bool IsLoopback(System::SharedPtr<IPAddress> address);
134 ASPOSECPP_SHARED_API bool Equals(System::SharedPtr<Object> comparand) override;
136 ASPOSECPP_SHARED_API int32_t GetHashCode() const override;
143
145 ASPOSECPP_SHARED_API IPAddress();
147 typedef std::shared_ptr<System::Details::ip_address_impl> ImplPtr;
150 ASPOSECPP_SHARED_API ImplPtr GetImpl() const;
153 ASPOSECPP_SHARED_API void SetImpl(ImplPtr impl);
154
155private:
157 ImplPtr ip_address;
158};
159} // namespace Net
160} // namespace System
Represents the IP address. Objects of this class should only be allocated using System::MakeObject() ...
Definition: ip_address.h:26
static int16_t HostToNetworkOrder(int16_t host)
Converts the specified host byte order to the corresponding network byte order.
static System::SharedPtr< IPAddress > Loopback
The IPv4 loopback address.
Definition: ip_address.h:41
int32_t GetHashCode() const override
Analog of C# Object.GetHashCode() method. Enables hashing of custom objects.
System::SharedPtr< IPAddress > MapToIPv6()
Maps the address to the IPv6 address.
int64_t get_ScopeId()
Gets the scope identifier of the IPv6 address.
IPAddress(System::ArrayPtr< uint8_t > address)
Constructs a new instance.
IPAddress(int64_t newAddress)
Constructs a new instance.
bool get_IsIPv6Teredo()
Returns a value that indicates if the address is an IPv6 Teredo address.
static System::SharedPtr< IPAddress > IPv6Any
The IPv6 address that indicates if the server must listen all network interfaces.
Definition: ip_address.h:47
System::ArrayPtr< uint8_t > GetAddressBytes()
Returns a byte array of the IP address.
static int16_t NetworkToHostOrder(int16_t network)
Converts the specified network byte order to the corresponding host byte order.
static bool TryParse(String ipString, System::SharedPtr< IPAddress > &address)
Tries to convert a passed string to an instance of the IPAddress class.
static bool IsLoopback(System::SharedPtr< IPAddress > address)
Returns a value that indicates if the specified address is a loopback address.
static System::SharedPtr< IPAddress > IPv6None
The IPv6 address that indicates if the server mustn't listen any network interface.
Definition: ip_address.h:51
ImplPtr GetImpl() const
Returns a pointer to implementation.
System::Net::Sockets::AddressFamily get_AddressFamily()
Returns the address family.
static System::SharedPtr< IPAddress > None
The IPv4 address that indicates if the server mustn't listen any network interface.
Definition: ip_address.h:45
std::shared_ptr< System::Details::ip_address_impl > ImplPtr
A pointer to the implementation type.
Definition: ip_address.h:147
static System::SharedPtr< IPAddress > Any
The IPv4 address that indicates if the server must listen all network interfaces.
Definition: ip_address.h:39
System::SharedPtr< IPAddress > MapToIPv4()
Maps the address to the IPv4 address.
static System::SharedPtr< IPAddress > IPv6Loopback
The IPv6 loopback address.
Definition: ip_address.h:49
static System::SharedPtr< IPAddress > Parse(String ipString)
Converts a passed string to an instance of the IPAddress class.
static int32_t NetworkToHostOrder(int32_t network)
Converts the specified network byte order to the corresponding host byte order.
void SetImpl(ImplPtr impl)
Sets a pointer to implementation.
bool get_IsIPv6SiteLocal()
Returns a value that indicates if the address is an IPv6 site-local address.
IPAddress()
Constructs a new instance.
IPAddress(System::ArrayPtr< uint8_t > address, int64_t scopeid)
Constructs a new instance.
bool get_IsIPv6LinkLocal()
Returns a value that indicates if the address is an IPv6 link-local address.
bool Equals(System::SharedPtr< Object > comparand) override
Compares objects using C# Object.Equals semantics.
static int32_t HostToNetworkOrder(int32_t host)
Converts the specified host byte order to the corresponding network byte order.
static System::SharedPtr< IPAddress > Broadcast
The IPv4 broadcast address.
Definition: ip_address.h:43
void set_ScopeId(int64_t value)
Sets the scope identifier of the IPv6 address.
bool get_IsIPv4MappedToIPv6()
Returns a value that indicates if the address is an IPv4 address and is mapped to an IPv6 address.
static int64_t HostToNetworkOrder(int64_t host)
Converts the specified host byte order to the corresponding network byte order.
String ToString() const override
Analog of C# Object.ToString() method. Enables converting custom objects to string.
static int64_t NetworkToHostOrder(int64_t network)
Converts the specified network byte order to the corresponding host byte order.
bool get_IsIPv6Multicast()
Returns a value that indicates if the address is an global IPv6 multicast address.
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
AddressFamily
Enumerates the address families.
Definition: address_family.h:12
Definition: db_command.h:9