UniRec  3.3.2
Public Member Functions | Data Fields
Nemea::IpAddress Struct Reference

A struct representing an IP address with associated operations. More...

#include <ipAddress.hpp>

Public Member Functions

 IpAddress (ip_addr_t ip=EMPTY_IP_ADDRESS)
 Constructor to initialize IpAddress with an ip_addr_t value. More...
 
 IpAddress (const std::string &ipAddressAsString)
 Constructor to create IpAddress from a string representation of an IP address. More...
 
bool isIpv4 () const
 Check if the stored IP address is an IPv4 address. More...
 
bool isIpv6 () const
 Check if the stored IP address is an IPv6 address. More...
 
bool operator== (const IpAddress &other) const
 Equality operator to compare two IpAddress objects. More...
 
IpAddress operator& (const IpAddress &other) const
 Bitwise AND operator to perform a bitwise AND operation on two IpAddress objects. More...
 
std::ostream & operator<< (std::ostream &os)
 Output stream operator to stream an IpAddress object to an output stream. More...
 

Data Fields

ip_addr_t ip
 

Detailed Description

A struct representing an IP address with associated operations.

Definition at line 29 of file ipAddress.hpp.

Constructor & Destructor Documentation

◆ IpAddress() [1/2]

Nemea::IpAddress::IpAddress ( ip_addr_t  ip = EMPTY_IP_ADDRESS)

Constructor to initialize IpAddress with an ip_addr_t value.

Parameters
ipThe ip_addr_t value.

Definition at line 15 of file ipAddress.cpp.

◆ IpAddress() [2/2]

Nemea::IpAddress::IpAddress ( const std::string &  ipAddressAsString)

Constructor to create IpAddress from a string representation of an IP address.

Parameters
ipAddressAsStringThe string representation of the IP address.
Exceptions
std::runtime_errorif the IP address string is invalid.

Definition at line 20 of file ipAddress.cpp.

Member Function Documentation

◆ isIpv4()

bool Nemea::IpAddress::isIpv4 ( ) const

Check if the stored IP address is an IPv4 address.

Returns
True if the IP address is IPv4, false otherwise.

Definition at line 28 of file ipAddress.cpp.

◆ isIpv6()

bool Nemea::IpAddress::isIpv6 ( ) const

Check if the stored IP address is an IPv6 address.

Returns
True if the IP address is IPv6, false otherwise.

Definition at line 30 of file ipAddress.cpp.

◆ operator&()

IpAddress Nemea::IpAddress::operator& ( const IpAddress other) const

Bitwise AND operator to perform a bitwise AND operation on two IpAddress objects.

Parameters
otherThe IpAddress to AND with.
Returns
A new IpAddress object containing the result of the bitwise AND operation.

Definition at line 37 of file ipAddress.cpp.

◆ operator<<()

std::ostream & Nemea::IpAddress::operator<< ( std::ostream &  os)

Output stream operator to stream an IpAddress object to an output stream.

Parameters
osThe output stream.
Returns
The modified output stream.

Definition at line 45 of file ipAddress.cpp.

◆ operator==()

bool Nemea::IpAddress::operator== ( const IpAddress other) const

Equality operator to compare two IpAddress objects.

Parameters
otherThe IpAddress to compare with.
Returns
True if the IpAddress objects are equal, false otherwise.

Definition at line 32 of file ipAddress.cpp.

Field Documentation

◆ ip

ip_addr_t Nemea::IpAddress::ip

Definition at line 30 of file ipAddress.hpp.


The documentation for this struct was generated from the following files: