1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). |
4 | ** Contact: http://www.qt-project.org/legal |
5 | ** |
6 | ** This file is part of the QtDBus module of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:LGPL$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and Digia. For licensing terms and |
14 | ** conditions see http://qt.digia.com/licensing. For further information |
15 | ** use the contact form at http://qt.digia.com/contact-us. |
16 | ** |
17 | ** GNU Lesser General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
19 | ** General Public License version 2.1 as published by the Free Software |
20 | ** Foundation and appearing in the file LICENSE.LGPL included in the |
21 | ** packaging of this file. Please review the following information to |
22 | ** ensure the GNU Lesser General Public License version 2.1 requirements |
23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
24 | ** |
25 | ** In addition, as a special exception, Digia gives you certain additional |
26 | ** rights. These rights are described in the Digia Qt LGPL Exception |
27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
28 | ** |
29 | ** GNU General Public License Usage |
30 | ** Alternatively, this file may be used under the terms of the GNU |
31 | ** General Public License version 3.0 as published by the Free Software |
32 | ** Foundation and appearing in the file LICENSE.GPL included in the |
33 | ** packaging of this file. Please review the following information to |
34 | ** ensure the GNU General Public License version 3.0 requirements will be |
35 | ** met: http://www.gnu.org/copyleft/gpl.html. |
36 | ** |
37 | ** |
38 | ** $QT_END_LICENSE$ |
39 | ** |
40 | ****************************************************************************/ |
41 | |
42 | #ifndef QDBUSEXTRATYPES_H |
43 | #define QDBUSEXTRATYPES_H |
44 | |
45 | // define some useful types for D-BUS |
46 | |
47 | #include <QtCore/qvariant.h> |
48 | #include <QtCore/qstring.h> |
49 | #include <QtDBus/qdbusmacros.h> |
50 | |
51 | #ifndef QT_NO_DBUS |
52 | |
53 | QT_BEGIN_HEADER |
54 | |
55 | QT_BEGIN_NAMESPACE |
56 | |
57 | QT_MODULE(DBus) |
58 | |
59 | // defined in qhash.cpp |
60 | Q_CORE_EXPORT uint qHash(const QString &key); |
61 | |
62 | class Q_DBUS_EXPORT QDBusObjectPath : private QString |
63 | { |
64 | public: |
65 | inline QDBusObjectPath() { } |
66 | |
67 | inline explicit QDBusObjectPath(const char *path); |
68 | inline explicit QDBusObjectPath(const QLatin1String &path); |
69 | inline explicit QDBusObjectPath(const QString &path); |
70 | inline QDBusObjectPath &operator=(const QDBusObjectPath &path); |
71 | |
72 | inline void setPath(const QString &path); |
73 | |
74 | inline QString path() const |
75 | { return *this; } |
76 | |
77 | private: |
78 | void check(); |
79 | }; |
80 | |
81 | inline QDBusObjectPath::QDBusObjectPath(const char *objectPath) |
82 | : QString(QString::fromLatin1(objectPath)) |
83 | { check(); } |
84 | |
85 | inline QDBusObjectPath::QDBusObjectPath(const QLatin1String &objectPath) |
86 | : QString(objectPath) |
87 | { check(); } |
88 | |
89 | inline QDBusObjectPath::QDBusObjectPath(const QString &objectPath) |
90 | : QString(objectPath) |
91 | { check(); } |
92 | |
93 | inline QDBusObjectPath &QDBusObjectPath::operator=(const QDBusObjectPath &_path) |
94 | { QString::operator=(_path); check(); return *this; } |
95 | |
96 | inline void QDBusObjectPath::setPath(const QString &objectPath) |
97 | { QString::operator=(objectPath); check(); } |
98 | |
99 | inline bool operator==(const QDBusObjectPath &lhs, const QDBusObjectPath &rhs) |
100 | { return lhs.path() == rhs.path(); } |
101 | |
102 | inline bool operator!=(const QDBusObjectPath &lhs, const QDBusObjectPath &rhs) |
103 | { return lhs.path() != rhs.path(); } |
104 | |
105 | inline bool operator<(const QDBusObjectPath &lhs, const QDBusObjectPath &rhs) |
106 | { return lhs.path() < rhs.path(); } |
107 | |
108 | inline uint qHash(const QDBusObjectPath &objectPath) |
109 | { return qHash(objectPath.path()); } |
110 | |
111 | |
112 | class Q_DBUS_EXPORT QDBusSignature : private QString |
113 | { |
114 | public: |
115 | inline QDBusSignature() { } |
116 | |
117 | inline explicit QDBusSignature(const char *signature); |
118 | inline explicit QDBusSignature(const QLatin1String &signature); |
119 | inline explicit QDBusSignature(const QString &signature); |
120 | inline QDBusSignature &operator=(const QDBusSignature &signature); |
121 | |
122 | inline void setSignature(const QString &signature); |
123 | |
124 | inline QString signature() const |
125 | { return *this; } |
126 | |
127 | private: |
128 | void check(); |
129 | }; |
130 | |
131 | inline QDBusSignature::QDBusSignature(const char *dBusSignature) |
132 | : QString(QString::fromAscii(dBusSignature)) |
133 | { check(); } |
134 | |
135 | inline QDBusSignature::QDBusSignature(const QLatin1String &dBusSignature) |
136 | : QString(dBusSignature) |
137 | { check(); } |
138 | |
139 | inline QDBusSignature::QDBusSignature(const QString &dBusSignature) |
140 | : QString(dBusSignature) |
141 | { check(); } |
142 | |
143 | inline QDBusSignature &QDBusSignature::operator=(const QDBusSignature &dbusSignature) |
144 | { QString::operator=(dbusSignature); check(); return *this; } |
145 | |
146 | inline void QDBusSignature::setSignature(const QString &dBusSignature) |
147 | { QString::operator=(dBusSignature); check(); } |
148 | |
149 | inline bool operator==(const QDBusSignature &lhs, const QDBusSignature &rhs) |
150 | { return lhs.signature() == rhs.signature(); } |
151 | |
152 | inline bool operator!=(const QDBusSignature &lhs, const QDBusSignature &rhs) |
153 | { return lhs.signature() != rhs.signature(); } |
154 | |
155 | inline bool operator<(const QDBusSignature &lhs, const QDBusSignature &rhs) |
156 | { return lhs.signature() < rhs.signature(); } |
157 | |
158 | inline uint qHash(const QDBusSignature &signature) |
159 | { return qHash(signature.signature()); } |
160 | |
161 | class QDBusVariant : private QVariant |
162 | { |
163 | public: |
164 | inline QDBusVariant() { } |
165 | inline explicit QDBusVariant(const QVariant &variant); |
166 | |
167 | inline void setVariant(const QVariant &variant); |
168 | |
169 | inline QVariant variant() const |
170 | { return *this; } |
171 | }; |
172 | |
173 | inline QDBusVariant::QDBusVariant(const QVariant &dBusVariant) |
174 | : QVariant(dBusVariant) { } |
175 | |
176 | inline void QDBusVariant::setVariant(const QVariant &dBusVariant) |
177 | { QVariant::operator=(dBusVariant); } |
178 | |
179 | inline bool operator==(const QDBusVariant &v1, const QDBusVariant &v2) |
180 | { return v1.variant() == v2.variant(); } |
181 | |
182 | QT_END_NAMESPACE |
183 | |
184 | Q_DECLARE_METATYPE(QDBusVariant) |
185 | Q_DECLARE_METATYPE(QDBusObjectPath) |
186 | Q_DECLARE_METATYPE(QList<QDBusObjectPath>) |
187 | Q_DECLARE_METATYPE(QDBusSignature) |
188 | Q_DECLARE_METATYPE(QList<QDBusSignature>) |
189 | |
190 | QT_END_HEADER |
191 | |
192 | #endif // QT_NO_DBUS |
193 | #endif |
194 | |