KD SOAP API Documentation  2.2
KDSoapValue.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** This file is part of the KD Soap project.
4 **
5 ** SPDX-FileCopyrightText: 2010 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
6 **
7 ** SPDX-License-Identifier: MIT
8 **
9 ****************************************************************************/
10 #ifndef KDSOAPVALUE_H
11 #define KDSOAPVALUE_H
12 
13 #include "KDSoapGlobal.h"
14 #include <QtCore/QList>
15 #include <QtCore/QPair>
16 #include <QtCore/QSet>
17 #include <QtCore/QSharedDataPointer>
18 #include <QtCore/QString>
19 #include <QtCore/QVariant>
20 #include <QtCore/QVector>
21 #include <QtCore/QXmlStreamNamespaceDeclarations>
22 
23 #ifndef QT_NO_STL
24 #include <algorithm>
25 #endif
26 
27 class KDSoapValueList;
29 QT_BEGIN_NAMESPACE
30 class QXmlStreamWriter;
31 QT_END_NAMESPACE
32 
33 namespace KDSoap {
40 {
42  SOAP1_1 = 1,
44  SOAP1_2 = 2
45 };
46 }
47 
60 {
61 public:
66  KDSoapValue();
70  ~KDSoapValue();
71 
80  KDSoapValue(const QString &name, const QVariant &valueVariant, const QString &typeNameSpace = QString(), const QString &typeName = QString());
89  KDSoapValue(const QString &name, const KDSoapValueList &childValues, const QString &typeNameSpace = QString(),
90  const QString &typeName = QString());
91 
95  KDSoapValue(const KDSoapValue &other);
96 
101  {
102  if (this != &other) {
103  KDSoapValue copy(other);
104  swap(copy);
105  }
106  return *this;
107  }
108 
112  void swap(KDSoapValue &other)
113  {
114  d.swap(other.d);
115  }
116 
121  bool isNull() const;
122 
128  bool isNil() const;
129 
134  void setNillable(bool nillable);
135 
139  QString name() const;
140 
144  QString namespaceUri() const;
145 
149  void setNamespaceUri(const QString &ns);
150 
154  QVariant value() const;
155 
159  void setValue(const QVariant &value);
160 
166  bool isQualified() const;
167 
180  void setQualified(bool qualified);
181 
186  KDSoapValueList &childValues() const;
187 
191  bool operator==(const KDSoapValue &other) const;
192 
196  bool operator!=(const KDSoapValue &other) const;
197 
212  void setType(const QString &nameSpace, const QString &type);
217  QString typeNs() const;
222  QString type() const;
223 
228  void setNamespaceDeclarations(const QXmlStreamNamespaceDeclarations &namespaceDeclarations);
229 
234  void addNamespaceDeclaration(const QXmlStreamNamespaceDeclaration &namespaceDeclaration);
235 
240  QXmlStreamNamespaceDeclarations namespaceDeclarations() const;
241 
246  void setEnvironmentNamespaceDeclarations(const QXmlStreamNamespaceDeclarations &environmentNamespaceDeclarations);
247 
252  QXmlStreamNamespaceDeclarations environmentNamespaceDeclarations() const;
253 
259  KDSoapValueList split() const;
260 
265  enum Use
266  {
268  EncodedUse
269  };
270 
271  QByteArray toXml(Use use = LiteralUse, const QString &messageNamespace = QString()) const;
272 
273 protected: // for KDSoapMessage
274  void setName(const QString &name);
275 
276 private:
277  // To catch mistakes
278  KDSoapValue(QString, QString, QString);
279 
280  friend class KDSoapMessageWriter;
281  void writeElement(KDSoapNamespacePrefixes &namespacePrefixes, QXmlStreamWriter &writer, KDSoapValue::Use use, const QString &messageNamespace,
282  bool forceQualified) const;
283  void writeElementContents(KDSoapNamespacePrefixes &namespacePrefixes, QXmlStreamWriter &writer, KDSoapValue::Use use,
284  const QString &messageNamespace) const;
285  void writeChildren(KDSoapNamespacePrefixes &namespacePrefixes, QXmlStreamWriter &writer, KDSoapValue::Use use, const QString &messageNamespace,
286  bool forceQualified) const;
287 
288  class Private;
289  QSharedDataPointer<Private> d;
290 };
291 
292 QT_BEGIN_NAMESPACE
294 QT_END_NAMESPACE
295 
296 KDSOAP_EXPORT QDebug operator<<(QDebug dbg, const KDSoapValue &value);
297 
298 KDSOAP_EXPORT uint qHash(const KDSoapValue &value);
299 inline void qSwap(KDSoapValue &lhs, KDSoapValue &rhs)
300 {
301  lhs.swap(rhs);
302 }
303 
304 #ifndef QT_NO_STL
305 namespace std {
306 template<>
308 {
309  lhs.swap(rhs);
310 }
311 }
312 #endif
313 
320 class KDSOAP_EXPORT KDSoapValueList : public QList<KDSoapValue> // krazy:exclude=dpointer
321 {
322 public:
338  void addArgument(const QString &argumentName, const QVariant &argumentValue, const QString &typeNameSpace = QString(),
339  const QString &typeName = QString());
340 
348  KDSoapValue child(const QString &name) const;
349 
358  void setArrayType(const QString &nameSpace, const QString &type);
362  QString arrayTypeNs() const;
366  QString arrayType() const;
367 
375  QList<KDSoapValue> &attributes()
376  {
377  return m_attributes;
378  }
382  const QList<KDSoapValue> &attributes() const
383  {
384  return m_attributes;
385  }
386 
387 private:
388  QPair<QString, QString> m_arrayType;
389  QList<KDSoapValue> m_attributes;
390 
391  QVariant d; // for extensions
392 };
393 
394 typedef QListIterator<KDSoapValue> KDSoapValueListIterator;
395 
396 // Q_DECLARE_METATYPE(KDSoapValueList)
397 
398 #endif // KDSOAPVALUE_H
#define KDSOAP_EXPORT
Definition: KDSoapGlobal.h:22
QListIterator< KDSoapValue > KDSoapValueListIterator
Definition: KDSoapValue.h:394
void qSwap(KDSoapValue &lhs, KDSoapValue &rhs)
Definition: KDSoapValue.h:299
QT_END_NAMESPACE KDSOAP_EXPORT QDebug operator<<(QDebug dbg, const KDSoapValue &value)
KDSOAP_EXPORT uint qHash(const KDSoapValue &value)
Definition: KDSoapValue.cpp:49
QT_BEGIN_NAMESPACE Q_DECLARE_TYPEINFO(KDSoapValue, Q_MOVABLE_TYPE)
QList< KDSoapValue > & attributes()
Definition: KDSoapValue.h:375
const QList< KDSoapValue > & attributes() const
Definition: KDSoapValue.h:382
@ LiteralUse
data is serialized according to a given schema, no xsi:type attributes are written out
Definition: KDSoapValue.h:267
void swap(KDSoapValue &other)
Definition: KDSoapValue.h:112
KDSoapValue & operator=(const KDSoapValue &other)
Definition: KDSoapValue.h:100
@ SOAP1_1
Definition: KDSoapValue.h:42
@ SOAP1_2
Definition: KDSoapValue.h:44
void swap< KDSoapValue >(KDSoapValue &lhs, KDSoapValue &rhs)
Definition: KDSoapValue.h:307

© 2010-2024 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 by doxygen 1.9.1