KDSoapValue.h

00001 /****************************************************************************
00002 ** Copyright (C) 2010-2010 Klaralvdalens Datakonsult AB.  All rights reserved.
00003 **
00004 ** This file is part of the KD SOAP library.
00005 **
00006 ** Licensees holding valid commercial KD Soap licenses may use this file in
00007 ** accordance with the KD Soap Commercial License Agreement provided with
00008 ** the Software.
00009 **
00010 **
00011 ** This file may be distributed and/or modified under the terms of the
00012 ** GNU General Public License version 2 and version 3 as published by the
00013 ** Free Software Foundation and appearing in the file LICENSE.GPL included.
00014 **
00015 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00016 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00017 **
00018 ** Contact info@kdab.com if any conditions of this licensing are not
00019 ** clear to you.
00020 **
00021 **********************************************************************/
00022 
00023 #ifndef KDSOAPVALUE_H
00024 #define KDSOAPVALUE_H
00025 
00026 #include <QtCore/QString>
00027 #include <QtCore/QVariant>
00028 #include <QtCore/QList>
00029 #include <QtCore/QPair>
00030 #include <QtCore/QSet>
00031 #include <QtCore/QVector>
00032 #include <QtCore/QSharedDataPointer>
00033 #include "KDSoapGlobal.h"
00034 
00035 #ifndef QT_NO_STL
00036 # include <algorithm>
00037 #endif
00038 
00039 class KDSoapValueList;
00040 
00052 class KDSOAP_EXPORT KDSoapValue
00053 {
00054 public:
00059     KDSoapValue();
00063     ~KDSoapValue();
00064 
00074     KDSoapValue(const QString& name, const QVariant& valueVariant, const QString& typeNameSpace = QString(), const QString& typeName = QString());
00083     KDSoapValue(const QString& name, const KDSoapValueList& childValues, const QString& typeNameSpace = QString(), const QString& typeName = QString());
00084 
00088     KDSoapValue(const KDSoapValue& other);
00089 
00093     KDSoapValue& operator=(const KDSoapValue& other) {
00094         if ( this != &other ) {
00095             KDSoapValue copy( other );
00096             swap( copy );
00097         }
00098         return *this;
00099     }
00100 
00104     void swap( KDSoapValue& other ) {
00105 #if QT_VERSION < 0x040600
00106         qSwap( reinterpret_cast<Private*&>(d), reinterpret_cast<Private*&>(other.d) );
00107 #else
00108         d.swap( other.d );
00109 #endif
00110     }
00111 
00115     QString name() const;
00116 
00120     QVariant value() const;
00121 
00125     void setValue(const QVariant& value);
00126 
00131     KDSoapValueList& childValues() const;
00132 
00136     bool operator==(const KDSoapValue& other) const;
00137 
00152     void setType(const QString& nameSpace, const QString& type);
00157     QString typeNs() const;
00162     QString type() const;
00163 
00164 private:
00165     // To catch mistakes
00166     KDSoapValue(QString, QString, QString);
00167     class Private;
00168     QSharedDataPointer<Private> d;
00169 };
00170 
00171 Q_DECLARE_TYPEINFO( KDSoapValue, Q_MOVABLE_TYPE );
00172 
00173 KDSOAP_EXPORT QDebug operator <<(QDebug dbg, const KDSoapValue &value);
00174 
00175 KDSOAP_EXPORT uint qHash( const KDSoapValue& value );
00176 inline void qSwap( KDSoapValue & lhs, KDSoapValue & rhs ) { lhs.swap( rhs ); }
00177 
00178 #ifndef QT_NO_STL
00179 namespace std {
00180     template <> inline void swap<KDSoapValue>( KDSoapValue & lhs, KDSoapValue & rhs ) {
00181         lhs.swap( rhs );
00182     }
00183 }
00184 #endif
00185 
00192 class KDSOAP_EXPORT KDSoapValueList : public QList<KDSoapValue>
00193 {
00194 public:
00209     void addArgument(const QString& argumentName, const QVariant& argumentValue, const QString& typeNameSpace = QString(), const QString& typeName = QString());
00210 
00216     KDSoapValue child(const QString& name) const;
00217 
00226     void setArrayType(const QString& nameSpace, const QString& type);
00230     QString arrayTypeNs() const;
00234     QString arrayType() const;
00235 
00243     QList<KDSoapValue>& attributes() { return m_attributes; }
00247     const QList<KDSoapValue>& attributes() const { return m_attributes; }
00248 
00249 private:
00250     QPair<QString, QString> m_arrayType;
00251     QList<KDSoapValue> m_attributes;
00252 
00253     QVariant d; // for extensions
00254 };
00255 
00256 typedef QListIterator<KDSoapValue> KDSoapValueListIterator;
00257 
00258 //Q_DECLARE_METATYPE(KDSoapValueList)
00259 
00260 #endif // KDSOAPVALUE_H
 All Classes Functions Enumerations Enumerator Friends

Klarälvdalens Datakonsult AB (KDAB)
Qt-related services and products
http://www.kdab.com/
http://www.kdab.com/products/kd-soap/