Network class that represents an IP address.
More...
|
|
using | IPv4 = std::array< UInt8, 4 > |
| |
|
using | IPv6 = std::array< UInt16, 8 > |
| |
|
|
| IpAddress () |
| | Constructs a IpAddress object by default.
|
| |
| | IpAddress (const IPv4 &ip, UInt16 port=0) |
| | Constructs a IpAddress object with an IP and a port. More...
|
| |
| | IpAddress (const IPv6 &ip, UInt16 port=0) |
| | Constructs a IpAddress object with an IP and a port. More...
|
| |
| | IpAddress (const UInt8 &a, const UInt8 &b, const UInt8 &c, const UInt8 &d, UInt16 port=0) |
| | Constructs a IpAddress object with an IP and a port. More...
|
| |
| | IpAddress (const UInt16 &a, const UInt16 &b, const UInt16 &c, const UInt16 &d, const UInt16 &e, const UInt16 &f, const UInt16 &g, const UInt16 &h, UInt16 port=0) |
| | Constructs a IpAddress object with an IP and a port. More...
|
| |
| | IpAddress (const char *address) |
| |
| | IpAddress (const String &address) |
| |
|
| IpAddress (const IpAddress &)=default |
| |
|
| IpAddress (IpAddress &&)=default |
| |
| bool | BuildFromAddress (const char *address) |
| | Builds the IP from a hostname. More...
|
| |
| UInt16 | GetPort () const |
| | Gets the port. More...
|
| |
| NetProtocol | GetProtocol () const |
| | Gets the net protocol. More...
|
| |
| bool | IsLoopback () const |
| | Checks whether the IP address is loopback. More...
|
| |
| bool | IsValid () const |
| | Checks whether the IP address is valid. More...
|
| |
| void | SetPort (UInt16 port) |
| | Sets the port. More...
|
| |
| IPv4 | ToIPv4 () const |
| | Converts IpAddress to IPv4. More...
|
| |
| IPv6 | ToIPv6 () const |
| | Converts IpAddress to IPv6. More...
|
| |
| String | ToString () const |
| | Gives a string representation. More...
|
| |
| UInt32 | ToUInt32 () const |
| | Converts IpAddress to UInt32. More...
|
| |
| | operator bool () const |
| | Converts IpAddress to boolean. More...
|
| |
|
IpAddress & | operator= (const IpAddress &)=default |
| |
|
IpAddress & | operator= (IpAddress &&)=default |
| |
Network class that represents an IP address.
◆ IpAddress() [1/6]
| Nz::IpAddress::IpAddress |
( |
const IPv4 & |
ip, |
|
|
UInt16 |
port = 0 |
|
) |
| |
|
inline |
Constructs a IpAddress object with an IP and a port.
- Parameters
-
| ip | IPv4 address |
| port | Port of the IP |
◆ IpAddress() [2/6]
| Nz::IpAddress::IpAddress |
( |
const IPv6 & |
ip, |
|
|
UInt16 |
port = 0 |
|
) |
| |
|
inline |
Constructs a IpAddress object with an IP and a port.
- Parameters
-
| ip | IPv6 address |
| port | Port of the IP |
◆ IpAddress() [3/6]
| Nz::IpAddress::IpAddress |
( |
const UInt8 & |
a, |
|
|
const UInt8 & |
b, |
|
|
const UInt8 & |
c, |
|
|
const UInt8 & |
d, |
|
|
UInt16 |
port = 0 |
|
) |
| |
|
inline |
Constructs a IpAddress object with an IP and a port.
- Parameters
-
| ip | IPv4 address (a.b.c.d) |
| port | Port of the IP |
◆ IpAddress() [4/6]
| Nz::IpAddress::IpAddress |
( |
const UInt16 & |
a, |
|
|
const UInt16 & |
b, |
|
|
const UInt16 & |
c, |
|
|
const UInt16 & |
d, |
|
|
const UInt16 & |
e, |
|
|
const UInt16 & |
f, |
|
|
const UInt16 & |
g, |
|
|
const UInt16 & |
h, |
|
|
UInt16 |
port = 0 |
|
) |
| |
|
inline |
Constructs a IpAddress object with an IP and a port.
- Parameters
-
| ip | IPv6 address (a.b.c.d.e.f.g.h) |
| port | Port of the IP |
◆ IpAddress() [5/6]
| Nz::IpAddress::IpAddress |
( |
const char * |
address | ) |
|
|
inlineexplicit |
Constructs a IpAddress object with a C-string
- Parameters
-
| address | Hostname or textual IP address |
◆ IpAddress() [6/6]
| Nz::IpAddress::IpAddress |
( |
const String & |
address | ) |
|
|
inlineexplicit |
Constructs a IpAddress object with a string
- Parameters
-
| address | Hostname or textual IP address |
◆ BuildFromAddress()
| bool Nz::IpAddress::BuildFromAddress |
( |
const char * |
address | ) |
|
Builds the IP from a hostname.
- Returns
- true If successful
◆ GetPort()
| UInt16 Nz::IpAddress::GetPort |
( |
| ) |
const |
|
inline |
Gets the port.
- Returns
- Port attached to the IP address
◆ GetProtocol()
| NetProtocol Nz::IpAddress::GetProtocol |
( |
| ) |
const |
|
inline |
Gets the net protocol.
- Returns
- Protocol attached to the IP address
◆ IsLoopback()
| bool Nz::IpAddress::IsLoopback |
( |
| ) |
const |
Checks whether the IP address is loopback.
- Returns
- true If it is the case
◆ IsValid()
| bool Nz::IpAddress::IsValid |
( |
| ) |
const |
|
inline |
Checks whether the IP address is valid.
- Returns
- true If successful
◆ operator bool()
| Nz::IpAddress::operator bool |
( |
| ) |
const |
|
inlineexplicit |
◆ ResolveAddress()
| String Nz::IpAddress::ResolveAddress |
( |
const IpAddress & |
address, |
|
|
String * |
service = nullptr, |
|
|
ResolveError * |
error = nullptr |
|
) |
| |
|
static |
Resolves the address based on the IP.
- Returns
- Hostname of the address
- Parameters
-
| address | IP address to resolve |
| service | Optional argument to specify the protocol used |
| error | Optional argument to get the error |
◆ ResolveHostname()
| std::vector< HostnameInfo > Nz::IpAddress::ResolveHostname |
( |
NetProtocol |
protocol, |
|
|
const String & |
hostname, |
|
|
const String & |
service = "http", |
|
|
ResolveError * |
error = nullptr |
|
) |
| |
|
static |
Resolves the address based on the hostname.
- Returns
- Informations about the host: IP(s) of the address, names, ...
- Parameters
-
| protocol | Net protocol to use |
| hostname | Hostname to resolve |
| service | Specify the service used (http, ...) |
| error | Optional argument to get the error |
◆ SetPort()
| void Nz::IpAddress::SetPort |
( |
UInt16 |
port | ) |
|
|
inline |
Sets the port.
- Parameters
-
| port | Port attached to the IP address |
◆ ToIPv4()
| IpAddress::IPv4 Nz::IpAddress::ToIPv4 |
( |
| ) |
const |
|
inline |
Converts IpAddress to IPv4.
- Returns
- Corresponding IPv4
◆ ToIPv6()
| IpAddress::IPv6 Nz::IpAddress::ToIPv6 |
( |
| ) |
const |
|
inline |
Converts IpAddress to IPv6.
- Returns
- Corresponding IPv6
◆ ToString()
| String Nz::IpAddress::ToString |
( |
| ) |
const |
Gives a string representation.
- Returns
- A string representation of the object
◆ ToUInt32()
| UInt32 Nz::IpAddress::ToUInt32 |
( |
| ) |
const |
|
inline |
Converts IpAddress to UInt32.
- Returns
- Corresponding UInt32
◆ operator!=
Compares the IpAddress to other one.
- Returns
- false if the ip addresses are the same
- Parameters
-
| first | First ip address to compare |
| second | Second ip address to compare with |
◆ operator<
Compares the IpAddress to other one.
- Returns
- true if this ip address is inferior to the other one
- Parameters
-
| first | First ip address to compare |
| second | Second ip address to compare with |
◆ operator<<
| std::ostream& operator<< |
( |
std::ostream & |
out, |
|
|
const IpAddress & |
address |
|
) |
| |
|
friend |
Output operator.
- Returns
- The stream
- Parameters
-
| out | The stream |
| address | The address to output |
◆ operator<=
Compares the IpAddress to other one.
- Returns
- true if this ip address is inferior or equal to the other one
- Parameters
-
| first | First ip address to compare |
| second | Second ip address to compare with |
◆ operator==
Compares the IpAddress to other one.
- Returns
- true if the ip addresses are the same
- Parameters
-
| first | First ip address to compare |
| second | Second ip address to compare with |
◆ operator>
Compares the IpAddress to other one.
- Returns
- true if this ip address is greather to the other one
- Parameters
-
| first | First ip address to compare |
| second | Second ip address to compare with |
◆ operator>=
Compares the IpAddress to other one.
- Returns
- true if this ip address is greather or equal to the other one
- Parameters
-
| first | First ip address to compare |
| second | Second ip address to compare with |
The documentation for this class was generated from the following files:
- include/Nazara/Network/IpAddress.hpp
- include/Nazara/Network/IpAddress.inl
- src/Nazara/Network/IpAddress.cpp