如何包装,返回并获取vector <map <string,string =“”>&gt;的对象在C ++版本的xmlrpc-c库?</map <string,>

时间:2011-07-19 15:02:13

标签: c++ xml-rpc

我正在使用xmlrpc-c库(http://xmlrpc-c.sourceforge.net),我正在编写服务器和客户端代码。我知道xmlrpc提供了许多内置结构,比如xmlrpc_c :: value_struct,但文档无法帮助我弄清楚如何实现我的对象。

在服务器中,我尝试返回结构vector<map<string,string>>,代码片段如下:

SomeDefaultMethod::execute(string const& methodName, xmlrpc_c::paramList const& paramList, xmlrpc_c::value* const retvalP)
{
    *retvalP = structure; // suppose the variable structure is of type vector<map<string,string> >
}

在客户端,我试图从服务器打印所有值,即打印每个地图的键和整个矢量的值。

string const serverUrl("http://localhost:8183/RPC2");
string const methodName("webcommands.bulkpagestatus");
xmlrpc_c::clientSimple myClient;
xmlrpc_c::value result;
myClient.call(serverUrl, methodName, &result)
// do not know how to get the values then through result in this situation.

有人能用xmlrpc -c给我一个C ++示例代码或虚拟代码来实现我的对象吗?我真的很感谢你的帮助!

1 个答案:

答案 0 :(得分:0)

您必须在服务器端进行编组并在客户端进行非编组。也称为序列化和反序列化。

您要求我们提供大量代码。尝试谷歌搜索编组代码示例。