XmlRPC入门_基本类型操作
#include <iostream> #include <winsock2.h> #include <windows.h> #include <xmlrpc-c/base.hpp> #include <xmlrpc-c/registry.hpp> #include <xmlrpc-c/server_abyss.hpp> #include <direct.h> #include <stdio.h> #include <stdlib.h> int main() { xmlrpc_env env; xmlrpc_env_init(&env); //整型操作 xmlrpc_value *int1, *int2; int1 = xmlrpc_build_value(&env, "i", 7); int2 = xmlrpc_int_new(&env, 8); int ivalue; int ivalue1; xmlrpc_read_int(&env, int1, &ivalue); xmlrpc_decompose_value(&env, int2, "i", &ivalue1); std::cout << "ivalue is: " << ivalue << std::endl; std::cout << "ivalue1 is: " << ivalue1 << std::endl; //浮点型操作 xmlrpc_value *double1, *double2; double1 = xmlrpc_build_value(&env, "d", 3.14159); double2 = xmlrpc_double_new(&env, 0.732); double dvalue; double dvalue1; xmlrpc_read_double(&env, double1, &dvalue); xmlrpc_decompose_value(&env, double2, "d", &dvalue1); std::cout << "dvalue is: " << dvalue << std::endl; std::cout << "dvalue1 is: " << dvalue1 << std::endl; //字符串操作 xmlrpc_value *str1, *str2; str1 = xmlrpc_build_value(&env, "s", "test1"); str2 = xmlrpc_string_new(&env, "test2"); const char* strr1; const char* strr2; xmlrpc_read_string(&env, str1, &strr1); xmlrpc_decompose_value(&env, str2, "s", &strr2); std::cout << "str1 is: " << strr1 << std::endl; std::cout << "str2 is: " << strr2 << std::endl; system("pause"); }
上述代码中实现了对三种基本数据类型整型、浮点型、字符串的xmlrpc封装与解析过程。注意,上述代码环境需要xmlrpc环境配置。
又没有什么可说的