libnick 2024.9.2
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)
 Constructs an IPv4Address.
 
 IPv4Address (unsigned long address)
 Constructs an IPv4Address.
 
unsigned char getFirst () const
 Gets the first byte of the address.
 
unsigned char getSecond () const
 Gets the second byte of the address.
 
unsigned char getThird () const
 Gets the third byte of the address.
 
unsigned char getFourth () const
 Gets the fourth byte of the address.
 
std::string str () const
 Gets the string representation of the address.
 

Static Public Member Functions

static std::optional< IPv4Addressparse (const std::string &address)
 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 )

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)

Constructs an IPv4Address.

Parameters
addressThe address as a long

Member Function Documentation

◆ getFirst()

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

Gets the first byte of the address.

Returns
The first byte of the address

◆ getFourth()

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

Gets the fourth byte of the address.

Returns
The fourth byte of the address

◆ getSecond()

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

Gets the second byte of the address.

Returns
The second byte of the address

◆ getThird()

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

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)
static

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

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: