diff options
author | Javier S. Pedro <maemo@javispedro.com> | 2013-04-01 15:04:58 +0200 |
---|---|---|
committer | Javier S. Pedro <maemo@javispedro.com> | 2013-04-01 15:04:58 +0200 |
commit | 5ef8b38e55c1883224fe1f01f47aba45b7b42666 (patch) | |
tree | 67a873c6a7c5263d202793314c3b3a61543fbb40 /xmlrpcreply.h | |
download | tapasboard-5ef8b38e55c1883224fe1f01f47aba45b7b42666.tar.gz tapasboard-5ef8b38e55c1883224fe1f01f47aba45b7b42666.zip |
initial import
Diffstat (limited to 'xmlrpcreply.h')
-rw-r--r-- | xmlrpcreply.h | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/xmlrpcreply.h b/xmlrpcreply.h new file mode 100644 index 0000000..58b2bca --- /dev/null +++ b/xmlrpcreply.h @@ -0,0 +1,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 |