Heart 1.4.918.d927d9c
Heart is base back end library for your c++ Qt projects.
Loading...
Searching...
No Matches
hostaddress.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2018-2025 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
QByteArray toBytes() const
toBytes This method convert a network address to a byte array.
unsigned short port() const
The port method return port of node.
QString toString() const
toString this method convert the Host Address value to string value.
void setPort(unsigned short port)
setPort This method set new port value.
bool isValid() const
isValid This method return true if the current network address is valid.
bool fromBytes(const QByteArray &array)
fromBytes This method applay array obejct. (conver a byte array to a newtwork address object)
static bool isIP(const QString &address)
isIP This method return true if the address is valid.
#define DEFAULT_PORT
Definition config.h:22
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