File: variant.h

package info (click to toggle)
qxmlrpc 0.0.svn6-2
  • links: PTS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, stretch, wheezy
  • size: 392 kB
  • ctags: 200
  • sloc: cpp: 1,621; python: 29; makefile: 23
file content (77 lines) | stat: -rw-r--r-- 2,460 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// vim:tabstop=4:shiftwidth=4:expandtab:cinoptions=(s,U1,m1
// Copyright (C) 2005 Dmitry Poplavsky <dima@thekompany.com>

#ifndef XMLRPC_VARIANT_H
#define XMLRPC_VARIANT_H

#include <QtCore>
#include <QtXml>

namespace  xmlrpc {

/*!
 \class xmlrpc::Variant variant.h
 \brief The xmlrpc::Variant class acts like a union for XML-RPC variables types.

 The xmlrpc::Variant class is the version of QVariant with set of types restricted to
 types supported by XML-RPC specification. For this purpose, the Variant( const QVariant& )
 constructor is declared as private, and xmlrpc::Variant construcors defined for all the
 XML-RPC supported types. This allows to perform the compile time XML-RPC types checks.

 The xmlrpc::Variant class also provides deserialization and serialization from/to QDomElement,
 according to XML-RPC specification, with <value> top DOM element.
 */
class Variant : public QVariant {
public:
    Variant();
	Variant( const Variant& );
	Variant( const QDomElement& );

    /*! Next constructors should be used to build xmlrpc::Variant
        values from users data, to be passed to the xmlrpc::Client::request call*/
    Variant ( uint val );
    Variant ( int val );
    Variant ( bool val );
    Variant ( double val );
    Variant ( const QByteArray & val );
    Variant ( const QString & val );
    Variant ( const QStringList & val );
    Variant ( const QDateTime & val );
    Variant ( const QList<Variant> & val );
    Variant ( const QMap<QString, Variant> & val );

    //! this variable is casted to string XML-RPC type
    Variant ( const QChar & c );

	virtual ~Variant();

    //! serialize Variant data to the QDomDocument, according to XML-RPC specification.
    QDomElement toDomElement( QDomDocument& ) const;

    QString pprint();

private:
    static QString   encodeDateTimeIso8601(QDateTime);
    static QDateTime decodeDateTimeIso8601(QString, bool *ok=0);

    /*! decode the <struct> dom node */
    static Variant decodeStruct( const QDomElement& node );

    /*! decode the <array> dom node */
    static Variant decodeArray( const QDomElement& node );

    /**
     * Variant( const QVariant& ) constructor is declared private
     * to prohibit casting from any QVariant type.
     * This allows to perform the compile time checks
     * for variables types, passed to xml=rpc request.
     */
	Variant( const QVariant& );

    QString pprint( int column );
}; 


} // namespace
#endif // XMLRPC_VARIANT_H