示例#1
0
bool
VR_VoiceBoxAppsXml::GetVBTXml(const std::string& xml,
    VoiceVector<std::string>::type& messages
)
{
    if (xml.empty()) {
        return false;
    }

    pugi::xml_document doc;
    if (!doc.load(xml.c_str())) {
        return false;
    }

    // Extract the tag:"Mesage" nodes
    bool bFound = false;
    pugi::xml_node csvrNodes = doc.child("event").child("CSVR");
    for (pugi::xml_node_iterator it = csvrNodes.begin(); it != csvrNodes.end(); ++it) {
        std::string strTag = it->name();
        if ("Message" == strTag) {
            std::ostringstream oss;
            it->print(oss);
            messages.push_back(oss.str());
            bFound = true;   
        }
    }
 
    return bFound;
}
bool 
VR_VoiceBoxEventSink::GetActionParameter(
    IVECIParsedMessage *pcMsg, 
    VoiceVector<NodeInfo>::type& vecActionParameter
)
{
    vecActionParameter.clear();

    if (NULL == pcMsg) {
        return false;
    }

    CVECIPtr<IVECIParameterSet> parmeterSet;
    m_client.CreateParameterSet(&parmeterSet);

    pcMsg->GetActionParameters(&parmeterSet);
    VBT_ULONG uSize;
    if (NULL == parmeterSet) {
        return false;
    }

    parmeterSet->GetSize(&uSize);
    CVECIOutStr strOut;
    VBT_STR strVBTValue; 
    std::string strName = "";
    std::string strValue = "";
    NodeInfo actionNode;

    for (VBT_ULONG uIndex = 0; uIndex < uSize; ++uIndex) {
        parmeterSet->GetParameter(uIndex, AttribName, &strOut);
        strVBTValue = strOut.Get();
        if (NULL == strVBTValue) {
            continue;
        }
        strName = strVBTValue;

        actionNode.strName = strName;
        parmeterSet->GetParameter(uIndex, AttribValue, &strOut);
        strVBTValue = strOut.Get();
        if (NULL == strVBTValue) {
            strValue = "";
        }
        else {
            strValue = strVBTValue;
        }
        
        actionNode.strValue = strValue;

        vecActionParameter.push_back(actionNode);
    }

    return true;
}