XN_C_API XnStatus xnContextRunXmlScriptFromFile(XnContext* pContext, const XnChar* strFileName, XnEnumerationErrors* pErrors) { XnStatus nRetVal = XN_STATUS_OK; TiXmlDocument doc; nRetVal = xnXmlLoadDocument(doc, strFileName); printf("XnXMLConfig.xnContextRunXmlScriptFromFileL: Load document\n"); XN_IS_STATUS_OK(nRetVal); TiXmlElement* pRootElem = doc.RootElement(); if (pRootElem != NULL) { printf("XnXMLConfig.xnContextRunXmlScriptFromFile: call xnLoadLicednsesFromXML\n"); nRetVal = xnLoadLicensesFromXml(pContext, pRootElem); XN_IS_STATUS_OK(nRetVal); printf("XnXMLConfig.xnContextRunXmlScriptFromFile: Loaded licenses.\n"); printf("XnXMLConfig.xnContextRunXmlScriptFromFile: call xnConfigureCreateNodes()\n"); nRetVal = xnConfigureCreateNodes(pContext, pRootElem, pErrors); printf("XnXMLConfig.xnContextRunXmlScriptFromFile: called xnConfigureCreateNodes()\n"); XN_IS_STATUS_OK(nRetVal); } else { printf("Porting to mac, cannot load xml document: %s", strFileName); } return (XN_STATUS_OK); }
XnStatus loadLicensesFile(TiXmlDocument& doc) { XnStatus nRetVal = XN_STATUS_OK; XnChar strFileName[XN_FILE_MAX_PATH]; nRetVal = resolveLicensesFile(strFileName, XN_FILE_MAX_PATH); XN_IS_STATUS_OK(nRetVal); XnBool bDoesExist = FALSE; nRetVal = xnOSDoesFileExist(strFileName, &bDoesExist); XN_IS_STATUS_OK(nRetVal); if (bDoesExist) { nRetVal = xnXmlLoadDocument(doc, strFileName); XN_IS_STATUS_OK(nRetVal); } else { TiXmlElement root(XN_XML_LICENSES_ROOT); doc.InsertEndChild(root); doc.SaveFile(strFileName); } return (XN_STATUS_OK); }
XN_C_API XnStatus xnContextRunXmlScriptFromFile(XnContext* pContext, const XnChar* strFileName, XnEnumerationErrors* pErrors) { XnStatus nRetVal = XN_STATUS_OK; TiXmlDocument doc; nRetVal = xnXmlLoadDocument(doc, strFileName); XN_IS_STATUS_OK(nRetVal); return RunXmlScriptImpl(pContext, &doc, pErrors); }
XnStatus XnXmlScriptNode::LoadScriptFromFile(const XnChar* strFileName) { return xnXmlLoadDocument(m_doc, strFileName); }
XN_C_API XnStatus xnLogInitFromXmlFile(const XnChar* strFileName) { XnStatus nRetVal = XN_STATUS_OK; nRetVal = xnLogInitSystem(); XN_IS_STATUS_OK(nRetVal); TiXmlDocument doc; nRetVal = xnXmlLoadDocument(doc, strFileName); XN_IS_STATUS_OK(nRetVal); TiXmlElement* pRootElem = doc.RootElement(); if (pRootElem != NULL) { TiXmlElement* pLog = pRootElem->FirstChildElement("Log"); if (pLog != NULL) { XnBool bOn; // configure filters TiXmlElement* pLogLevel = pLog->FirstChildElement("LogLevel"); if (pLogLevel != NULL) { XnInt nValue; nRetVal = xnXmlReadIntAttribute(pLogLevel, "value", &nValue); XN_IS_STATUS_OK(nRetVal); nRetVal = xnLogSetSeverityFilter((XnLogSeverity)nValue); XN_IS_STATUS_OK(nRetVal); } TiXmlElement* pMasks = pLog->FirstChildElement("Masks"); if (pMasks != NULL) { TiXmlElement* pMask = pMasks->FirstChildElement("Mask"); while (pMask != NULL) { const XnChar* strName; nRetVal = xnXmlReadStringAttribute(pMask, "name", &strName); XN_IS_STATUS_OK(nRetVal); nRetVal = xnXmlReadBoolAttribute(pMask, "on", &bOn); XN_IS_STATUS_OK(nRetVal); nRetVal = xnLogSetMaskState(strName, bOn); XN_IS_STATUS_OK(nRetVal); pMask = pMask->NextSiblingElement("Mask"); } } // configure writers if (pLog->Attribute("writeToConsole")) { nRetVal = xnXmlReadBoolAttribute(pLog, "writeToConsole", &bOn); XN_IS_STATUS_OK(nRetVal); nRetVal = xnLogSetConsoleOutput(bOn); XN_IS_STATUS_OK(nRetVal); } if (pLog->Attribute("writeToFile")) { nRetVal = xnXmlReadBoolAttribute(pLog, "writeToFile", &bOn); XN_IS_STATUS_OK(nRetVal); nRetVal = xnLogSetFileOutput(bOn); XN_IS_STATUS_OK(nRetVal); } if (pLog->Attribute("writeLineInfo")) { nRetVal = xnXmlReadBoolAttribute(pLog, "writeLineInfo", &bOn); XN_IS_STATUS_OK(nRetVal); nRetVal = xnLogSetLineInfo(bOn); XN_IS_STATUS_OK(nRetVal); } // Dumps TiXmlElement* pDumps = pLog->FirstChildElement("Dumps"); if (pDumps != NULL) { TiXmlElement* pDump = pDumps->FirstChildElement("Dump"); while (pDump != NULL) { const XnChar* strName; nRetVal = xnXmlReadStringAttribute(pDump, "name", &strName); XN_IS_STATUS_OK(nRetVal); nRetVal = xnXmlReadBoolAttribute(pDump, "on", &bOn); XN_IS_STATUS_OK(nRetVal); nRetVal = xnDumpSetMaskState(strName, bOn); XN_IS_STATUS_OK(nRetVal); pDump = pDump->NextSiblingElement("Dump"); } } } } return (XN_STATUS_OK); }