NetSim 1.0.0
An educational network simulation software for students
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
NetSim::IPAddress Class Reference

Represents an IPv4 address. More...

#include <ipaddress.h>

Public Member Functions

 IPAddress ()=default
 Default constructor.
 
 IPAddress (const QVector< quint8 > &address)
 Constructs an IPAddress from a given byte array.
 
QString toString () const
 Converts the IP address to a string format.
 
QVector< quint8 > toArray () const
 Converts the IP address to a byte array.
 
quint32 toInt () const
 Converts the IP address to an integer format.
 
bool operator< (const IPAddress &other) const
 Overload of the less than operator.
 
bool operator== (const IPAddress &other) const
 Overload of the equality operator.
 

Static Public Member Functions

static IPAddress getRandomAddress (bool isLocal=false)
 Generates a random IP address.
 

Detailed Description

Represents an IPv4 address.

This class provides functionalities to represent an IPv4 address, and offers various conversion utilities like converting to string, array or an integer format.

Constructor & Destructor Documentation

◆ IPAddress() [1/2]

NetSim::IPAddress::IPAddress ( )
default

Default constructor.

Here is the caller graph for this function:

◆ IPAddress() [2/2]

IPAddress::IPAddress ( const QVector< quint8 > &  address)

Constructs an IPAddress from a given byte array.

Parameters
addressA byte array representing the IP address.

Member Function Documentation

◆ getRandomAddress()

IPAddress IPAddress::getRandomAddress ( bool  isLocal = false)
static

Generates a random IP address.

If the isLocal parameter is true, the last byte of the IP address is set to 1.

Parameters
isLocalWhether the IP address should be local or not.
Returns
A random IP address.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator<()

bool IPAddress::operator< ( const IPAddress other) const

Overload of the less than operator.

Compares this IP address to another based on their integer format.

Parameters
otherThe other IP address to compare against.
Returns
true if this IP address is less than the other, false otherwise.
Here is the call graph for this function:

◆ operator==()

bool IPAddress::operator== ( const IPAddress other) const

Overload of the equality operator.

Checks if this IP address is equal to another based on their integer format.

Parameters
otherThe other IP address to compare against.
Returns
true if the IP addresses are equal, false otherwise.
Here is the call graph for this function:

◆ toArray()

QVector< quint8 > IPAddress::toArray ( ) const

Converts the IP address to a byte array.

Here is the caller graph for this function:

◆ toInt()

quint32 IPAddress::toInt ( ) const

Converts the IP address to an integer format.

Here is the caller graph for this function:

◆ toString()

QString IPAddress::toString ( ) const

Converts the IP address to a string format.

Here is the caller graph for this function:

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