Thermal Camera SDK 10.1.1
SDK for Optris Thermal Cameras
Loading...
Searching...
No Matches
optris::IpAddress Class Reference

Encapsulates an IP v4 address. More...

#include <IpAddress.h>

Collaboration diagram for optris::IpAddress:
Collaboration graph

Public Member Functions

OTC_SDK_API IpAddress () noexcept
 Constructor.
 
OTC_SDK_API IpAddress (std::uint32_t address) noexcept
 Constructor.
 
OTC_SDK_API IpAddress (const std::string &address)
 Constructor.
 
OTC_SDK_API IpAddress (std::uint8_t a, std::uint8_t b, std::uint8_t c, std::uint8_t d) noexcept
 Constructor.
 
OTC_SDK_API void reset ()
 Resets all the bytes of the IP address to 0 (0.0.0.0).
 
OTC_SDK_API void setFromUInt32 (std::uint32_t address) noexcept
 Sets the address from an unsigned 32 bit integer in network byte order.
 
OTC_SDK_API std::uint32_t toUInt32 () const noexcept
 Returns the address as an unsigned 32 bit integer in network byte order.
 
OTC_SDK_API void setFromString (const std::string &address)
 Sets the address from a string in dot notation (a.b.c.d).
 
OTC_SDK_API int setFromCidrString (const std::string &address)
 Sets the address from a string in classless inter-domain routing (CIDR) notation (a.b.c.d/cidr).
 
OTC_SDK_API std::string toString () const noexcept
 Returns the address as a string in dot notation (a.b.c.d).
 
OTC_SDK_API std::string toCidrString (int cidr) const noexcept
 Returns the address as a string in classless inter-domain routing (CIDR) notation (a.b.c.d/cidr).
 
OTC_SDK_API void setByte (int index, std::uint8_t value)
 Sets the value of the byte with the given index.
 
OTC_SDK_API std::uint8_t getByte (int index) const
 Returns the value of the byte with the given index.
 
OTC_SDK_API IpAddress getNetworkPortion (const IpAddress &subnetMask) const noexcept
 Returns the network portion of the IP address according to the given subnet mask.
 
OTC_SDK_API IpAddress getNetworkPortion (int cidr) const
 Returns the network portion of the IP address according to the given CIDR bit count.
 
OTC_SDK_API IpAddress getHostPortion (const IpAddress &subnetMask) const noexcept
 Returns the host portion of the IP address according to the given subnet mask.
 
OTC_SDK_API IpAddress getHostPortion (int cidr) const
 Returns the host portion of the IP address according to the given CIDR bit count.
 
OTC_SDK_API IpAddress getBroadcastAddress (const IpAddress &subnetMask) const noexcept
 Returns the broadcast address for this IP address with the given subnet mask.
 
OTC_SDK_API IpAddress getBroadcastAddress (int cidr) const
 Returns the broadcast address for this IP address with the given CIDR bit count.
 
bool operator== (const IpAddress &rhs) const noexcept
 Equality operator.
 
bool operator== (std::uint32_t rhs) const noexcept
 Equality operator.
 
bool operator!= (const IpAddress &rhs) const noexcept
 Unequality operator.
 
bool operator< (const IpAddress &rhs) const noexcept
 Less than operator.
 

Detailed Description

Encapsulates an IP v4 address.

IP address are stored in an array in the following oder:

a.b.c.d => [0: a, 1: b, 2: c, 3: d]

Constructor & Destructor Documentation

◆ IpAddress() [1/4]

OTC_SDK_API optris::IpAddress::IpAddress ( )
noexcept

Constructor.

All IP address bytes are set to 0.

◆ IpAddress() [2/4]

OTC_SDK_API optris::IpAddress::IpAddress ( std::uint32_t address)
noexcept

Constructor.

Parameters
[in]addressas an unsigned 32 bit integer in network byte order.

◆ IpAddress() [3/4]

OTC_SDK_API optris::IpAddress::IpAddress ( const std::string & address)

Constructor.

Parameters
[in]addressstring in dot notation (a.b.c.d).
Exceptions
SDKExceptionif address string is invalid.

◆ IpAddress() [4/4]

OTC_SDK_API optris::IpAddress::IpAddress ( std::uint8_t a,
std::uint8_t b,
std::uint8_t c,
std::uint8_t d )
noexcept

Constructor.

Parameters
[in]abyte from an a.b.c.d IP address.
[in]bbyte from an a.b.c.d IP address.
[in]cbyte from an a.b.c.d IP address.
[in]dbyte from an a.b.c.d IP address.

Member Function Documentation

◆ getBroadcastAddress() [1/2]

OTC_SDK_API IpAddress optris::IpAddress::getBroadcastAddress ( const IpAddress & subnetMask) const
noexcept

Returns the broadcast address for this IP address with the given subnet mask.

Parameters
[in]subnetMaskto apply to the IP address.
Returns
broadcast address for this IP address with the given subnet mask.

◆ getBroadcastAddress() [2/2]

OTC_SDK_API IpAddress optris::IpAddress::getBroadcastAddress ( int cidr) const

Returns the broadcast address for this IP address with the given CIDR bit count.

Parameters
[in]cidrpart of the address representing the bit count of the network portion of the address.
Returns
broadcast address for this IP address with the given CIDR bit count.
Exceptions
SDKExceptionif the value of cidr is not in [0, 32].

◆ getByte()

OTC_SDK_API std::uint8_t optris::IpAddress::getByte ( int index) const

Returns the value of the byte with the given index.

Parameters
[in]indexof the desired byte.
Returns
value of the byte with the given index.
Exceptions
SDKExceptionif the index is out of range.

◆ getHostPortion() [1/2]

OTC_SDK_API IpAddress optris::IpAddress::getHostPortion ( const IpAddress & subnetMask) const
noexcept

Returns the host portion of the IP address according to the given subnet mask.

Parameters
[in]subnetMaskto apply to the IP address.
Returns
host portion of the IP address.

◆ getHostPortion() [2/2]

OTC_SDK_API IpAddress optris::IpAddress::getHostPortion ( int cidr) const

Returns the host portion of the IP address according to the given CIDR bit count.

Parameters
[in]cidrpart of the address representing the bit count of the network portion of the address.
Returns
host portion of the IP address.
Exceptions
SDKExceptionif the value of cidr is not in [0, 32].

◆ getNetworkPortion() [1/2]

OTC_SDK_API IpAddress optris::IpAddress::getNetworkPortion ( const IpAddress & subnetMask) const
noexcept

Returns the network portion of the IP address according to the given subnet mask.

Parameters
[in]subnetMaskto apply to the IP address.
Returns
network portion of the IP address.

◆ getNetworkPortion() [2/2]

OTC_SDK_API IpAddress optris::IpAddress::getNetworkPortion ( int cidr) const

Returns the network portion of the IP address according to the given CIDR bit count.

Parameters
[in]cidrpart of the address representing the bit count of the network portion of the address.
Returns
network portion of the IP address.
Exceptions
SDKExceptionif the value of cidr is not in [0, 32].

◆ setByte()

OTC_SDK_API void optris::IpAddress::setByte ( int index,
std::uint8_t value )

Sets the value of the byte with the given index.

Parameters
[in]indexof the byte to set.
[in]valueto set.
Exceptions
SDKExceptionif index is out of range.

◆ setFromCidrString()

OTC_SDK_API int optris::IpAddress::setFromCidrString ( const std::string & address)

Sets the address from a string in classless inter-domain routing (CIDR) notation (a.b.c.d/cidr).

Parameters
[in]addressin CIDR notation.
Returns
CIDR part of the address representing the bit count of the network portion of the address.
Exceptions
SDKExceptionif the address string is invalid.

◆ setFromString()

OTC_SDK_API void optris::IpAddress::setFromString ( const std::string & address)

Sets the address from a string in dot notation (a.b.c.d).

Parameters
[in]addressin dot notation.
Exceptions
SDKExceptionif the address string is invalid.

◆ setFromUInt32()

OTC_SDK_API void optris::IpAddress::setFromUInt32 ( std::uint32_t address)
noexcept

Sets the address from an unsigned 32 bit integer in network byte order.

Note
The network byte order is big-endian while many architectures like x64 or arm64 are little-endian.
Parameters
[in]addressas an unsigned 32 bit integer with the bytes in network order.

◆ toCidrString()

OTC_SDK_API std::string optris::IpAddress::toCidrString ( int cidr) const
noexcept

Returns the address as a string in classless inter-domain routing (CIDR) notation (a.b.c.d/cidr).

Parameters
[in]cidrpart of the address representing the bit count of the network portion of the address.
Returns
the address as a string in classless inter-domain routing (CIDR) notation.

◆ toString()

OTC_SDK_API std::string optris::IpAddress::toString ( ) const
noexcept

Returns the address as a string in dot notation (a.b.c.d).

Returns
the address as a string in dot notation.

◆ toUInt32()

OTC_SDK_API std::uint32_t optris::IpAddress::toUInt32 ( ) const
noexcept

Returns the address as an unsigned 32 bit integer in network byte order.

Note
The network byte order is big-endian while many architectures like x64 or arm64 are little-endian.
Returns
address as an unsigned 32 bit integer in network byte order.

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