- struct TypeConfig
- {
- TypeConfig(TiXmlElement* _e, const char* filename):e(_e),xmlFileName(filename)
- {
- }
- bool init()
- {
- TiXmlElement* p_Config = e->FirstChildElement("_config");
- if(!p_Config)
- {
- printf("未定义_config节点。\\n");
- return false;
- }
- TiXmlElement* pConfig = p_Config->FirstChildElement();
- while(pConfig)
- {
- TiXmlAttribute* pAtt = pConfig->FirstAttribute();
- if(pAtt)
- {
- std::vector<std::string> nodecontainers;
- SplitStr splitStr(pAtt->Value());
- splitStr.split(nodecontainers);
- if(!strncmp(pAtt->Name(), "node", 10))
- {
- for(std::vector<std::string>::iterator it = nodecontainers.begin();
- it != nodecontainers.end(); ++it)
- {
- containerList[*it] = pConfig->Value();
- //printf("节点:%s,存放容器:%s\\n", (*it).c_str(), pConfig->Value());
- }
- }else if(!strncmp(pAtt->Name(), "prop", 10))
- {
- for(std::vector<std::string>::iterator it = nodecontainers.begin();
- it != nodecontainers.end(); ++it)
- {
- typeList[*it] = pConfig->Value();
- //printf("属性:%s,类型:%s\\n", (*it).c_str(), pConfig->Value());
- }
- }
- }
- pConfig = pConfig->NextSiblingElement();
- }
- return true;
- }
- //该片段来自于http://www.codesnippet.cn/detail/100320148952.html
来源: http://www.codesnippet.cn/detail/100320148952.html