Qt 4.8
qdbusextratypes.h
Go to the documentation of this file.
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 
54 
56 
57 QT_MODULE(DBus)
58 
59 // defined in qhash.cpp
61 
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 
86  : QString(objectPath)
87 { check(); }
88 
89 inline QDBusObjectPath::QDBusObjectPath(const QString &objectPath)
90  : QString(objectPath)
91 { check(); }
92 
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 
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 
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 
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 
183 
189 
191 
192 #endif // QT_NO_DBUS
193 #endif
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
QVariant & operator=(const QVariant &other)
Assigns the value of the variant variant to this variant.
Definition: qvariant.cpp:1921
void setVariant(const QVariant &variant)
Assigns the value of the given Qt variant to this D-Bus variant.
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
QString & operator=(QChar c)
Definition: qstring.cpp:1582
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276
#define QT_MODULE(x)
Definition: qglobal.h:2783
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
The QDBusSignature class enables the programmer to identify the SIGNATURE type provided by the D-Bus ...
void setSignature(const QString &signature)
Assigns the value of the given signature to this signature.
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool operator==(const QString &s) const
Returns true if string other is equal to this string; otherwise returns false.
Definition: qstring.cpp:2368
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
QDBusObjectPath & operator=(const QDBusObjectPath &path)
Assigns the value of the given path to this object path.
unsigned int uint
Definition: qglobal.h:996
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
QString path() const
Returns this object path.
#define Q_DECLARE_METATYPE(TYPE)
This macro makes the type Type known to QMetaType as long as it provides a public default constructor...
Definition: qmetatype.h:265
QDBusSignature & operator=(const QDBusSignature &signature)
Assigns the value of the given signature to this signature.
uint qHash(const QUrl &url)
Definition: qurl.h:285
void setPath(const QString &path)
Assigns the value of the given path to this object path.
Q_CORE_EXPORT uint qHash(const QString &key)
Definition: qhash.cpp:97
#define Q_CORE_EXPORT
Definition: qglobal.h:1449
QDBusSignature()
Constructs a new signature.
QDBusVariant()
Constructs a new D-Bus variant.
bool operator==(const QVariant &v) const
Compares this QVariant with v and returns true if they are equal; otherwise returns false...
Definition: qvariant.h:404
int key
The QDBusObjectPath class enables the programmer to identify the OBJECT_PATH type provided by the D-B...
QVariant variant() const
Returns this D-Bus variant as a QVariant object.
#define Q_DBUS_EXPORT
Definition: qglobal.h:1463
bool operator!=(const QString &s) const
Returns true if this string is not equal to string other; otherwise returns false.
Definition: qstring.h:406
const char * variant
QString signature() const
Returns this signature.
#define QT_END_HEADER
Definition: qglobal.h:137
The QDBusVariant class enables the programmer to identify the variant type provided by the D-Bus type...
bool operator<(const QString &s) const
Returns true if this string is lexically less than string other; otherwise returns false...
Definition: qstring.cpp:2436
The QList class is a template class that provides lists.
Definition: qdatastream.h:62
QDBusObjectPath()
Constructs a new object path.