Heart 1.3.842.34c2ab5
Heart is base back end library for your c++ Qt projects.
hostaddress.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2018-2024 QuasarApp.
3 * Distributed under the lgplv3 software license, see the accompanying
4 * Everyone is permitted to copy and distribute verbatim copies
5 * of this license document, but changing it is not allowed.
6*/
7
8
9#ifndef HOSTADDRESS_H
10#define HOSTADDRESS_H
11#include "heart_global.h"
12
13#include <QHostAddress>
14#include "config.h"
15
16namespace QH {
17
21class HEARTSHARED_EXPORT HostAddress: public QHostAddress
22{
23public:
24 explicit HostAddress();
25 explicit HostAddress(const QHostAddress& other, int port = DEFAULT_PORT);
26 explicit HostAddress(const QString& other, int port = DEFAULT_PORT);
27 HostAddress(const SpecialAddress& other, int port = DEFAULT_PORT);
28
29 HostAddress(const HostAddress& other);
30
31
36 unsigned short port() const;
37
42 void setPort(unsigned short port);
43
44 friend QDataStream& operator << (QDataStream& stream, const HostAddress& address);
45 friend QDataStream& operator >> (QDataStream& stream, HostAddress& address);
46
47 friend bool& operator == (QDataStream& stream, HostAddress& address);
48 friend bool& operator != (QDataStream& stream, HostAddress& address);
49
50 HostAddress& operator = (const HostAddress& right);;
56 static bool isIP(const QString& address);
57
62 bool isValid() const;
63
68 QString toString() const;
69
74 QByteArray toBytes() const;
75
81 bool fromBytes(const QByteArray& array);
82
83private:
84 unsigned short _port = 0;
85
86};
87
88uint qHash(const HostAddress& address);
89}
90
92
93#endif // HOSTADDRESS_H
The Host Address class this is wrapper of QHostAddress. Contains the NetworkAddress and network port.
Definition hostaddress.h:22
#define DEFAULT_PORT
Definition config.h:22
#define HEARTSHARED_EXPORT
Q_DECLARE_METATYPE(QH::HostAddress)
The QH namespace - QuasarApp Heart namespace. This namespace contains all classes of the Heart librar...
Definition heart.cpp:13
uint qHash(NodeCoonectionStatus status)
qHash - Simple hash function of NodeCoonectionStatus