KD SOAP 2.0.0
Loading...
Searching...
No Matches
KDSoapValue.h
1/****************************************************************************
2**
3** This file is part of the KD Soap library.
4**
5** SPDX-FileCopyrightText: 2010-2021 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
6**
7** SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDAB-KDSoap OR LicenseRef-KDAB-KDSoap-US
8**
9** Licensees holding valid commercial KD Soap licenses may use this file in
10** accordance with the KD Soap Commercial License Agreement provided with
11** the Software.
12**
13** Contact info@kdab.com if any conditions of this licensing are not clear to you.
14**
15****************************************************************************/
16#ifndef KDSOAPVALUE_H
17#define KDSOAPVALUE_H
18
19#include <QtCore/QString>
20#include <QtCore/QVariant>
21#include <QtCore/QList>
22#include <QtCore/QPair>
23#include <QtCore/QSet>
24#include <QtCore/QVector>
25#include <QtCore/QSharedDataPointer>
26#include <QtCore/QXmlStreamNamespaceDeclarations>
27#include "KDSoapGlobal.h"
28
29#ifndef QT_NO_STL
30#include <algorithm>
31#endif
32
33class KDSoapValueList;
34class KDSoapNamespacePrefixes;
35QT_BEGIN_NAMESPACE
36class QXmlStreamWriter;
37QT_END_NAMESPACE
38
39namespace KDSoap {
45enum SoapVersion
46{
48 SOAP1_1 = 1,
50 SOAP1_2 = 2
51};
52}
53
65class KDSOAP_EXPORT KDSoapValue
66{
67public:
77
86 KDSoapValue(const QString &name, const QVariant &valueVariant, const QString &typeNameSpace = QString(), const QString &typeName = QString());
95 KDSoapValue(const QString &name, const KDSoapValueList &childValues, const QString &typeNameSpace = QString(),
96 const QString &typeName = QString());
97
101 KDSoapValue(const KDSoapValue &other);
102
107 {
108 if (this != &other) {
109 KDSoapValue copy(other);
110 swap(copy);
111 }
112 return *this;
113 }
114
118 void swap(KDSoapValue &other)
119 {
120 d.swap(other.d);
121 }
122
127 bool isNull() const;
128
134 bool isNil() const;
135
140 void setNillable(bool nillable);
141
145 QString name() const;
146
150 QString namespaceUri() const;
151
155 void setNamespaceUri(const QString &ns);
156
160 QVariant value() const;
161
165 void setValue(const QVariant &value);
166
172 bool isQualified() const;
173
186 void setQualified(bool qualified);
187
192 KDSoapValueList &childValues() const;
193
197 bool operator==(const KDSoapValue &other) const;
198
202 bool operator!=(const KDSoapValue &other) const;
203
218 void setType(const QString &nameSpace, const QString &type);
223 QString typeNs() const;
228 QString type() const;
229
234 void setNamespaceDeclarations(const QXmlStreamNamespaceDeclarations &namespaceDeclarations);
235
240 void addNamespaceDeclaration(const QXmlStreamNamespaceDeclaration &namespaceDeclaration);
241
246 QXmlStreamNamespaceDeclarations namespaceDeclarations() const;
247
252 void setEnvironmentNamespaceDeclarations(const QXmlStreamNamespaceDeclarations &environmentNamespaceDeclarations);
253
258 QXmlStreamNamespaceDeclarations environmentNamespaceDeclarations() const;
259
265 KDSoapValueList split() const;
266
271 enum Use
272 {
274 EncodedUse
275 };
276
277 QByteArray toXml(Use use = LiteralUse, const QString &messageNamespace = QString()) const;
278
279protected: // for KDSoapMessage
280 void setName(const QString &name);
281
282private:
283 // To catch mistakes
284 KDSoapValue(QString, QString, QString);
285
286 friend class KDSoapMessageWriter;
287 void writeElement(KDSoapNamespacePrefixes &namespacePrefixes, QXmlStreamWriter &writer, KDSoapValue::Use use, const QString &messageNamespace,
288 bool forceQualified) const;
289 void writeElementContents(KDSoapNamespacePrefixes &namespacePrefixes, QXmlStreamWriter &writer, KDSoapValue::Use use,
290 const QString &messageNamespace) const;
291 void writeChildren(KDSoapNamespacePrefixes &namespacePrefixes, QXmlStreamWriter &writer, KDSoapValue::Use use, const QString &messageNamespace,
292 bool forceQualified) const;
293
294 class Private;
295 QSharedDataPointer<Private> d;
296};
297
298QT_BEGIN_NAMESPACE
299Q_DECLARE_TYPEINFO(KDSoapValue, Q_MOVABLE_TYPE);
300QT_END_NAMESPACE
301
302KDSOAP_EXPORT QDebug operator<<(QDebug dbg, const KDSoapValue &value);
303
304KDSOAP_EXPORT uint qHash(const KDSoapValue &value);
305inline void qSwap(KDSoapValue &lhs, KDSoapValue &rhs)
306{
307 lhs.swap(rhs);
308}
309
310#ifndef QT_NO_STL
311namespace std {
312template<>
313inline void swap<KDSoapValue>(KDSoapValue &lhs, KDSoapValue &rhs)
314{
315 lhs.swap(rhs);
316}
317}
318#endif
319
326class KDSOAP_EXPORT KDSoapValueList : public QList<KDSoapValue> // krazy:exclude=dpointer
327{
328public:
344 void addArgument(const QString &argumentName, const QVariant &argumentValue, const QString &typeNameSpace = QString(),
345 const QString &typeName = QString());
346
354 KDSoapValue child(const QString &name) const;
355
364 void setArrayType(const QString &nameSpace, const QString &type);
368 QString arrayTypeNs() const;
372 QString arrayType() const;
373
381 QList<KDSoapValue> &attributes()
382 {
383 return m_attributes;
384 }
388 const QList<KDSoapValue> &attributes() const
389 {
390 return m_attributes;
391 }
392
393private:
394 QPair<QString, QString> m_arrayType;
395 QList<KDSoapValue> m_attributes;
396
397 QVariant d; // for extensions
398};
399
400typedef QListIterator<KDSoapValue> KDSoapValueListIterator;
401
402// Q_DECLARE_METATYPE(KDSoapValueList)
403
404#endif // KDSOAPVALUE_H
Definition: KDSoapValue.h:66
Use
Definition: KDSoapValue.h:272
@ LiteralUse
data is serialized according to a given schema, no xsi:type attributes are written out
Definition: KDSoapValue.h:273
void swap(KDSoapValue &other)
Definition: KDSoapValue.h:118
KDSoapValue & operator=(const KDSoapValue &other)
Definition: KDSoapValue.h:106
Definition: KDSoapValue.h:327
const QList< KDSoapValue > & attributes() const
Definition: KDSoapValue.h:388
QList< KDSoapValue > & attributes()
Definition: KDSoapValue.h:381

© 2010-2021 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/
Generated on Fri May 1 2026 03:12:45 for KD SOAP by doxygen 1.9.6