| KD SOAP 1.9.1

KDSoapValue.h
1 /****************************************************************************
2 ** Copyright (C) 2010-2020 Klaralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com.
3 ** All rights reserved.
4 **
5 ** This file is part of the KD Soap library.
6 **
7 ** Licensees holding valid commercial KD Soap licenses may use this file in
8 ** accordance with the KD Soap Commercial License Agreement provided with
9 ** the Software.
10 **
11 **
12 ** This file may be distributed and/or modified under the terms of the
13 ** GNU Lesser General Public License version 2.1 and version 3 as published by the
14 ** Free Software Foundation and appearing in the file LICENSE.LGPL.txt included.
15 **
16 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
17 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
18 **
19 ** Contact info@kdab.com if any conditions of this licensing are not
20 ** clear to you.
21 **
22 **********************************************************************/
23 #ifndef KDSOAPVALUE_H
24 #define KDSOAPVALUE_H
25
26 #include <QtCore/QString>
27 #include <QtCore/QVariant>
28 #include <QtCore/QList>
29 #include <QtCore/QPair>
30 #include <QtCore/QSet>
31 #include <QtCore/QVector>
32 #include <QtCore/QSharedDataPointer>
33 #include <QtCore/QXmlStreamNamespaceDeclarations>
34 #include "KDSoapGlobal.h"
35
36 #ifndef QT_NO_STL
37 # include <algorithm>
38 #endif
39
40 // Qt-4.7 errors on QVariant::fromValue<signed char>(), but later versions support it.
41 #if QT_VERSION < 0x040800
42 Q_DECLARE_METATYPE(signed char)
43 #endif
44
45 class KDSoapValueList;
46 class KDSoapNamespacePrefixes;
47 QT_BEGIN_NAMESPACE
48 class QXmlStreamWriter;
49 QT_END_NAMESPACE
50
51 namespace KDSoap {
57 enum SoapVersion {
59 SOAP1_1 = 1,
61 SOAP1_2 = 2
62 };
63 }
64
76 class KDSOAP_EXPORT KDSoapValue
77 {
78 public:
83 KDSoapValue();
87 ~KDSoapValue();
88
97 KDSoapValue(const QString &name, const QVariant &valueVariant, const QString &typeNameSpace = QString(), const QString &typeName = QString());
106 KDSoapValue(const QString &name, const KDSoapValueList &childValues, const QString &typeNameSpace = QString(), const QString &typeName = QString());
107
111 KDSoapValue(const KDSoapValue &other);
112
116 KDSoapValue &operator=(const KDSoapValue &other)
117 {
118 if (this != &other) {
119 KDSoapValue copy(other);
120 swap(copy);
121 }
122 return *this;
123 }
124
128 void swap(KDSoapValue &other)
129 {
130 #if QT_VERSION < 0x040600
131 qSwap(reinterpret_cast<Private *&>(d), reinterpret_cast<Private *&>(other.d));
132 #else
133 d.swap(other.d);
134 #endif
135 }
136
141 bool isNull() const;
142
148 bool isNil() const;
149
154 void setNillable(bool nillable);
155
159 QString name() const;
160
164 QString namespaceUri() const;
165
169 void setNamespaceUri(const QString &ns);
170
174 QVariant value() const;
175
179 void setValue(const QVariant &value);
180
186 bool isQualified() const;
187
200 void setQualified(bool qualified);
201
206 KDSoapValueList &childValues() const;
207
211 bool operator==(const KDSoapValue &other) const;
212
216 bool operator!=(const KDSoapValue &other) const;
217
232 void setType(const QString &nameSpace, const QString &type);
237 QString typeNs() const;
242 QString type() const;
243
248 void setNamespaceDeclarations(const QXmlStreamNamespaceDeclarations& namespaceDeclarations);
249
254 void addNamespaceDeclaration(const QXmlStreamNamespaceDeclaration& namespaceDeclaration);
255
260 QXmlStreamNamespaceDeclarations namespaceDeclarations() const;
261
266 void setEnvironmentNamespaceDeclarations(const QXmlStreamNamespaceDeclarations& environmentNamespaceDeclarations);
267
272 QXmlStreamNamespaceDeclarations environmentNamespaceDeclarations() const;
273
279 KDSoapValueList split() const;
280
285 enum Use {
286 LiteralUse,
287 EncodedUse
288 };
289
290 QByteArray toXml(Use use = LiteralUse, const QString &messageNamespace = QString()) const;
291
292 protected: // for KDSoapMessage
293
294 void setName(const QString &name);
295
296 private:
297 // To catch mistakes
298 KDSoapValue(QString, QString, QString);
299
300 friend class KDSoapMessageWriter;
301 void writeElement(KDSoapNamespacePrefixes &namespacePrefixes, QXmlStreamWriter &writer, KDSoapValue::Use use, const QString &messageNamespace, bool forceQualified) const;
302 void writeElementContents(KDSoapNamespacePrefixes &namespacePrefixes, QXmlStreamWriter &writer, KDSoapValue::Use use, const QString &messageNamespace) const;
303 void writeChildren(KDSoapNamespacePrefixes &namespacePrefixes, QXmlStreamWriter &writer, KDSoapValue::Use use, const QString &messageNamespace, bool forceQualified) const;
304
305 class Private;
306 QSharedDataPointer<Private> d;
307 };
308
309 QT_BEGIN_NAMESPACE
310 Q_DECLARE_TYPEINFO(KDSoapValue, Q_MOVABLE_TYPE);
311 QT_END_NAMESPACE
312
313 KDSOAP_EXPORT QDebug operator <<(QDebug dbg, const KDSoapValue &value);
314
315 KDSOAP_EXPORT uint qHash(const KDSoapValue &value);
316 inline void qSwap(KDSoapValue &lhs, KDSoapValue &rhs)
317 {
318 lhs.swap(rhs);
319 }
320
321 #ifndef QT_NO_STL
322 namespace std
323 {
324 template <> inline void swap<KDSoapValue>(KDSoapValue &lhs, KDSoapValue &rhs)
325 {
326 lhs.swap(rhs);
327 }
328 }
329 #endif
330
337 class KDSOAP_EXPORT KDSoapValueList : public QList<KDSoapValue> //krazy:exclude=dpointer
338 {
339 public:
355 void addArgument(const QString &argumentName, const QVariant &argumentValue, const QString &typeNameSpace = QString(), const QString &typeName = QString());
356
364 KDSoapValue child(const QString &name) const;
365
374 void setArrayType(const QString &nameSpace, const QString &type);
378 QString arrayTypeNs() const;
382 QString arrayType() const;
383
391 QList<KDSoapValue> &attributes()
392 {
393 return m_attributes;
394 }
398 const QList<KDSoapValue> &attributes() const
399 {
400 return m_attributes;
401 }
402
403 private:
404 QPair<QString, QString> m_arrayType;
405 QList<KDSoapValue> m_attributes;
406
407 QVariant d; // for extensions
408 };
409
410 typedef QListIterator<KDSoapValue> KDSoapValueListIterator;
411
412 //Q_DECLARE_METATYPE(KDSoapValueList)
413
414 #endif // KDSOAPVALUE_H
KDSoapValue::LiteralUse
@ LiteralUse
data is serialized according to a given schema, no xsi:type attributes are written out
Definition: KDSoapValue.h:286
KDSoapValue::swap
void swap(KDSoapValue &other)
Definition: KDSoapValue.h:128
KDSoapValue
Definition: KDSoapValue.h:77
KDSoapValue::operator=
KDSoapValue & operator=(const KDSoapValue &other)
Definition: KDSoapValue.h:116
KDSoapValue::Use
Use
Definition: KDSoapValue.h:285
KDSoapValueList
Definition: KDSoapValue.h:338
KDSoapValueList::attributes
const QList< KDSoapValue > & attributes() const
Definition: KDSoapValue.h:398
KDSoapValueList::attributes
QList< KDSoapValue > & attributes()
Definition: KDSoapValue.h:391

Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
https://www.kdab.com/development-resources/qt-tools/kd-soap/