Ocean
Ocean::Network::Address4 Class Reference

This class wraps an address number with 32 bits. More...

Inheritance diagram for Ocean::Network::Address4:

Public Member Functions

 Address4 ()=default
 Creates a new address object with zero as default value. More...
 
 Address4 (const uint32_t address)
 Creates a new address object. More...
 
 Address4 (const uint32_t address, const OrderType orderType)
 Creates a new address object by a given address number in big-endian, little-endian order or local platform. More...
 
 Address4 (const uint8_t sub0, const uint8_t sub1, const uint8_t sub2, const uint8_t sub3)
 Creates a new address object. More...
 
uint32_t littleEndian () const
 Returns the address number in little-endian order. More...
 
std::string readable () const
 Returns the address number as a readable string. More...
 
bool isValid () const
 Returns whether this address hold a valid address. More...
 
bool isNull () const
 Returns whether this address hold an invalid address (a zero address). More...
 
bool operator== (const Address4 &address) const
 Returns whether two address objects are identical. More...
 
bool operator!= (const Address4 &address) const
 Returns whether two address objects are not identical. More...
 
 operator uint32_t () const
 Casts the wrapped address number. More...
 
size_t operator() (const Address4 &address) const
 Hash function. More...
 

Static Public Member Functions

static Address4 localHost ()
 Returns the local host address. More...
 
- Static Public Member Functions inherited from Ocean::Network::Data
static int toBigEndian (const int32_t value)
 Returns a value in big-endian order given in local system bit order. More...
 
static uint32_t toBigEndian (const uint32_t value)
 Returns a value in big-endian order given in local system bit order. More...
 
static int16_t toBigEndian (const int16_t value)
 Returns a value in big-endian order given in local system bit order. More...
 
static uint16_t toBigEndian (const uint16_t value)
 Returns a value in big-endian order given in local system bit order. More...
 
static int32_t fromBigEndian (const int32_t value)
 Returns a value in local system bit order given as big-endian bit order. More...
 
static uint32_t fromBigEndian (const uint32_t value)
 Returns a value in local system bit order given as big-endian bit order. More...
 
static int16_t fromBigEndian (const int16_t value)
 Returns a value in local system bit order given as big-endian bit order. More...
 
static uint16_t fromBigEndian (const uint16_t value)
 Returns a value in local system bit order given as big-endian bit order. More...
 

Protected Attributes

uint32_t address_ = 0u
 Address4 number to wrap in big-endian order. More...
 

Additional Inherited Members

- Public Types inherited from Ocean::Network::Data
enum  OrderType : uint32_t { TYPE_BIG_ENDIAN , TYPE_LITTLE_ENDIAN , TYPE_READABLE }
 Definition of different order types. More...
 

Detailed Description

This class wraps an address number with 32 bits.

Internally, the address number is stored in big-endian order.

Constructor & Destructor Documentation

◆ Address4() [1/4]

Ocean::Network::Address4::Address4 ( )
inlinedefault

Creates a new address object with zero as default value.

◆ Address4() [2/4]

Ocean::Network::Address4::Address4 ( const uint32_t  address)
inline

Creates a new address object.

Parameters
addressAddress4 number in big-endian order

◆ Address4() [3/4]

Ocean::Network::Address4::Address4 ( const uint32_t  address,
const OrderType  orderType 
)
inline

Creates a new address object by a given address number in big-endian, little-endian order or local platform.

Parameters
addressAddress4 number to be wrapped
orderTypeType of the order

◆ Address4() [4/4]

Ocean::Network::Address4::Address4 ( const uint8_t  sub0,
const uint8_t  sub1,
const uint8_t  sub2,
const uint8_t  sub3 
)
inline

Creates a new address object.

Parameters
sub0First sub address
sub1Second sub address
sub2Third sub address
sub3Fourth sub address

Member Function Documentation

◆ isNull()

bool Ocean::Network::Address4::isNull ( ) const
inline

Returns whether this address hold an invalid address (a zero address).

Returns
True, if so

◆ isValid()

bool Ocean::Network::Address4::isValid ( ) const
inline

Returns whether this address hold a valid address.

Returns
True, if so

◆ littleEndian()

unsigned int Ocean::Network::Address4::littleEndian ( ) const
inline

Returns the address number in little-endian order.

Returns
Address4 number in little-endian order

◆ localHost()

Address4 Ocean::Network::Address4::localHost ( )
inlinestatic

Returns the local host address.

Returns
Local host address

◆ operator uint32_t()

Ocean::Network::Address4::operator uint32_t ( ) const
inline

Casts the wrapped address number.

Returns
Wrapped address number in big-endian order

◆ operator!=()

bool Ocean::Network::Address4::operator!= ( const Address4 address) const
inline

Returns whether two address objects are not identical.

Parameters
addressRight address object to compare
Returns
True, if so

◆ operator()()

size_t Ocean::Network::Address4::operator() ( const Address4 address) const
inline

Hash function.

Parameters
addressThe address for which the hash will be determined
Returns
The hash value

◆ operator==()

bool Ocean::Network::Address4::operator== ( const Address4 address) const
inline

Returns whether two address objects are identical.

Parameters
addressRight address object to compare
Returns
True, if so

◆ readable()

std::string Ocean::Network::Address4::readable ( ) const

Returns the address number as a readable string.

Returns
Readable address string

Field Documentation

◆ address_

uint32_t Ocean::Network::Address4::address_ = 0u
protected

Address4 number to wrap in big-endian order.


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