• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ XmlRpcValue类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中XmlRpcValue的典型用法代码示例。如果您正苦于以下问题:C++ XmlRpcValue类的具体用法?C++ XmlRpcValue怎么用?C++ XmlRpcValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了XmlRpcValue类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: XmlRpcException

void SessionMethodValue::setXmlValutRts2 (rts2core::Connection *conn, std::string valueName, XmlRpcValue &x_val)
{
	int i_val;
	double d_val;
	std::string s_val;

	rts2core::Value *val = conn->getValue (valueName.c_str ());
	if (!val)
	{
		throw XmlRpcException ("Cannot find value '" + std::string (valueName) + "' on device '" + std::string (conn->getName ()) + "'.");
	}

	switch (val->getValueBaseType ())
	{
		case RTS2_VALUE_INTEGER:
		case RTS2_VALUE_LONGINT:
			if (x_val.getType () == XmlRpcValue::TypeInt)
			{
				i_val = (int) (x_val);
			}
			else
			{
				s_val = (std::string) (x_val);
				i_val = atoi (s_val.c_str ());
			}
			conn->queCommand (new rts2core::CommandChangeValue (conn->getOtherDevClient (), valueName, '=', i_val));
			break;
		case RTS2_VALUE_DOUBLE:
			if (x_val.getType () == XmlRpcValue::TypeDouble)
			{
				d_val = (double) (x_val);
			}
			else
			{
				s_val = (std::string) (x_val);
				d_val = atof (s_val.c_str ());
			}
			conn->queCommand (new rts2core::CommandChangeValue (conn->getOtherDevClient (), valueName, '=', d_val));
			break;

		case RTS2_VALUE_FLOAT:
			if (x_val.getType () == XmlRpcValue::TypeDouble)
			{
				d_val = (double) (x_val);
			}
			else
			{
				s_val = (std::string) (x_val);
				d_val = atof (s_val.c_str ());
			}
			conn->queCommand (new rts2core::CommandChangeValue (conn->getOtherDevClient (), valueName, '=', (float) d_val));
			break;
		case RTS2_VALUE_STRING:
			conn->queCommand (new rts2core::CommandChangeValue (conn->getOtherDevClient (), valueName, '=', (std::string) (x_val)));
			break;
		default:
			conn->queCommand (new rts2core::CommandChangeValue (conn->getOtherDevClient (), valueName, '=', (std::string) (x_val), true));
			break;
	}
}
开发者ID:shaoguangleo,项目名称:rts2,代码行数:60,代码来源:xmlapi.cpp


示例2:

// Encode the request to call the specified method with the specified parameters into xml
bool
XmlRpcCurlClient::generateRequest(const char* methodName, XmlRpcValue const& params)
{
  std::string body = REQUEST_BEGIN;
  body += methodName;
  body += REQUEST_END_METHODNAME;

  // If params is an array, each element is a separate parameter
  if (params.valid()) {
    body += PARAMS_TAG;
    if (params.getType() == XmlRpcValue::TypeArray)
    {
      for (int i=0; i<params.size(); ++i) {
        body += PARAM_TAG;
        body += params[i].toXml();
        body += PARAM_ETAG;
      }
    }
    else
    {
      body += PARAM_TAG;
      body += params.toXml();
      body += PARAM_ETAG;
    }

    body += PARAMS_ETAG;
  }
  body += REQUEST_END;

  _request = body;
  return true;
}
开发者ID:dllizhen,项目名称:pr-downloader,代码行数:33,代码来源:XmlRpcCurlClient.cpp


示例3: testArray

void testArray(XmlRpcValue const& d)
{
  // Array
  XmlRpcValue a;
  a.setSize(4);
  a[0] = 1;
  a[1] = std::string("two");
  a[2] = 43.7;
  a[3] = "four";
  assert(int(a[0]) == 1);
  assert(a[2] == d);

  char csaXml[] =
    "<value><array>\n"
    "  <data>\n"
    "    <value><i4>1</i4></value> \n"
    "    <value> <string>two</string></value>\n"
    "    <value><double>43.7</double></value>\n"
    "    <value>four</value>\n"
    "  </data>\n"
    "</array></value>";
    
  int offset = 0;
  XmlRpcValue aXml(csaXml, &offset);
  assert(a == aXml);
}
开发者ID:jaredsburrows,项目名称:xml-rpcpp,代码行数:26,代码来源:TestValuesWin32.cpp


示例4:

// Convert the response xml into a result value
bool
XmlRpcClient::parseResponse(XmlRpcValue& result)
{
  // Parse response xml into result
  int offset = 0;
  if ( ! XmlRpcUtil::findTag(METHODRESPONSE_TAG,_response,&offset)) {
    XmlRpcUtil::error("Error in XmlRpcClient::parseResponse: Invalid response - no methodResponse. Response:\n%s", _response.c_str());
    return false;
  }

  // Expect either <params><param>... or <fault>...
  if ((XmlRpcUtil::nextTagIs(PARAMS_TAG,_response,&offset) &&
       XmlRpcUtil::nextTagIs(PARAM_TAG,_response,&offset)) ||
      XmlRpcUtil::nextTagIs(FAULT_TAG,_response,&offset) && (_isFault = true))
  {
    if ( ! result.fromXml(_response, &offset)) {
      XmlRpcUtil::error("Error in XmlRpcClient::parseResponse: Invalid response value. Response:\n%s", _response.c_str());
      _response = "";
      return false;
    }
  } else {
    XmlRpcUtil::error("Error in XmlRpcClient::parseResponse: Invalid response - no param or fault tag. Response:\n%s", _response.c_str());
    _response = "";
    return false;
  }

  _response = "";
  return result.valid();
}
开发者ID:shaikhkh,项目名称:fcc_files,代码行数:30,代码来源:XmlRpcClient.cpp


示例5: findDataType

const DataType& XmlRpcFunction::parameterType (size_t synopsis_index,
					       size_t parameter_index)
{
    XmlRpcValue func_synop = mSynopsis.arrayGetItem(synopsis_index);
    XmlRpcValue param = func_synop.arrayGetItem(parameter_index + 1);
    return findDataType(param.getString());
}
开发者ID:BenedictHiddleston,项目名称:xmlrpc-c-1.06.30,代码行数:7,代码来源:XmlRpcFunction.cpp


示例6: generateRequest

// Encode the request to call the specified method with the specified parameters into xml
bool XmlRpcClient::generateRequest(const char* methodName, XmlRpcValue const& params)
{
	std::string body = REQUEST_BEGIN;
	body += methodName;
	body += REQUEST_END_METHODNAME;
	// If params is an array, each element is a separate parameter
	if (params.valid())
	{
		body += PARAMS_TAG;
		if (params.getType() == XmlRpcValue::TypeArray)
		{
			for (int i=0; i<params.size(); ++i)
			{
				body += PARAM_TAG;
				body += params[i].toXml();
				body += PARAM_ETAG;
			}
		}
		else
		{
			body += PARAM_TAG;
			body += params.toXml();
			body += PARAM_ETAG;
		}
		body += PARAMS_ETAG;
	}
	body += REQUEST_END;
	std::string header = generateHeader(body);
	XmlRpcUtil::log(4, "XmlRpcClient::generateRequest: header is %d bytes, content-length is %d.",
					header.length(), body.length());
	_request = header + body;
	return true;
}
开发者ID:ampereira,项目名称:F2Dock,代码行数:34,代码来源:XmlRpcClient.cpp


示例7: AdvancedTest

static void AdvancedTest()
{
	XmlRpcValue args, result;

	// Passing datums:
	args[0] = "a string";
	args[1] = 1;
	args[2] = true;
	args[3] = 3.14159;
	struct tm timeNow;
	args[4] = XmlRpcValue(&timeNow);

	// Passing an array:
	XmlRpcValue array;
	array[0] = 4;
	array[1] = 5;
	array[2] = 6;
	args[5] = array;
	// Note: if there's a chance that the array contains zero elements,
	// you'll need to call:
	//      array.initAsArray();
	// ...because otherwise the type will never get set to "TypeArray" and
	// the value will be a "TypeInvalid".

	// Passing a struct:
	XmlRpcValue record;
	record["SOURCE"] = "a";
	record["DESTINATION"] = "b";
	record["LENGTH"] = 5;
	args[6] = record;
	// We don't support zero-size struct's...Surely no-one needs these?

	// Make the call:
	XmlRpcClient Connection("https://61.95.191.232:9600/arumate/rpc/xmlRpcServer.php");
	Connection.setIgnoreCertificateAuthority();
	if (! Connection.execute("arumate.getMegawatts", args, result)) {
		std::cout << Connection.getError();
		return;
	}

	// Pull the data out:
	if (result.getType() != XmlRpcValue::TypeStruct) {
		std::cout << "I was expecting a struct.";
		return;
	}
	int i = result["n"];
	std::string s = result["name"];
	array = result["A"];
	for (int i=0; i < array.size(); i++)
		std::cout << (int)array[i] << "\n";
	record = result["subStruct"];
	std::cout << (std::string)record["foo"] << "\n";
}
开发者ID:drtimcooper,项目名称:XmlRpc4Win,代码行数:53,代码来源:SampleMain.cpp


示例8: switch

void XMLRPC2DIServer::xmlrpcval2amarg(XmlRpcValue& v, AmArg& a, 
				      unsigned int start_index) {
  if (v.valid()) {
    for (int i=start_index; i<v.size();i++) {
      switch (v[i].getType()) {
      case XmlRpcValue::TypeInt:   { a.push(AmArg((int)v[i]));    }  break;
      case XmlRpcValue::TypeDouble:{ a.push(AmArg((double)v[i])); }  break;
      case XmlRpcValue::TypeString:{ a.push(AmArg(((string)v[i]).c_str())); }  break;
	// TODO: support more types (datetime, struct, ...)
      default:     throw XmlRpcException("unsupported parameter type", 400);
      };
    }
  } 
}
开发者ID:BackupTheBerlios,项目名称:sems-svn,代码行数:14,代码来源:XMLRPC2DI.cpp


示例9: arrayFromXml

  // Array
  bool XmlRpcValue::arrayFromXml(std::string const& valueXml, int* offset)
  {
    if ( ! XmlRpcUtil::nextTagIs(DATA_TAG, valueXml, offset))
      return false;

    _type = TypeArray;
    _value.asArray = new ValueArray;
    XmlRpcValue v;
    while (v.fromXml(valueXml, offset))
      _value.asArray->push_back(v);       // copy...

    // Skip the trailing </data>
    (void) XmlRpcUtil::nextTagIs(DATA_ETAG, valueXml, offset);
    return true;
  }
开发者ID:KinKir,项目名称:codeblocks-python,代码行数:16,代码来源:XmlRpcValue.cpp


示例10: XmlRpcException

// Execute multiple calls and return the results in an array.
bool XmlRpcServerConnection::executeMulticall(const std::string& in_methodName, XmlRpcValue& params, XmlRpcValue& result)
{
	if (in_methodName != SYSTEM_MULTICALL) return false;

	// There ought to be 1 parameter, an array of structs
	if (params.size() != 1 || params[0].getType() != XmlRpcValue::TypeArray)
		throw XmlRpcException(SYSTEM_MULTICALL + ": Invalid argument (expected an array)");

	int nc = params[0].size();
	result.setSize(nc);

	for (int i=0; i<nc; ++i)
	{
		if ( ! params[0][i].hasMember(METHODNAME) ||
			! params[0][i].hasMember(PARAMS))
		{
			result[i][FAULTCODE] = -1;
			result[i][FAULTSTRING] = SYSTEM_MULTICALL +
				": Invalid argument (expected a struct with members methodName and params)";
			continue;
		}

		const std::string& methodName = params[0][i][METHODNAME];
		XmlRpcValue& methodParams = params[0][i][PARAMS];

		XmlRpcValue resultValue;
		resultValue.setSize(1);
		try
		{
			if ( ! executeMethod(methodName, methodParams, resultValue[0]) &&
				! executeMulticall(methodName, params, resultValue[0]))
			{
				result[i][FAULTCODE] = -1;
				result[i][FAULTSTRING] = methodName + ": unknown method name";
			}
			else
				result[i] = resultValue;

		}
		catch (const XmlRpcException& fault)
		{
			result[i][FAULTCODE] = fault.getCode();
			result[i][FAULTSTRING] = fault.getMessage();
		}
	}

	return true;
}
开发者ID:RTS2,项目名称:rts2,代码行数:49,代码来源:XmlRpcServerConnection.cpp


示例11: sessionExecute

void TargetAltitude::sessionExecute (XmlRpcValue& params, XmlRpcValue& result)
{
	if (params.size () != 4)
		throw XmlRpcException ("Invalid number of parameters");
	if (((int) params[0]) < 0)
		throw XmlRpcException ("Target id < 0");
	rts2db::Target *tar = createTarget ((int) params[0], Configuration::instance ()->getObserver (), Configuration::instance ()->getObservatoryAltitude ());
	if (tar == NULL)
	{
		throw XmlRpcException ("Cannot create target");
	}
	time_t tfrom = (int)params[1];
	double jd_from = ln_get_julian_from_timet (&tfrom);
	time_t tto = (int)params[2];
	double jd_to = ln_get_julian_from_timet (&tto);
	double stepsize = ((double)params[3]) / 86400;
	// test for insane request
	if ((jd_to - jd_from) / stepsize > 10000)
	{
		throw XmlRpcException ("Too many points");
	}
	int i;
	double j;
	for (i = 0, j = jd_from; j < jd_to; i++, j += stepsize)
	{
		result[i][0] = j;
		ln_hrz_posn hrz;
		tar->getAltAz (&hrz, j);
		result[i][1] = hrz.alt;
	}
}
开发者ID:shaoguangleo,项目名称:rts2,代码行数:31,代码来源:xmlapi.cpp


示例12: execute

void UserLogin::execute (struct sockaddr_in *saddr, XmlRpcValue& params, XmlRpcValue& result)
{
	if (params.size() != 2)
		throw XmlRpcException ("Invalid number of parameters");

	result = verifyUser (params[0], params[1]);
}
开发者ID:shaoguangleo,项目名称:rts2,代码行数:7,代码来源:xmlapi.cpp


示例13: cf

// Execute the named procedure on the remote server.
// Params should be an array of the arguments for the method.
// Returns true if the request was sent and a result received (although the result
// might be a fault).
bool
XmlRpcClient::execute(const char* method, XmlRpcValue const& params, XmlRpcValue& result)
{
  XmlRpcUtil::log(1, "XmlRpcClient::execute: method %s (_connectionState %d).", method, _connectionState);

  // This is not a thread-safe operation, if you want to do multithreading, use separate
  // clients for each thread. If you want to protect yourself from multiple threads
  // accessing the same client, replace this code with a real mutex.
  if (_executing)
    return false;

  _executing = true;
  ClearFlagOnExit cf(_executing);

  _sendAttempts = 0;
  _isFault = false;

  if ( ! setupConnection())
    return false;

  if ( ! generateRequest(method, params))
    return false;

  result.clear();
  double msTime = -1.0;   // Process until exit is called
  _disp.work(msTime);

  if (_connectionState != IDLE || ! parseResponse(result))
    return false;

  XmlRpcUtil::log(1, "XmlRpcClient::execute: method %s completed.", method);
  _response = "";
  return true;
}
开发者ID:shaikhkh,项目名称:fcc_files,代码行数:38,代码来源:XmlRpcClient.cpp


示例14: generateFaultResponse

void XmlRpcServerConnection::generateFaultResponse(std::string const& errorMsg, int errorCode)
{
	const char RESPONSE_1[] =
		"<?xml version=\"1.0\"?>\r\n"
		"<methodResponse><fault>\r\n\t";
	const char RESPONSE_2[] =
		"\r\n</fault></methodResponse>\r\n";

	XmlRpcValue faultStruct;
	faultStruct[FAULTCODE] = errorCode;
	faultStruct[FAULTSTRING] = errorMsg;
	std::string body = RESPONSE_1 + faultStruct.toXml() + RESPONSE_2;
	std::string header = generateHeader(body);

	_response = header + body;
}
开发者ID:RTS2,项目名称:rts2,代码行数:16,代码来源:XmlRpcServerConnection.cpp


示例15: execute

	void execute(XmlRpcValue& params, XmlRpcValue& result)
	{
		int nArgs = params.size();
		int requiredSize;
		wchar_t wFieldText[129];
		bool ShowMsg=false;

		Log(2,L"RX: %d",nArgs);

		for (int i=0; i<nArgs; i++)
		{
			int y = (int) (params[i]["Row"]);
			int x = (int) (params[i]["Column"]);
			std::string& fieldText = params[i]["Field"];
			int attribute = params[i]["Attribute"];

			requiredSize = mbstowcs(NULL, fieldText.c_str(), 0); // C4996
			if (requiredSize>127) 
				requiredSize=127;

			mbstowcs(wFieldText,fieldText.c_str(),requiredSize+1);

			//row updated?
			if (0 != wcsncmp(ScreenContent[y]+x, wFieldText, wcslen(wFieldText)))
			{
				wcsncpy(ScreenContent[y]+x, wFieldText, wcslen(wFieldText));
				Log(2,L"R:%d C:%d <%s>",y,x,wFieldText);
			}
		}
		DumpScreenContent();

		result = "OK";
	}
开发者ID:hjgode,项目名称:ITE_xml_rpc,代码行数:33,代码来源:ITEScreenWatch.cpp


示例16: if

// Convert the response xml into a result value
bool 
XmlRpcClient::parseResponse(XmlRpcValue& result)
{
  std::string r;
  _response.swap(r);

  // Parse response xml into result
  bool emptyParam;
  int offset = 0;
  if ( ! XmlRpcUtil::findTag("methodResponse",r,&offset,&emptyParam) || emptyParam)
  {
    XmlRpcUtil::error("Error in XmlRpcClient::parseResponse: Invalid response - no methodResponse. Response:\n%s", r.c_str());
    return false;
  }

  // Expect either <params><param>... or <fault>...
  if (XmlRpcUtil::nextTagIs("params",r,&offset,&emptyParam) &&
      XmlRpcUtil::nextTagIs("param",r,&offset,&emptyParam))
  {
    if (emptyParam)
    {
      result = 0; // No result?
    }
    else if (  ! result.fromXml(r, &offset))
    {
      XmlRpcUtil::error("Error in XmlRpcClient::parseResponse: Invalid response value. Response:\n%s", r.c_str());
      return false;
    }
  }
  else if (XmlRpcUtil::nextTagIs("fault",r,&offset,&emptyParam))
  {
    _isFault = true;

    if (emptyParam || ! result.fromXml(r, &offset))
    {
      result = 0; // No result?
      return false;
    }
  }
  else
  {
    XmlRpcUtil::error("Error in XmlRpcClient::parseResponse: Invalid response - no param or fault tag. Response:\n%s", r.c_str());
    return false;
  }
      
  return result.valid();
}
开发者ID:cybertux,项目名称:XMLRpcxx,代码行数:48,代码来源:XmlRpcClient.cpp


示例17: ROSCPP_LOG_DEBUG

bool XMLRPCManager::validateXmlrpcResponse(const std::string& method, XmlRpcValue &response,
                                    XmlRpcValue &payload)
{
  if (response.getType() != XmlRpcValue::TypeArray)
  {
    ROSCPP_LOG_DEBUG("XML-RPC call [%s] didn't return an array",
        method.c_str());
    return false;
  }
  if (response.size() != 2 && response.size() != 3)
  {
    ROSCPP_LOG_DEBUG("XML-RPC call [%s] didn't return a 2 or 3-element array",
        method.c_str());
    return false;
  }
  if (response[0].getType() != XmlRpcValue::TypeInt)
  {
    ROSCPP_LOG_DEBUG("XML-RPC call [%s] didn't return a int as the 1st element",
        method.c_str());
    return false;
  }
  int status_code = response[0];
  if (response[1].getType() != XmlRpcValue::TypeString)
  {
    ROSCPP_LOG_DEBUG("XML-RPC call [%s] didn't return a string as the 2nd element",
        method.c_str());
    return false;
  }
  std::string status_string = response[1];
  if (status_code != 1)
  {
    ROSCPP_LOG_DEBUG("XML-RPC call [%s] returned an error (%d): [%s]",
        method.c_str(), status_code, status_string.c_str());
    return false;
  }
  if (response.size() > 2)
  {
    payload = response[2];
  }
  else
  {
    std::string empty_array = "<value><array><data></data></array></value>";
    int offset = 0;
    payload = XmlRpcValue(empty_array, &offset);
  }
  return true;
}
开发者ID:rosmod,项目名称:rosmod-comm,代码行数:47,代码来源:rosmod_xmlrpc_manager.cpp


示例18: execute

 void execute(XmlRpcValue& params, XmlRpcValue& result)
 {
     int nArgs = params.size();
     double sum = 0.0;
     for (int i=0; i<nArgs; ++i)
         sum += double(params[i]);
     result = sum;
 }
开发者ID:Quiplit,项目名称:sems,代码行数:8,代码来源:HelloServer.cpp


示例19: execute

 void execute(XmlRpcValue& params, XmlRpcValue& result) 
 { 
      string tmp = params[0];
     vector<string> list = chat.Listar();
     for(int i = 0; i < list.size(); i++)
            result[i] = (string)list[i];
      
     cout << "Listando: " << result.size() <<  endl;
 } 
开发者ID:petroniocandido,项目名称:SD,代码行数:9,代码来源:main.cpp


示例20: TriggerValueGet

bool HmValue::TriggerValueGet()
{
	if( _sendingChannel )
	{
		XmlRpcValue value = _channel->GetValue(_valueId);
		if( value.valid() )
		{
			HandleXmlRpcEvent( value );
			return true;
		}else{
			_sendingChannel->MarkAsUndefined();
			LOG( Logger::LOG_WARNING, "Error getting value %s.%s", _channel->GetSerial().c_str(), _valueId.c_str());
			return false;
		}
	}else{
		return true;
	}
}
开发者ID:Schiiiiins,项目名称:lcu1,代码行数:18,代码来源:HmValue.cpp



注:本文中的XmlRpcValue类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ XmlSerializer类代码示例发布时间:2022-05-31
下一篇:
C++ XmlRpcServer类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap