XML RPC - 如何在C++版本的 XMLRPC-C 库中包装、返回和获取 vector<map<string、string> > 的对象?

xml rpc - how to wrap, return and get the object of vector<map<string, string> > in C++ version of xmlrpc-c library?

本文关键字:lt string gt 获取 vector 返回 对象 map 包装 RPC C++      更新时间:2023-10-16

我正在使用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.

谁能给我一个c++示例代码或虚拟代码使用xmlrpc-c来实现我的对象?非常感谢你的帮助!

您必须在服务器端进行封送,在客户端进行反封送。也称为序列化和反序列化。

你要求我们提供大量代码。