void FrameNetBuilder::read_relations(FrameNet &fn){ rapidxml::file<> fdoc(this->relation_file_path.c_str()); rapidxml::xml_document<> doc; doc.parse<0>(fdoc.data()); rapidxml::xml_node<>* root = doc.first_node(); for(auto fr_type = root->first_node("frameRelationType");fr_type!= nullptr;fr_type = fr_type->next_sibling("frameRelationType")){ std::string fr_type_name = fr_type->first_attribute("name")->value(); for(auto fr = fr_type->first_node("frameRelation");fr!= nullptr;fr = fr->next_sibling("frameRelation")){ std::string subFrame = fr->first_attribute("subFrameName")->value(); std::string superFrame = fr->first_attribute("superFrameName")->value(); Frame *current_frame = fn.get_frame(subFrame); if(fr_type_name == "Causative_of"||fr_type_name == "Inchoative_of"||fr_type_name == "Precedes"){ current_frame = fn.get_frame(superFrame); } for(auto fe_r =fr->first_node("FERelation");fe_r!= nullptr;fe_r = fe_r->next_sibling("FERelation")){ std::string parent = fe_r->first_attribute("superFEName")->value(); std::string child = fe_r->first_attribute("subFEName")->value(); FrameElementRelation *fr = new FrameElementRelation(parent,child,fr_type_name,superFrame,subFrame); current_frame->add_fe_relation(fr); } } } }
LexicalUnit* FrameNetBuilder::parse_lu_xml(std::string xml_path,LexicalUnit* original){ rapidxml::file<> fdoc(xml_path.c_str()); rapidxml::xml_document<> doc; doc.parse<0>(fdoc.data()); rapidxml::xml_node<>* root = doc.first_node(); std::string name = original->get_name(); //带有词性 std::string POS = original->get_pos(); std::string frame_name = original->get_frame_name(); int ID = original->get_ID(); std::string status = original->get_status(); //std::string lexeme = root->first_node("lexeme")->first_attribute("name")->value(); std::string definition = root->first_node("definition")->value(); rapidxml::xml_node<>* valence = root->first_node("valences"); std::vector<FERealization*>fe_realizations; for(auto p = valence->first_node("FERealization");p != nullptr;p = p->next_sibling("FERealization")){ fe_realizations.push_back(build_realization(p,frame_name,name)); } std::vector<Annotation*> annotations; for(auto subCorpus = root->first_node("subCorpus");subCorpus != nullptr;subCorpus = subCorpus->next_sibling("subCorpus")){ for(auto senten = subCorpus->first_node("sentence");senten != nullptr; senten = senten->next_sibling("sentence")){ annotations.push_back(build_annotation(senten)); } } original->set_definition(definition); original->set_fe_realizations(fe_realizations); original->set_annotations(annotations); return original; }
bool NFCClassModule::Load() { ////////////////////////////////////////////////////////////////////////// rapidxml::xml_document<> xDoc; char* pData = NULL; int nDataSize = 0; std::string strFile = pPluginManager->GetConfigPath() + msConfigFileName; rapidxml::file<> fdoc(strFile.c_str()); nDataSize = fdoc.size(); pData = new char[nDataSize + 1]; strncpy(pData, fdoc.data(), nDataSize); pData[nDataSize] = 0; xDoc.parse<0>(pData); ////////////////////////////////////////////////////////////////////////// //support for unlimited layer class inherits rapidxml::xml_node<>* root = xDoc.first_node(); for (rapidxml::xml_node<>* attrNode = root->first_node(); attrNode; attrNode = attrNode->next_sibling()) { Load(attrNode, NULL); } ////////////////////////////////////////////////////////////////////////// if (NULL != pData) { delete []pData; } ////////////////////////////////////////////////////////////////////////// return true; }
void CTaskSerialization::InitConfigXml() { try { if (PathFileExists(m_strXmlPath)) { if (m_bXmlLoaded == FALSE) { file<> fdoc((LPCTSTR)m_strXmlPath); m_pszXmlData = _strdup(fdoc.data()); m_Xmldoc.parse<0>(m_pszXmlData); m_bXmlLoaded = TRUE; // xml 文件只加载一次,后续都在内存操作 } } else { xml_node<>* rot = m_Xmldoc.allocate_node(rapidxml::node_pi,m_Xmldoc.allocate_string( "xml version='1.0' encoding='UTF-8'" )); m_Xmldoc.append_node(rot); m_bXmlLoaded = TRUE; } } catch (...) { LogMsg("初始化XML历史记录文件出现异常"); m_bXmlLoaded = FALSE; } }
void ReadServerErrCodeFile(std::map<uint32_t, std::map<ELanguageType, TString> >& languageServerErrCodeMap) { TString filePath = CResourceManager::GetInstance()->GetResourcePath(eRT_Language); filePath.append(_T("\\")).append("networkError.xml"); if (CFilePathTool::GetInstance()->Exists(filePath.c_str())) { rapidxml::file<> fdoc(filePath.c_str()); rapidxml::xml_document<> errCodeXML; try { errCodeXML.parse<rapidxml::parse_default>(fdoc.data()); } catch (rapidxml::parse_error err) { BEATS_ASSERT(false, _T("Load config file %s faled!/n%s/n"), "errno.xml", err.what()); } rapidxml::xml_node<>* pRootElement = errCodeXML.first_node("config"); if (pRootElement) { for (auto element = pRootElement->first_node(); element; element = element->next_sibling()) { std::map<ELanguageType, TString> curMap; curMap[eLT_Chinese] = element->first_attribute("lang_zhCN")->value(); curMap[eLT_English] = element->first_attribute("lang_enUS")->value(); languageServerErrCodeMap[_tstoi(element->first_attribute("code")->value())] = curMap; } } } }
CXmlConfig::CXmlConfig(CString strConfigFile):m_strLanguageCode(_T("0x0409")),m_bKnownLanguage(TRUE) { if(!FindFirstFileExists((LPCTSTR)strConfigFile,FALSE)) { HANDLE hFile = NULL; hFile = CreateFile(strConfigFile, READ_CONTROL, 0, NULL, CREATE_ALWAYS, 0, NULL); if (hFile != INVALID_HANDLE_VALUE) { CloseHandle(hFile); } } QueryDefaultLanguage(); m_strConfigFile = strConfigFile; try { SetLanguage(); std::wifstream configFile(m_strConfigFile,ios_base::binary,_SH_SECURE);//以安全权限方式打开 if(configFile) { //configFile.imbue(std::locale("CHS")); file<TCHAR> fdoc(configFile); TCHAR* pConfigData = m_xmlDoc.allocate_string(fdoc.data()); // 分配字符串并将Config数据复制进去 m_xmlDoc.parse<0>(pConfigData); locale::global(locale("C"));//还原全局区域设定 m_xmlRoot = m_xmlDoc.first_node(); if(0 == m_xmlRoot) { m_xmlDoc.append_node(m_xmlDoc.allocate_node(rapidxml::node_pi,m_xmlDoc.allocate_string(_T("xml version='1.0' encoding='utf-8'")))); m_xmlRoot = m_xmlDoc.allocate_node(node_element,_T("config"),_T("")); m_xmlDoc.append_node(m_xmlRoot); } configFile.close(); } else { locale::global(locale("C"));//还原全局区域设定 //LOGEX_FATAL(_T("cannot open file: ") + m_strConfigFile); throw runtime_error(string("cannot open file ")/* + filename*/); } } catch(...) { locale::global(locale("C"));//还原全局区域设定 //LOGEX_FATAL(_T("error reading stream. ")); throw runtime_error("error reading stream."); } locale::global(locale("")); //LOG_INFO(_T("ANSI CodePage: %d"), GetACP()); // LOG_INFO(_T("SystemDefaultLangID: 0x%04x"), GetSystemDefaultLangID()); }
bool NFCPluginManager::LoadPluginConfig() { rapidxml::file<> fdoc("Plugin.xml"); rapidxml::xml_document<> doc; doc.parse<0>(fdoc.data()); rapidxml::xml_node<>* pRoot = doc.first_node(); for (rapidxml::xml_node<>* pPluginNode = pRoot->first_node("Plugin"); pPluginNode; pPluginNode = pPluginNode->next_sibling("Plugin")) { const char* strPluginName = pPluginNode->first_attribute("Name")->value(); const char* strMain = pPluginNode->first_attribute("Main")->value(); mPluginNameMap.insert(PluginNameMap::value_type(strPluginName, true)); } rapidxml::xml_node<>* pPluginAppNode = pRoot->first_node("APPID"); if (!pPluginAppNode) { NFASSERT(0, "There are no App ID", __FILE__, __FUNCTION__); return false; } const char* strAppID = pPluginAppNode->first_attribute("Name")->value(); if (!strAppID) { NFASSERT(0, "There are no App ID", __FILE__, __FUNCTION__); return false; } if (!NF_StrTo(strAppID, mnAppID)) { NFASSERT(0, "App ID Convert Error", __FILE__, __FUNCTION__); return false; } rapidxml::xml_node<>* pPluginConfigPathNode = pRoot->first_node("ConfigPath"); if (!pPluginConfigPathNode) { NFASSERT(0, "There are no ConfigPath", __FILE__, __FUNCTION__); return false; } if (NULL == pPluginConfigPathNode->first_attribute("Name")) { NFASSERT(0, "There are no ConfigPath.Name", __FILE__, __FUNCTION__); return false; } mstrConfigPath = pPluginConfigPathNode->first_attribute("Name")->value(); return true; }
map<tstring,tstring> CVersionInfo::GetUpdateList(vector<tstring>& m_services) { map<tstring,tstring> updatelist; //check the remote version file in update folder file<> fdoc(m_update_ver_path.c_str()); //TiXmlDocument ver; //TiXmlDocument remote_ver; if (fdoc.size() > 0) { //TiXmlNode* root = remote_ver.RootElement(); //TiXmlElement* pver_elem = root->FirstChildElement(); xml_document<> xdoc; xdoc.parse<0>(fdoc.data()); xml_node<>* pver_elem = xdoc.first_node(); while (pver_elem) { //get ver id which > cur version //tstring cur_ver_str = pver_elem->Attribute("no"); tstring cur_ver_str = pver_elem->first_attribute("no")->value(); DWORD marj,subj,ssubj,sssubj; marj=subj=ssubj=sssubj=0; sscanf(cur_ver_str.c_str(),"%d.%d.%d.%d",&marj,&subj,&ssubj,&sssubj); CVersion cur_ver(marj,subj,ssubj,sssubj); if(cur_ver > m_local) { //TiXmlElement* pitem = pver_elem->FirstChildElement(); xml_node<>* pitem = pver_elem->first_node(); while (pitem) { tstring filepath = pitem->first_attribute("path")->value(); tstring filename = pitem->first_attribute("name")->value(); //res.push_back(filepath); updatelist[filename] = filepath; const char* pservice = pitem->first_attribute("service")->value(); if(pservice) { m_services.push_back(filename); } pitem = pitem->next_sibling(); } } pver_elem = pver_elem->next_sibling(); } } return updatelist; }
bool NFCElementModule::Load() { if (mbLoaded) { return false; } NF_SHARE_PTR<NFIClass> pLogicClass = m_pClassModule->First(); while (pLogicClass.get()) { const std::string& strInstancePath = pLogicClass->GetInstancePath(); if (strInstancePath.empty()) { pLogicClass = m_pClassModule->Next(); continue; } ////////////////////////////////////////////////////////////////////////// rapidxml::xml_document<> xDoc; char* pData = NULL; int nDataSize = 0; std::string strFile = pPluginManager->GetConfigPath() + strInstancePath; rapidxml::file<> fdoc(strFile.c_str()); nDataSize = fdoc.size(); pData = new char[nDataSize + 1]; strncpy(pData, fdoc.data(), nDataSize); pData[nDataSize] = 0; xDoc.parse<0>(pData); ////////////////////////////////////////////////////////////////////////// //support for unlimited layer class inherits rapidxml::xml_node<>* root = xDoc.first_node(); for (rapidxml::xml_node<>* attrNode = root->first_node(); attrNode; attrNode = attrNode->next_sibling()) { Load(attrNode, pLogicClass); } mbLoaded = true; ////////////////////////////////////////////////////////////////////////// if (NULL != pData) { delete []pData; } ////////////////////////////////////////////////////////////////////////// pLogicClass = m_pClassModule->Next(); } return true; }
BOOL CTaskXml::Open( LPCTSTR lpszXmlPath ) { if (m_pDoc) { delete m_pDoc; m_pDoc = NULL; } if (m_pszXmlData) { free(m_pszXmlData); m_pszXmlData = NULL; } Clear(); if (!IsAccessibleFile(lpszXmlPath)) { return FALSE; } m_sXmlPath = lpszXmlPath; file<> fdoc((LPCTSTR)m_sXmlPath); m_pszXmlData = _strdup(fdoc.data()); m_pDoc = new xml_document<>; rapidxml::xml_node<>* rot = m_pDoc->allocate_node( rapidxml::node_pi,m_pDoc->allocate_string("xml version='1.0' encoding='utf-8'")); m_pDoc->parse<0>(m_pszXmlData); m_pDoc->insert_node(m_pDoc->first_node(),rot); m_pTasksNode = m_pDoc->first_node("tasks"); if (m_pTasksNode) m_pDownLoadTasksNode = m_pTasksNode->first_node("download"); if (m_pTasksNode) m_pUpLoadTasksNode = m_pTasksNode->first_node("upload"); if (m_pTasksNode) m_pCopyTasksNode = m_pTasksNode->first_node("copy"); if ( m_pTasksNode == NULL || m_pDownLoadTasksNode == NULL || m_pUpLoadTasksNode == NULL || m_pCopyTasksNode == NULL) { Clear(); return FALSE; } return TRUE; }
Frame* FrameBuilder::build_frame(std::string xml_path){ std::vector<FrameElement*>elements; std::vector<LexicalUnit*>lexemes; std::vector<FrameRelation*>relations; std::vector<std::string>parents; std::vector<std::string>children; //read the frame.xml and analysis rapidxml::file<> fdoc(xml_path.c_str()); rapidxml::xml_document<> doc; doc.parse<0>(fdoc.data()); rapidxml::xml_node<>* root = doc.first_node(); std::string name = root->first_attribute("name")->value(); int ID = atoi(root->first_attribute("ID")->value()); //build FE for(auto node = root->first_node("FE");node!= nullptr;node = node->next_sibling("FE")){ elements.push_back(build_FE(node,name)); } //build LU for(auto node = root->first_node("lexUnit");node!= nullptr;node = node->next_sibling("lexUnit")){ lexemes.push_back(build_LU(node,name)); } //build frameRelation for(auto node = root->first_node("frameRelation");node!= nullptr;node = node->next_sibling("frameRelation")){ relations.push_back(build_FR(node,parents,children)); } //build definition,use regex to filter the html tag rapidxml::xml_node<>* def_node = root->first_node("definition"); std::string xml_text = def_node->value(); boost::regex expr{"<[^>]*>"}; std::string fmt{""}; std::string def_text = boost::regex_replace(xml_text, expr, fmt); Frame *frame = new Frame(parents,children,name,elements,lexemes,relations,xml_text,def_text,ID); return frame; }
CVersionFromXML::CVersionFromXML(const tstring &path) { file<> fdoc(path.c_str()); //TiXmlDocument ver; if(fdoc.size() > 0) { xml_document<> xdoc; xdoc.parse<0>(fdoc.data()); xml_node<>* root = xdoc.first_node(); //TiXmlNode* root = ver.RootElement(); //TiXmlElement* pver_elem = root->ToElement(); if (root && root->first_attribute("cur")) { //get ver id which > cur version tstring cur_ver_str = root->first_attribute("cur")->value(); sscanf(cur_ver_str.c_str(),"%d.%d.%d.%d",&m_marj,&m_subj,&m_ssubj,&m_sssubj); } } }
bool NFCElementInfoModule::LoadSceneInfo(const std::string& strFileName, const std::string& strClassName) { rapidxml::file<> fdoc(strFileName.c_str()); //std::cout << fdoc.data() << std::endl; rapidxml::xml_document<> doc; doc.parse<0>(fdoc.data()); NF_SHARE_PTR<NFILogicClass> pLogicClass = m_pLogicClassModule->GetElement(strClassName.c_str()); if (pLogicClass.get()) { //support for unlimited layer class inherits rapidxml::xml_node<>* root = doc.first_node(); for (rapidxml::xml_node<>* attrNode = root->first_node(); attrNode; attrNode = attrNode->next_sibling()) { Load(attrNode, pLogicClass); } } else { std::cout << "error load scene info failed, name is:" << strClassName << " file name is :" << strFileName << std::endl; } return true; }
void CLanguageManager::LoadFromFile(ELanguageType language) { #ifdef EDITOR_MODE BEYONDENGINE_UNUSED_PARAM(language); m_languageMap.clear(); TString filePath = CResourceManager::GetInstance()->GetResourcePath(eRT_Resource); filePath.append(_T("/LanguageConfig.xml")); if (CFilePathTool::GetInstance()->Exists(filePath.c_str())) { rapidxml::file<> fdoc(filePath.c_str()); rapidxml::xml_document<> doc; try { doc.parse<rapidxml::parse_default>(fdoc.data()); doc.m_pszFilePath = filePath.c_str(); } catch (rapidxml::parse_error &e) { TCHAR info[MAX_PATH]; _stprintf(info, _T("Load file :%s Failed! error :%s"), filePath.c_str(), e.what()); MessageBox(BEYONDENGINE_HWND, info, _T("Load File Failed"), MB_OK | MB_ICONERROR); } uint32_t uCounter = 0; rapidxml::xml_node<>* pRootNode = doc.first_node("Language"); rapidxml::xml_node<>* pLanguageNode = pRootNode->first_node("LanguageNode"); while (pLanguageNode != nullptr) { uCounter++; TString strEnum = pLanguageNode->first_attribute("Enum")->value(); BEATS_ASSERT(!strEnum.empty()); if (pLanguageNode->first_attribute("Tag")) { TString strTag = pLanguageNode->first_attribute("Tag")->value(); m_languageTagMap[strEnum] = strTag; } BEATS_ASSERT(m_languageMap.find(strEnum) == m_languageMap.end()); std::map<ELanguageType, TString>& curMap = m_languageMap[strEnum]; rapidxml::xml_node<>* pLanguageValueNode = pLanguageNode->first_node(); while (pLanguageValueNode != nullptr) { TString languageTypeStr = pLanguageValueNode->name(); ELanguageType languageType = eLT_Count; for (int j = 0; j < eLT_Count; ++j) { if (pszLanguageTypeString[j] == languageTypeStr) { languageType = (ELanguageType)j; break; } } BEATS_ASSERT(curMap.find(languageType) == curMap.end()); const TCHAR* pszValue = pLanguageValueNode->first_attribute("Value")->value(); BEATS_ASSERT(_tcslen(pszValue) > 0); curMap[languageType] = pszValue; pLanguageValueNode = pLanguageValueNode->next_sibling(); } pLanguageNode = pLanguageNode->next_sibling(); } BEATS_ASSERT((uint32_t)_ttoi(pRootNode->first_attribute("Count")->value()) == uCounter); } #else TString filePath = CResourceManager::GetInstance()->GetResourcePath(eRT_Language); filePath.append(_T("/")).append(pszLanguageTypeString[language]).append(_T(".bin")); bool bFindLanguageFile = CFilePathTool::GetInstance()->Exists(filePath.c_str()); BEATS_ASSERT(bFindLanguageFile, "Can't Find language file %s", filePath.c_str()); if (bFindLanguageFile) { int count = 0; CSerializer tmp(filePath.c_str()); tmp >> count; m_texts.clear(); for (int i = 0; i < count; ++i) { ELanguageTextType textId = (ELanguageTextType)i; std::string strValue; tmp >> strValue; m_texts.emplace(textId, strValue); } tmp >> count; for (int i = 0; i < count; ++i) { uint32_t key; tmp >> key; BEATS_ASSERT(m_texts.find((ELanguageTextType)key) == m_texts.end()); tmp >> m_texts[(ELanguageTextType)key]; } } #endif }
bool NFCClassModule::AddClassInclude(const char* pstrClassFilePath, NF_SHARE_PTR<NFIClass> pClass) { if (pClass->Find(pstrClassFilePath)) { return false; } ////////////////////////////////////////////////////////////////////////// rapidxml::xml_document<> xDoc; char* pData = NULL; int nDataSize = 0; std::string strFile = pPluginManager->GetConfigPath() + pstrClassFilePath; rapidxml::file<> fdoc(strFile.c_str()); nDataSize = fdoc.size(); pData = new char[nDataSize + 1]; strncpy(pData, fdoc.data(), nDataSize); pData[nDataSize] = 0; xDoc.parse<0>(pData); ////////////////////////////////////////////////////////////////////////// //support for unlimited layer class inherits rapidxml::xml_node<>* root = xDoc.first_node(); rapidxml::xml_node<>* pRropertyRootNode = root->first_node("Propertys"); if (pRropertyRootNode) { AddPropertys(pRropertyRootNode, pClass); } ////////////////////////////////////////////////////////////////////////// //and record rapidxml::xml_node<>* pRecordRootNode = root->first_node("Records"); if (pRecordRootNode) { AddRecords(pRecordRootNode, pClass); } rapidxml::xml_node<>* pComponentRootNode = root->first_node("Components"); if (pComponentRootNode) { AddComponents(pComponentRootNode, pClass); } //pClass->mvIncludeFile.push_back( pstrClassFilePath ); //and include file rapidxml::xml_node<>* pIncludeRootNode = root->first_node("Includes"); if (pIncludeRootNode) { for (rapidxml::xml_node<>* includeNode = pIncludeRootNode->first_node(); includeNode; includeNode = includeNode->next_sibling()) { const char* pstrIncludeFile = includeNode->first_attribute("Id")->value(); //std::vector<std::string>::iterator it = std::find( pClass->mvIncludeFile.begin(), pClass->mvIncludeFile..end(), pstrIncludeFile ); if (AddClassInclude(pstrIncludeFile, pClass)) { pClass->Add(pstrIncludeFile); } } } ////////////////////////////////////////////////////////////////////////// if (NULL != pData) { delete []pData; } ////////////////////////////////////////////////////////////////////////// return true; }
//version int DownLoader::AnalyzeVersion(char * szVersionFileName,std::string &fileApp) { std::string strFileName = szVersionFileName; if (DownLoadHelper::Access(szVersionFileName,0) == 0) { } else { //去除old int nPos = strFileName.rfind("_old"); if (nPos != std::string::npos) { strFileName.replace(nPos,4,""); } if (DownLoadHelper::Access(strFileName.c_str(),0) != 0) { return 0; } } if (!strFileName.empty()) { //是否存在 //存在 try { rapidxml::file<> fdoc(strFileName.c_str()); rapidxml::xml_document<> doc; doc.parse<0>(fdoc.data()); //解析 rapidxml::xml_node<> *pRoot = doc.first_node(); //是否有节点 if (pRoot == NULL) { return 0; } else { int nVersion = 0; rapidxml::xml_node<> *pNode = pRoot->first_node("app_version"); if (pNode) { nVersion = atoi(pNode->value()); } pNode = pRoot->first_node("app_name"); if (pNode) { fileApp = pNode->value(); } return nVersion; } } catch (std::exception e) { printf("parse error:%s\n",e.what()); } catch(...) { printf("parse error"); } } return 0; }
void CComponentProxyManager::LoadFile(uint32_t uFileId, std::vector<CComponentBase*>* pComponentContainer) { const TString& strFilePath = m_pProject->GetComponentFileName(uFileId); BEATS_ASSERT(strFilePath.length() > 0); if (CFilePathTool::GetInstance()->Exists(strFilePath.c_str())) { rapidxml::file<> fdoc(strFilePath.c_str()); rapidxml::xml_document<> doc; try { doc.parse<rapidxml::parse_default>(fdoc.data()); doc.m_pszFilePath = strFilePath.c_str(); } catch (rapidxml::parse_error &e) { TCHAR info[MAX_PATH]; _stprintf(info, _T("Load file :%s Failed! error :%s"), strFilePath.c_str(), e.what()); MessageBox(BEYONDENGINE_HWND, info, _T("Load File Failed"), MB_OK | MB_ICONERROR); } BEATS_ASSERT(std::find(m_loadedFiles.begin(), m_loadedFiles.end(), uFileId) == m_loadedFiles.end()); m_loadedFiles.push_back(uFileId); rapidxml::xml_node<>* pRootElement = doc.first_node("Root"); rapidxml::xml_node<>* pComponentListNode = pRootElement->first_node("Components"); if (pComponentListNode != NULL) { bool bRestoreLoadingPhase = CComponentInstanceManager::GetInstance()->IsInLoadingPhase(); CComponentInstanceManager::GetInstance()->SetLoadPhaseFlag(true); std::vector<CComponentProxy*> loadedProxyList; rapidxml::xml_node<>* pComponentElement = pComponentListNode->first_node("Component"); while (pComponentElement != NULL) { const char* pGuidStr = pComponentElement->first_attribute("GUID")->value(); char* pStopPos = NULL; int guid = strtoul(pGuidStr, &pStopPos, 16); BEATS_ASSERT(*pStopPos == 0, _T("Guid value %s is not a 0x value at file %s."), pGuidStr, strFilePath.c_str()); if (GetComponentTemplate(guid) == NULL) { CComponentProxyManager::GetInstance()->GetRefreshFileList().insert(uFileId); BEATS_ASSERT(false, _T("Can't create component with \nGUID 0x%x\nName %s\nFile id:%d Name:%s\nHave you removed this component class?"), guid, pComponentElement->first_attribute("Name")->value(), uFileId, strFilePath.c_str()); } else { rapidxml::xml_node<>* pInstanceElement = pComponentElement->first_node(); while (pInstanceElement != NULL) { int id = atoi(pInstanceElement->first_attribute("Id")->value()); BEATS_ASSERT(id != -1); CComponentProxy* pComponentProxy = NULL; if (strcmp(pInstanceElement->name(), "Instance") == 0) { pComponentProxy = down_cast<CComponentProxy*>(CreateComponent(guid, false, false, id, false, NULL, false)); } pComponentProxy->LoadFromXML(pInstanceElement); loadedProxyList.push_back(pComponentProxy); if (pComponentContainer != nullptr) { pComponentContainer->push_back(pComponentProxy); } pInstanceElement = pInstanceElement->next_sibling(); } } pComponentElement = pComponentElement->next_sibling("Component"); } ResolveDependency(); CComponentInstanceManager::GetInstance()->SetLoadPhaseFlag(bRestoreLoadingPhase); if (!CComponentProxyManager::GetInstance()->IsExporting()) { // Call component proxy's initialize means we have sync all value to host component, so we call host component's load function. for (size_t i = 0; i < loadedProxyList.size(); ++i) { loadedProxyList[i]->Initialize(); } for (size_t i = 0; i < loadedProxyList.size(); ++i) { CComponentInstance* pHostComponent = static_cast<CComponentProxy*>(loadedProxyList[i])->GetHostComponent(); if (pHostComponent != nullptr) { pHostComponent->Load(); } else { BEATS_ASSERT(m_bCreateInstanceWithProxy == false, "Only when m_bCreateInstanceWithProxy is set to false, we can't get the host component"); } } } } } }