本文整理汇总了C++中XmlRpcValue::fromXml方法的典型用法代码示例。如果您正苦于以下问题:C++ XmlRpcValue::fromXml方法的具体用法?C++ XmlRpcValue::fromXml怎么用?C++ XmlRpcValue::fromXml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlRpcValue
的用法示例。
在下文中一共展示了XmlRpcValue::fromXml方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// 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();
}
示例2: 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();
}
示例3: 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;
}