libnick 2025.9.1
A cross-platform base for native Nickvision applications.
Loading...
Searching...
No Matches
Nickvision::Network::IPv4Address Class Reference

A model of an IPv4 address. More...

#include <ipv4address.h>

Public Member Functions

 IPv4Address (unsigned char first, unsigned char second, unsigned char third, unsigned char fourth) noexcept
 Constructs an IPv4Address.
 
 IPv4Address (unsigned long address) noexcept
 Constructs an IPv4Address.
 
unsigned char getFirst () const noexcept
 Gets the first byte of the address.
 
unsigned char getSecond () const noexcept
 Gets the second byte of the address.
 
unsigned char getThird () const noexcept
 Gets the third byte of the address.
 
unsigned char getFourth () const noexcept
 Gets the fourth byte of the address.
 
unsigned long getNetworkByteOrder () const noexcept
 Gets the address in network byte order.
 
std::string str () const noexcept
 Gets the string representation of the address.
 

Static Public Member Functions

static std::optional< IPv4Addressparse (const std::string &address) noexcept
 Parses an IPv4Address from a string.
 

Detailed Description

A model of an IPv4 address.

Constructor & Destructor Documentation

◆ IPv4Address() [1/2]

Nickvision::Network::IPv4Address::IPv4Address ( unsigned char first,
unsigned char second,
unsigned char third,
unsigned char fourth )
noexcept

Constructs an IPv4Address.

Parameters
firstThe first byte of the address
secondThe second byte of the address
thirdThe third byte of the address
fourthThe fourth byte of the address

◆ IPv4Address() [2/2]

Nickvision::Network::IPv4Address::IPv4Address ( unsigned long address)
noexcept

Constructs an IPv4Address.

Parameters
addressThe address as a long

Member Function Documentation

◆ getFirst()

unsigned char Nickvision::Network::IPv4Address::getFirst ( ) const
noexcept

Gets the first byte of the address.

Returns
The first byte of the address

◆ getFourth()

unsigned char Nickvision::Network::IPv4Address::getFourth ( ) const
noexcept

Gets the fourth byte of the address.

Returns
The fourth byte of the address

◆ getNetworkByteOrder()

unsigned long Nickvision::Network::IPv4Address::getNetworkByteOrder ( ) const
noexcept

Gets the address in network byte order.

Returns
The address in network byte order

◆ getSecond()

unsigned char Nickvision::Network::IPv4Address::getSecond ( ) const
noexcept

Gets the second byte of the address.

Returns
The second byte of the address

◆ getThird()

unsigned char Nickvision::Network::IPv4Address::getThird ( ) const
noexcept

Gets the third byte of the address.

Returns
The third byte of the address

◆ parse()

static std::optional< IPv4Address > Nickvision::Network::IPv4Address::parse ( const std::string & address)
staticnoexcept

Parses an IPv4Address from a string.

Parameters
addressThe string address to parse
Returns
The parsed address if successful, else std::nullopt

◆ str()

std::string Nickvision::Network::IPv4Address::str ( ) const
noexcept

Gets the string representation of the address.

Returns
The string representation of the address

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