当前位置: 首页>>代码示例>>C++>>正文


C++ XmlRpcValue::getType方法代码示例

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


在下文中一共展示了XmlRpcValue::getType方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例4: sessionExecute

void RecordsValues::sessionExecute (XmlRpcValue& params, XmlRpcValue& result)
{
	if (params.getType () != XmlRpcValue::TypeInvalid)
		throw XmlRpcException ("Invalid number of parameters");
	try
	{
		rts2db::RecvalsSet recvals = rts2db::RecvalsSet ();
		int i = 0;
		time_t t;
		recvals.load ();
		for (rts2db::RecvalsSet::iterator iter = recvals.begin (); iter != recvals.end (); iter++)
		{
			rts2db::Recval rv = iter->second;
			XmlRpcValue res;
			res["id"] = rv.getId ();
			res["device"] = rv.getDevice ();
			res["value_name"] = rv.getValueName ();
			res["value_type"] = rv.getType ();
			t = rv.getFrom ();
			res["from"] = XmlRpcValue (gmtime (&t));
			t = rv.getTo ();
			res["to"] = XmlRpcValue (gmtime (&t));
			result[i++] = res;
		}
	}
	catch (rts2db::SqlError err)
	{
		throw XmlRpcException (err.what ());
	}
}
开发者ID:shaoguangleo,项目名称:rts2,代码行数:30,代码来源:xmlapi.cpp

示例5: HandleXmlRpcEvent

void HmValue::HandleXmlRpcEvent( XmlRpcValue& value )
{
	LOG( Logger::LOG_DEBUG, "HmValue %s.%s=%s", _channel->GetSerial().c_str(), _valueId.c_str(), value.toText().c_str());
	if( _sendingChannel )
	{
		if( value.getType() == XmlRpcValue::TypeInt )
		{
			_sendingChannel->SetValue( (int&)value );
		}else if( value.getType() == XmlRpcValue::TypeDouble )
		{
			_sendingChannel->SetValue( (unsigned long)(((double&)value) * _floatScale) );
		}else if( value.getType() == XmlRpcValue::TypeBoolean )
		{
			_sendingChannel->SetValue( ((bool&)value) != _boolInvert ? 1 : 0 );
		}else{
			LOG( Logger::LOG_WARNING, "Unsupported type of value %s handling XmlRpc event", value.toText().c_str());
		}
	}else{
		LOG( Logger::LOG_WARNING, "No IcChannel defined handling XmlRpc event");
	}
}
开发者ID:Schiiiiins,项目名称:lcu1,代码行数:21,代码来源:HmValue.cpp

示例6: validateXmlrpcResponse

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

示例7: validateXmlrpcResponse

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() != 3)
  {
    ROSCPP_LOG_DEBUG("XML-RPC call [%s] didn't return a 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;
  }
  payload = response[2];
  return true;
}
开发者ID:robotambassador,项目名称:robot-ambassadors,代码行数:38,代码来源:xmlrpc_manager.cpp

示例8:

std::vector<std::string> ImageMultiplexerNode::GetMachineNames(void)
{
  std::vector<std::string> names;

  XmlRpcValue machines;
  if (m_node.getParam("machines", machines) && machines.getType() == XmlRpcValue::TypeStruct)
  {
    for (XmlRpcValue::ValueStruct::const_iterator it = machines.begin(); it != machines.end(); ++it)
    {
      const std::string& strComputer = it->first;
      const XmlRpcValue& properties = it->second;

      if (properties.getType() == XmlRpcValue::TypeStruct)
      {
        // Only get machines with cameras attached
        bool bHasCamera = false;
        for (XmlRpcValue::ValueStruct::const_iterator it2 = const_cast<XmlRpcValue&>(properties).begin();
            it2 != const_cast<XmlRpcValue&>(properties).end();
            ++it2)
        {
          const std::string& strProperty = it2->first;
          const XmlRpcValue& value = it->second;
          if (strProperty == "camera" && value.getType() == XmlRpcValue::TypeString)
          {
            bHasCamera = true;
            break;
          }
        }
        if (bHasCamera)
          names.push_back(it->first);
      }
    }
  }

  return names;
}
开发者ID:kineticgar,项目名称:sexy_jarvis,代码行数:36,代码来源:ImageMultiplexerNode.cpp

示例9: toValue

Value toValue(XmlRpcValue& v, bool outer)
{
    int t = v.getType();
    switch (t) {
    case XmlRpcValue::TypeInt:
        return Value((int)v);
        break;
    case XmlRpcValue::TypeDouble:
        return Value((double)v);
        break;
    case XmlRpcValue::TypeString:
        {
            string s = (string)v;
            if (s.length()==0 || s[0]!='[') {
                return Value(s);
            } else {
                Value v;
                v.fromString(s.c_str());
                return v;
            }
        }
        break;
    case XmlRpcValue::TypeArray:
        {
            Value vbot;
            Bottle *bot = vbot.asList();
            for (int i=0; i<v.size(); i++) {
                XmlRpcValue& v2 = v[i];
                if (v2.getType()!=XmlRpcValue::TypeInvalid) {
                    Value v = toValue(v2,false);
                    if (i==0) {
                        std::string tag = v.asString();
                        if (tag=="list"||tag=="dict") {
                            if (!outer) {
                                bot->addString("list");
                            }
                        }
                    }
                    bot->add(v);
                }
            }
            return vbot;
        }
        break;
    case XmlRpcValue::TypeStruct:
        {
            Value vbot;
            Bottle *bot = vbot.asList();
            XmlRpcValue::ValueStruct& vals = v;
            bot->addString("dict");
            for (auto& val : vals) {
                XmlRpcValue& v2 = val.second;
                Bottle& sub = bot->addList();
                sub.addString(val.first.c_str());
                if (v2.getType()!=XmlRpcValue::TypeInvalid) {
                    sub.add(toValue(v2,false));
                }
            }
            return vbot;
        }
        break;
    case XmlRpcValue::TypeInvalid:
        return Value::getNullValue();
        break;
    }
    //printf("Skipping %d\n", t);
    return Value("(type not supported yet out of laziness)");
}
开发者ID:ale-git,项目名称:yarp,代码行数:68,代码来源:XmlRpcStream.cpp


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