1// Copyright (C) 2017 Lorenz Haas
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QMQTTTOPICNAME_H
6#define QMQTTTOPICNAME_H
7
8#include <QtMqtt/qmqttglobal.h>
9
10#include <QtCore/QExplicitlySharedDataPointer>
11#include <QtCore/QMetaType>
12#include <QtCore/QString>
13#include <QtCore/QStringList>
14
15QT_BEGIN_NAMESPACE
16
17class QMqttTopicNamePrivate;
18
19class QMqttTopicName;
20// qHash is a friend, but we can't use default arguments for friends (ยง8.3.6.4)
21Q_MQTT_EXPORT size_t qHash(const QMqttTopicName &name, size_t seed = 0) Q_DECL_NOTHROW;
22
23class Q_MQTT_EXPORT QMqttTopicName
24{
25public:
26 QMqttTopicName(const QString &name = QString());
27 QMqttTopicName(const QLatin1String &name);
28 QMqttTopicName(const QMqttTopicName &name);
29 ~QMqttTopicName();
30 QMqttTopicName &operator=(const QMqttTopicName &name);
31
32#ifdef Q_COMPILER_RVALUE_REFS
33 QMqttTopicName &operator=(QMqttTopicName &&other) noexcept { swap(other); return *this; }
34#endif
35
36 void swap(QMqttTopicName &other) noexcept { d.swap(other&: other.d); }
37
38 QString name() const;
39 void setName(const QString &name);
40
41 Q_REQUIRED_RESULT bool isValid() const;
42 Q_REQUIRED_RESULT int levelCount() const;
43 Q_REQUIRED_RESULT QStringList levels() const;
44
45 friend Q_MQTT_EXPORT bool operator==(const QMqttTopicName &lhs, const QMqttTopicName &rhs) Q_DECL_NOTHROW;
46 friend inline bool operator!=(const QMqttTopicName &lhs, const QMqttTopicName &rhs) Q_DECL_NOTHROW { return !(lhs == rhs); }
47 friend Q_MQTT_EXPORT bool operator<(const QMqttTopicName &lhs, const QMqttTopicName &rhs) Q_DECL_NOTHROW;
48 friend Q_MQTT_EXPORT size_t qHash(const QMqttTopicName &name, size_t seed) Q_DECL_NOTHROW;
49
50private:
51 QExplicitlySharedDataPointer<QMqttTopicNamePrivate> d;
52};
53
54Q_DECLARE_SHARED(QMqttTopicName)
55
56#ifndef QT_NO_DATASTREAM
57Q_MQTT_EXPORT QDataStream &operator<<(QDataStream &, const QMqttTopicName &);
58Q_MQTT_EXPORT QDataStream &operator>>(QDataStream &, QMqttTopicName &);
59#endif
60
61#ifndef QT_NO_DEBUG_STREAM
62Q_MQTT_EXPORT QDebug operator<<(QDebug, const QMqttTopicName &);
63#endif
64
65QT_END_NAMESPACE
66
67Q_DECLARE_METATYPE(QMqttTopicName)
68
69#endif // QMQTTTOPICNAME_H
70

source code of qtmqtt/src/mqtt/qmqtttopicname.h