MT Core (C++)
Core library for replacing C++ standard in project usage
Loading...
Searching...
No Matches
mtcore::IPv6 Struct Reference

Represents an IP version 6 address (128 bits) If it represents an IPv4 address, can be converted to an IPv4 address. More...

#include <ip.hpp>

Public Member Functions

Result< void, IpInitErrorinit (const Slice< const char > &str)
 
Result< void, IpInitErrorinit (const Slice< char > &str)
 
Result< void, IpInitErrorinit (const std::string_view &str)
 
Result< void, IpInitErrorinit (const std::string &str)
 
std::strong_ordering operator<=> (const IPv6 &o) const noexcept
 
bool operator== (const IPv6 &o) const noexcept
 
bool operator!= (const IPv6 &o) const noexcept
 
bool operator<= (const IPv6 &o) const noexcept
 
bool operator>= (const IPv6 &o) const noexcept
 
bool operator< (const IPv6 &o) const noexcept
 
bool operator> (const IPv6 &o) const noexcept
 
bool is_ip4 () const noexcept
 
Result< IPv4, Ip6ConversionErrorto_ip4 () const
 

Public Attributes

u64 high = 0
 
u64 low = 0
 

Detailed Description

Represents an IP version 6 address (128 bits) If it represents an IPv4 address, can be converted to an IPv4 address.

Definition at line 83 of file ip.hpp.

Member Function Documentation

◆ init() [1/4]

Result< void, IpInitError > mtcore::IPv6::init ( const Slice< char > & str)
nodiscard

◆ init() [2/4]

Result< void, IpInitError > mtcore::IPv6::init ( const Slice< const char > & str)
nodiscard

◆ init() [3/4]

Result< void, IpInitError > mtcore::IPv6::init ( const std::string & str)
nodiscard

◆ init() [4/4]

Result< void, IpInitError > mtcore::IPv6::init ( const std::string_view & str)
nodiscard

◆ is_ip4()

bool mtcore::IPv6::is_ip4 ( ) const
inlinenodiscardnoexcept

Definition at line 107 of file ip.hpp.

107 {
108 return high == 0 && ((low & 0xffffffff00000000ull) == 0x0000ffff00000000ull);
109 }
u64 high
Definition ip.hpp:84
u64 low
Definition ip.hpp:85

◆ operator!=()

bool mtcore::IPv6::operator!= ( const IPv6 & o) const
inlinenodiscardnoexcept

Definition at line 101 of file ip.hpp.

101{ return (*this <=> o) != 0; }

◆ operator<()

bool mtcore::IPv6::operator< ( const IPv6 & o) const
inlinenodiscardnoexcept

Definition at line 104 of file ip.hpp.

104{ return (*this <=> o) < 0; }

◆ operator<=()

bool mtcore::IPv6::operator<= ( const IPv6 & o) const
inlinenodiscardnoexcept

Definition at line 102 of file ip.hpp.

102{ return (*this <=> o) <= 0; }

◆ operator<=>()

std::strong_ordering mtcore::IPv6::operator<=> ( const IPv6 & o) const
inlinenodiscardnoexcept

Definition at line 92 of file ip.hpp.

92 {
93 const auto highCmp = high <=> o.high;
94 const auto lowCmp = low <=> o.low;
95 if (highCmp == std::strong_ordering::equal) {
96 return lowCmp;
97 }
98 return highCmp;
99 }

◆ operator==()

bool mtcore::IPv6::operator== ( const IPv6 & o) const
inlinenodiscardnoexcept

Definition at line 100 of file ip.hpp.

100{ return (*this <=> o) == 0; }

◆ operator>()

bool mtcore::IPv6::operator> ( const IPv6 & o) const
inlinenodiscardnoexcept

Definition at line 105 of file ip.hpp.

105{ return (*this <=> o) > 0; }

◆ operator>=()

bool mtcore::IPv6::operator>= ( const IPv6 & o) const
inlinenodiscardnoexcept

Definition at line 103 of file ip.hpp.

103{ return (*this <=> o) >= 0; }

◆ to_ip4()

Result< IPv4, Ip6ConversionError > mtcore::IPv6::to_ip4 ( ) const
nodiscard

Member Data Documentation

◆ high

u64 mtcore::IPv6::high = 0

Definition at line 84 of file ip.hpp.

◆ low

u64 mtcore::IPv6::low = 0

Definition at line 85 of file ip.hpp.


The documentation for this struct was generated from the following file: