BOOL PluginOILFilter::GetXPFBOOL(xmlNodePtr pNode, LPTSTR pAttrName, XPFBOOL* pbValue) { XPFBOOL bValue = XPFB_UNKNOWN; if (pNode) { wxString strAttrName(pAttrName); wxCharBuffer buf = strAttrName.mb_str(wxConvUTF8); // buf will remain allocated in this scope wxString str = CXMLUtils::ConvertToWXString(xmlGetProp(pNode, (xmlChar*)buf.data())); if (!str.IsEmpty()) { if (str == _T("true")) { bValue = XPFB_TRUE; } else if (str == _T("false")) { bValue = XPFB_FALSE; } else { ERROR1(FALSE, _R(IDE_XPF_BADXML_UNEXPECTED_BOOLVALUE)); } } } else { ERROR1(FALSE, _R(IDE_XPF_BADXML_NULLNODE)); } *pbValue = bValue; return TRUE; }
int CLogObjectLIN::Der_SetConfigData(xmlNodePtr pNodePtr) { int nResult = S_OK; SFILTERAPPLIED_LIN sFilterApplied; CStringArray omStrFilters; std::map<std::string, int> mapFilters; if (S_OK == sFilterApplied.nSetXMLConfigData(pNodePtr->doc, LIN)) { while(pNodePtr != nullptr) //TODO:Move To Utils { if ( pNodePtr->xmlChildrenNode != nullptr ) { if ((!xmlStrcmp(pNodePtr->name, (const xmlChar*)"Filter"))) { int nEnabled = 1; xmlAttrPtr pAttr = pNodePtr->properties; while (pAttr) { // walk through all the attributes and find the required one if (pAttr->type == XML_ATTRIBUTE_NODE) { std::string strAttrName((char*)pAttr->name); if ((strAttrName == "IsEnabled") ) { nEnabled = atoi((char*)pAttr->children->content); break; // found } } pAttr = pAttr->next; } xmlChar* key = xmlNodeListGetString(pNodePtr->doc, pNodePtr->xmlChildrenNode, 1); if(nullptr != key) { mapFilters[(char*)key] = nEnabled; xmlFree(key); } } } pNodePtr = pNodePtr->next; } //sFilterApplied.nGetFiltersFromName(m_sFilterApplied, omStrFilters); sFilterApplied.nGetFiltersFromName(m_sFilterApplied, mapFilters); } return nResult; }
BOOL PluginOILFilter::GetXPFProp(xmlNodePtr pNode, LPTSTR pAttrName, PropMapEntry aMap[], XPFProp* pValue) { XPFProp Value = XPFP_UNKNOWN; if (pNode) { wxString strAttrName(pAttrName); wxCharBuffer buf = strAttrName.mb_str(wxConvUTF8); // buf will remain allocated in this scope wxString str = CXMLUtils::ConvertToWXString(xmlGetProp(pNode, (xmlChar*)buf.data())); if (!str.IsEmpty()) { // Loop through the map until we find it or the NULL indicating the end INT32 Index = 0; while (aMap[Index].pName) { if (str == aMap[Index].pName) { Value = aMap[Index].Value; break; } Index++; } if (Value == XPFP_UNKNOWN) { ERROR1(FALSE, _R(IDE_XPF_BADXML_UNEXPECTED_PROPVALUE)); } } } else { ERROR1(FALSE, _R(IDE_XPF_BADXML_NULLNODE)); } *pValue = Value; return TRUE; }