gpt4 book ai didi

c++ - 如何在 C++ 版本的 xmlrpc-c 库中包装、返回和获取 vector> 的对象?

转载 作者:太空宇宙 更新时间:2023-11-04 14:22:02 26 4
gpt4 key购买 nike

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

在客户端,我尝试打印来自服务器的所有值,即打印每个 map 的键和整个 vector 的值。

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 实现我的目标的虚拟代码吗?非常感谢您的帮助!

最佳答案

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

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

关于c++ - 如何在 C++ 版本的 xmlrpc-c 库中包装、返回和获取 vector<map<string, string>> 的对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6749345/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com