mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-21 06:45:39 -06:00
Core/Rpc: Finished
git-svn-id: svn://ultimatepp.org/upp/trunk@5168 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
3b3ba5db66
commit
1dbfde1189
3 changed files with 14 additions and 10 deletions
|
|
@ -188,6 +188,13 @@ Value ParseXmlRpcValue(XmlParser& p);
|
|||
Value ParseXmlRpcParam(XmlParser& p);
|
||||
ValueArray ParseXmlRpcParams(XmlParser& p);
|
||||
|
||||
struct RpcGet {
|
||||
Value v;
|
||||
|
||||
template <class T>
|
||||
operator T() { T x; ValueGet(x, v); return x; }
|
||||
};
|
||||
|
||||
struct RpcData {
|
||||
String peeraddr;
|
||||
ValueArray in;
|
||||
|
|
@ -201,15 +208,15 @@ struct RpcData {
|
|||
template <class T>
|
||||
RpcData& operator>>(T& x) { ValueGet(x, Get()); return *this; }
|
||||
|
||||
Value operator[](const char *id) { return in_map[id]; }
|
||||
RpcGet operator[](const char *id) { RpcGet h; h.v = in_map[id]; return h; }
|
||||
|
||||
template <class T>
|
||||
RpcData& operator<<(const T& x) { ASSERT(out_map.GetCount() == 0); Value v; ValuePut(v, x); out.Add(v); return *this; }
|
||||
RpcData& operator<<(const T& x) { ASSERT(out_map.GetCount() == 0); Value v; ValuePut(v, x); out.Add(v); return *this; }
|
||||
|
||||
template <class T>
|
||||
void Set(int i, const T& x) { ASSERT(out_map.GetCount() == 0); Value v; ValuePut(v, x); out.Set(i, v); }
|
||||
void Set(int i, const T& x) { ASSERT(out_map.GetCount() == 0); Value v; ValuePut(v, x); out.Set(i, v); }
|
||||
|
||||
void Reset() { in.Clear(); out.Clear(); ii = 0; }
|
||||
void Reset() { in.Clear(); out.Clear(); ii = 0; }
|
||||
|
||||
RpcData() { ii = 0; }
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#include "Rpc.h"
|
||||
|
||||
#define LLOG(x) DLOG(x)
|
||||
#define LLOG(x) // DLOG(x)
|
||||
|
||||
NAMESPACE_UPP
|
||||
|
||||
|
|
@ -148,12 +148,10 @@ Value ProcessJsonRpc(const Value& v, const char *group, const char *peeraddr)
|
|||
data.in_map = param;
|
||||
else
|
||||
data.in = param;
|
||||
DDUMP(data.in);
|
||||
try {
|
||||
if(CallRpcMethod(data, group, methodname)) {
|
||||
if(IsValueArray(data.out)) {
|
||||
ValueArray va = data.out;
|
||||
DDUMP(data.out);
|
||||
Value result = Null;
|
||||
if(va.GetCount()) {
|
||||
if(IsError(va[0])) {
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ void ValueGet(int& n, const Value& v)
|
|||
|
||||
void ValueGet(String& s, const Value& v)
|
||||
{
|
||||
ValueCheck(IsNull(v) || IsString(s));
|
||||
ValueCheck(IsNull(v) || IsString(v));
|
||||
s = v;
|
||||
}
|
||||
|
||||
|
|
@ -53,7 +53,7 @@ void ValueGet(double& x, const Value& v)
|
|||
|
||||
void ValueGet(bool& x, const Value& v)
|
||||
{
|
||||
ValueCheck(IsNull(v) || IsNumber(x));
|
||||
ValueCheck(IsNull(v) || IsNumber(v));
|
||||
x = v;
|
||||
}
|
||||
|
||||
|
|
@ -67,7 +67,6 @@ Time IsoTime(const Value& v)
|
|||
|
||||
void ValueGet(Date& x, const Value& v)
|
||||
{
|
||||
DDUMP(v);
|
||||
if(IsString(v)) {
|
||||
x = IsoTime(v);
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue