NetSim 1.0.0
An educational network simulation software for students
Loading...
Searching...
No Matches
ipaddress.h
Go to the documentation of this file.
1#ifndef IPADDRESS_H
2#define IPADDRESS_H
3
4#include <QRandomGenerator>
5#include <QString>
6#include <QTextStream>
7#include <QVector>
8
12
13namespace NetSim {
14
17
27class IPAddress {
28public:
30 IPAddress() = default;
31
37 IPAddress(const QVector<quint8> &address);
38
40 QString toString() const;
41
43 QVector<quint8> toArray() const;
44
46 quint32 toInt() const;
47
57 static IPAddress getRandomAddress(bool isLocal = false);
58
67 bool operator<(const IPAddress &other) const;
68
78 bool operator==(const IPAddress &other) const;
79
80private:
82 QVector<quint8> m_address{QVector<quint8>() << 0 << 0 << 0 << 0};
83};
84} // namespace NetSim
85
86#endif // IPADDRESS_H
Represents an IPv4 address.
Definition ipaddress.h:27
QString toString() const
Converts the IP address to a string format.
Definition ipaddress.cpp:9
quint32 toInt() const
Converts the IP address to an integer format.
Definition ipaddress.cpp:19
bool operator==(const IPAddress &other) const
Overload of the equality operator.
Definition ipaddress.cpp:44
static IPAddress getRandomAddress(bool isLocal=false)
Generates a random IP address.
Definition ipaddress.cpp:28
QVector< quint8 > toArray() const
Converts the IP address to a byte array.
Definition ipaddress.cpp:16
bool operator<(const IPAddress &other) const
Overload of the less than operator.
Definition ipaddress.cpp:40
IPAddress()=default
Default constructor.
Definition logger.h:12