bool WizXmlRpcResultFromXml(CWizXMLDocument& doc, CWizXmlRpcValue** ppRet) { CWizXMLNode nodeMethodResponse; doc.FindChildNode("methodResponse", nodeMethodResponse); if (nodeMethodResponse.isNull()) { TOLOG("Failed to get methodResponse node!"); return false; } CWizXMLNode nodeTest; if (!nodeMethodResponse.GetFirstChildNode(nodeTest)) { TOLOG("Failed to get methodResponse child node!"); return false; } CString strTestName = nodeTest.GetName(); if (0 == strTestName.CompareNoCase("params")) { CWizXMLNode nodeParamValue; nodeTest.FindNodeByPath("param/value", nodeParamValue); if (nodeParamValue.isNull()) { TOLOG("Failed to get param value node of params!"); return false; } return WizXmlRpcValueFromXml(nodeParamValue, ppRet); } else if (0 == strTestName.CompareNoCase("fault")) { CWizXMLNode nodeFaultValue; nodeTest.FindChildNode(_T("value"), nodeFaultValue); if (nodeFaultValue.isNull()) { TOLOG("Failed to get fault value node!"); return false; } CWizXmlRpcFaultValue* pFault = new CWizXmlRpcFaultValue(); pFault->Read(nodeFaultValue); *ppRet = pFault; return true; } else { TOLOG1("Unknown response node name: %1", strTestName); return false; } }
bool CWizXmlRpcStructValue::Read(CWizXMLNode& nodeValue) { CWizXMLNode nodeStruct; if (!nodeValue.FindChildNode(_T("struct"), nodeStruct)) { TOLOG(_T("Failed to get struct node!")); return FALSE; } // std::deque<CWizXMLNode> arrayMember; nodeStruct.GetAllChildNodes(arrayMember); // for (std::deque<CWizXMLNode>::iterator it = arrayMember.begin(); it != arrayMember.end(); it++) { CWizXMLNode& nodeMember = *it; // CString strName; if (!nodeMember.GetChildNodeText(_T("name"), strName)) { TOLOG(_T("Failed to get struct member name!")); return FALSE; } // CWizXMLNode nodeMemberValue; if (!nodeMember.FindChildNode(_T("value"), nodeMemberValue)) { TOLOG(_T("Failed to get struct member value!")); return FALSE; } // CWizXmlRpcValue* pMemberValue = NULL; if (!WizXmlRpcValueFromXml(nodeMemberValue, &pMemberValue)) { TOLOG(_T("Failed to load struct member value from node!")); return FALSE; } // ATLASSERT(pMemberValue); // AddValue(strName, pMemberValue); } // return TRUE; }
bool CWizXmlRpcStructValue::Read(CWizXMLNode& nodeValue) { CWizXMLNode nodeStruct; if (!nodeValue.FindChildNode("struct", nodeStruct)) { TOLOG("Failed to get struct node!"); return false; } std::deque<CWizXMLNode> arrayMember; nodeStruct.GetAllChildNodes(arrayMember); std::deque<CWizXMLNode>::iterator it; for (it = arrayMember.begin(); it != arrayMember.end(); it++) { CWizXMLNode& nodeMember = *it; QString strName; if (!nodeMember.GetChildNodeText("name", strName)) { TOLOG("Failed to get struct member name!"); return false; } CWizXMLNode nodeMemberValue; if (!nodeMember.FindChildNode("value", nodeMemberValue)) { TOLOG("Failed to get struct member value!"); return false; } CWizXmlRpcValue* pMemberValue = NULL; if (!WizXmlRpcValueFromXml(nodeMemberValue, &pMemberValue)) { TOLOG("Failed to load struct member value from node!"); return false; } Q_ASSERT(pMemberValue); AddValue(strName, pMemberValue); } return true; }