Ocean
Ocean::Network::Port Class Reference

This class wraps a port number with 16 bits. More...

Inheritance diagram for Ocean::Network::Port:

Public Member Functions

 Port ()=default
 Creates a new port object with zero as default value. More...
 
 Port (const uint16_t port)
 Creates a new port object. More...
 
 Port (const uint16_t port, const OrderType orderType)
 Creates a new port object by a given port number in big-endian, little-endian order or local platform order. More...
 
uint16_t littleEndian () const
 Returns the port number in little-endian order. More...
 
uint16_t readable () const
 Returns the port number in a readable order. More...
 
bool isValid () const
 Returns whether this port hold a non-zero value. More...
 
bool isNull () const
 Returns whether this port holds a zero value. More...
 
bool operator== (const Port &port) const
 Returns whether two port number are identical. More...
 
bool operator!= (const Port &port) const
 Returns whether two port number are not identical. More...
 
 operator uint16_t () const
 Casts the wrapped port number. More...
 

Protected Attributes

uint16_t port_ = 0u
 Port 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...
 
- 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...
 

Detailed Description

This class wraps a port number with 16 bits.


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

Constructor & Destructor Documentation

◆ Port() [1/3]

Ocean::Network::Port::Port ( )
default

Creates a new port object with zero as default value.

◆ Port() [2/3]

Ocean::Network::Port::Port ( const uint16_t  port)
inlineexplicit

Creates a new port object.

Parameters
portThe port number to be wrapped in big-endian order

◆ Port() [3/3]

Ocean::Network::Port::Port ( const uint16_t  port,
const OrderType  orderType 
)
inline

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

Parameters
portThe port number to be wrapped
orderTypeType of the order

Member Function Documentation

◆ isNull()

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

Returns whether this port holds a zero value.

Returns
True, if so

◆ isValid()

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

Returns whether this port hold a non-zero value.

Returns
True, if so

◆ littleEndian()

uint16_t Ocean::Network::Port::littleEndian ( ) const
inline

Returns the port number in little-endian order.

Returns
Port number in little-endian order

◆ operator uint16_t()

Ocean::Network::Port::operator uint16_t ( ) const
inline

Casts the wrapped port number.

Returns
Wrapped port number in big-endian order

◆ operator!=()

bool Ocean::Network::Port::operator!= ( const Port port) const
inline

Returns whether two port number are not identical.

Parameters
portRight port to compare
Returns
True, if so

◆ operator==()

bool Ocean::Network::Port::operator== ( const Port port) const
inline

Returns whether two port number are identical.

Parameters
portRight port to compare
Returns
True, if so

◆ readable()

uint16_t Ocean::Network::Port::readable ( ) const
inline

Returns the port number in a readable order.

This function is platform specific.

Field Documentation

◆ port_

uint16_t Ocean::Network::Port::port_ = 0u
protected

Port number to wrap in big-endian order.


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