summaryrefslogtreecommitdiff
path: root/xmlrpcreply.h
blob: 58b2bca9bc33a35b2f77f56352aab4533b6abda4 (plain)
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
#ifndef XMLRPCREPLY_H
#define XMLRPCREPLY_H

#include "xmlrpcpendingcall.h"

template <typename T>
class XmlRpcReply
{
public:
	XmlRpcReply(XmlRpcPendingCall *call);

	bool isValid() const;

	operator T () const;

private:
	bool _valid;
	T _value;
};

template <typename T>
XmlRpcReply<T>::XmlRpcReply(XmlRpcPendingCall *call)
    : _valid(false)
{
	call->waitForFinished();
	if (call->isValid()) {
		QVariant v = call->value();
		if (v.canConvert<T>()) {
			_value = v.value<T>();
			_valid = true;
		}
	}
}

template <typename T>
inline bool XmlRpcReply<T>::isValid() const
{
	return _valid;
}

template <typename T>
inline XmlRpcReply<T>::operator T () const
{
	return _value;
}

#endif // XMLRPCREPLY_H