当前位置: 首页>>代码示例>>C++>>正文


C++ TiXmlElement::Type方法代码示例

本文整理汇总了C++中TiXmlElement::Type方法的典型用法代码示例。如果您正苦于以下问题:C++ TiXmlElement::Type方法的具体用法?C++ TiXmlElement::Type怎么用?C++ TiXmlElement::Type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TiXmlElement的用法示例。


在下文中一共展示了TiXmlElement::Type方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: BBWinConfigException

void 			BBWinConfig::LoadConfiguration(const string & fileName, const string & configNameSpace, bbwinconfig_t  & config) {
	string				configName(BBWIN_CONFIG_ROOT);

	EnterCriticalSection(&m_configCriticalSection); 
	m_path = fileName;
	m_doc = new TiXmlDocument(m_path.c_str());
	if (m_doc == NULL) 
		throw BBWinConfigException("can't allocare tinyxml instance");
	bool loadOkay = m_doc->LoadFile();
	if ( !loadOkay ) {
		LeaveCriticalSection(&m_configCriticalSection);
		throw BBWinConfigException(m_doc->ErrorDesc());
	}
	TiXmlElement *root = m_doc->FirstChildElement( "configuration" );
	if ( root ) {
		TiXmlNode * nameSpaceNode = root->FirstChild( configNameSpace.c_str() );
		if ( nameSpaceNode ) {
			TiXmlElement		* elem;
			for (elem = nameSpaceNode->FirstChildElement(); elem ; elem = elem->NextSiblingElement()) {
				bbwinconfig_attr_t		config_attr;
				if (elem->Type() == TiXmlNode::ELEMENT) {
					TiXmlAttribute 			* attr;
					
					for (attr = elem->FirstAttribute(); attr; attr = attr->Next()) {
						config_attr.insert(pair< string, string >(attr->Name(), attr->Value()));
					}
				}
				config.insert(pair < string, bbwinconfig_attr_t > (elem->Value(), config_attr));
			}
		}
	}
	delete m_doc;
	m_doc = NULL;
	LeaveCriticalSection(&m_configCriticalSection);
}
开发者ID:tjyang,项目名称:bbwin,代码行数:35,代码来源:BBWinConfig.cpp

示例2: GetNodePointerByNameAll

/***********************************************************************************************************
 * 程序作者:赵进军
 * 函数功能:通过节点名获取XML中所有符合条件的节点指针
 * 参数说明:
 *    pRootEle:XML文件的根节点
 * strNodeName:需要获取的节点指针的名称
 *     retNode:获取到的符合条件的节点指针数组
 * 注意事项:在使用该函数之前 arrayIndex全局变量必须置为0
 * 修改日期:2015/12/13 13:56:00
 ***********************************************************************************************************/
bool OperationProfile_XML::GetNodePointerByNameAll(TiXmlElement* pRootEle, char*  strNodeName, TiXmlElement* retNode[])
{
	if (pRootEle == NULL)
		return false;

	if (!strcmp(strNodeName, pRootEle->Value()))																			// 假如等于节点名就自动退出
	{
		if (arrayIndex < groupNodeCount)
			retNode[arrayIndex] = pRootEle;
		else
			printf("请重新定义节点的数量");
		arrayIndex++;
		return true;
	}

	TiXmlElement* pchild = pRootEle->FirstChildElement();
	while (pchild)
	{
		int t = pchild->Type();

		if (t == TiXmlNode::TINYXML_ELEMENT)
			GetNodePointerByNameAll(pchild, strNodeName, retNode);

		pchild = pchild->NextSiblingElement();
	}

	if (NULL == retNode)
		return false;
	else
		return true;
}
开发者ID:zhjjssyf20120925,项目名称:OperationProfile,代码行数:41,代码来源:OperationProfile_XML.cpp

示例3: GetNodePointerByName

/***********************************************************************************************************
 * 程序作者:赵进军
 * 函数功能:通过节点名获取XML的节点指针
 * 参数说明:
 *    pRootEle:XML文件的根节点
 * strNodeName:需要获取的节点指针的名称
 *		  node:获取到的符合条件的节点指针
 *   nodeIndex:节点的位置
 * 注意事项:在使用该函数之前 arrayIndex全局变量必须置为0
 * 修改日期:2015/12/12 17:18:00
 ***********************************************************************************************************/
bool OperationProfile_XML::GetNodePointerByName(TiXmlElement* pRootEle, char* strNodeName, TiXmlElement* &node, int nodeIndex)
{
	if (pRootEle == NULL)
		return false;

	if (!strcmp(strNodeName, pRootEle->Value()))																			// 假如等于节点名就自动退出
	{
		if (arrayIndex == nodeIndex)
			node = pRootEle;
		arrayIndex++;
		return true;
	}

	TiXmlElement* pchild = pRootEle->FirstChildElement();
	while (pchild)
	{
		int t = pchild->Type();

		if (t == TiXmlNode::TINYXML_ELEMENT)
			GetNodePointerByName(pchild, strNodeName, node, nodeIndex);
		pchild = pchild->NextSiblingElement();
	}

	if (NULL == node)
		return false;
	else
		return true;
}
开发者ID:zhjjssyf20120925,项目名称:OperationProfile,代码行数:39,代码来源:OperationProfile_XML.cpp

示例4: XmlParseConfig

 bool XmlParseConfig(Config &c, TiXmlElement *conf)
 {
     if ( conf == NULL ) return false;
     stringstream ss;
     TiXmlElement *config = conf->FirstChildElement();
     for ( ; config; config = config->NextSiblingElement() ) {
         if ( config->Type() != TiXmlNode::TINYXML_ELEMENT ) continue;
         string configType(config->Value());
         const char *name = config->Attribute("Name");
         if ( !name ) {
             Severe("Config Name attribute missing");
             return false;
         }
         string configName(name);
         if ( configType == "Float" ) {
             double value;
             if ( !config->Attribute("Value", &value) ) {
                 ss << "Config [" << configName << "] missing value";
                 Severe(ss);
                 return false;
             }
             c.AddAttribute(configName, (float) value);
         } else if ( configType == "Int32" ) {
             int i;
             if ( !config->Attribute("Value", &i) ) {
                 ss << "Config [" << configName << "] missing value";
                 Severe(ss);
                 return false;
             }
             c.AddAttribute(configName, i);
         } else if ( configType == "Vector" ) {
             Vector vec;
             TiXmlElement *elemVec = config->FirstChildElement("Value");
             if ( !elemVec ) {
                 ss << "Config [" << configName << "] missing value";
                 Severe(ss);
                 return false;
             }
             if ( !XmlParseVector(vec, elemVec) ) return false;
             c.AddAttribute(configName, vec);
         } else if ( configType == "Bool" ) {
             int b;
             if ( !config->Attribute("Value", &b) ) {
                 ss << "Config [" << configName << "] missing value";
                 Severe(ss);
                 return false;
             }
             c.AddAttribute(configName, b != 0);
         } else {
             ss << "Unknown config type: [" << configType << "]";
             Severe(ss);
             return false;
         }
     }
     return true;
 }
开发者ID:zhaoruoxu,项目名称:lyraefx,代码行数:56,代码来源:XmlParse.cpp

示例5:

int em::EmXml::ReadRootChildAttrList( EmVecMapStr &rVecMapStr )
{
	int iResult = 0;
	rVecMapStr.clear();

	TiXmlElement *pElemRoot = m_pDoc->RootElement();
	if(pElemRoot == NULL)
	{
		return 0;
	}
	
	TiXmlElement *pElemChild = pElemRoot->FirstChildElement();
	TiXmlAttribute *pAttrChild = NULL;
	EmMapStr MapStr;
	while(true)
	{
		if(pElemChild == NULL)
		{
			break;
		}
		
		if(pElemChild->Type() != TiXmlNode::TINYXML_ELEMENT)
		{
			continue;
		}
		
		MapStr.clear();
		
		pAttrChild = pElemChild->FirstAttribute();
		while(true)
		{
			if(pAttrChild == NULL)
			{
				break;
			}
			
			MapStr[ pAttrChild->Name() ] = pAttrChild->Value();
			
			pAttrChild = pAttrChild->Next();
		}
		
		rVecMapStr.push_back(MapStr);
		pElemChild = pElemChild->NextSiblingElement();
	}
	
	iResult = rVecMapStr.size();
	
	return iResult;
}
开发者ID:lidongqiang,项目名称:FWFactoryTool,代码行数:49,代码来源:EmXml.cpp

示例6: ParseOffsets

void VersionInfoFactory::ParseOffsets(TiXmlElement * parent, VersionInfo* target, bool initial)
{
    // we parse the groups iteratively instead of recursively
    // breadcrubs acts like a makeshift stack
    // first pair entry stores the current element of that level
    // second pair entry the group object from OffsetGroup
    typedef triple< TiXmlElement *, OffsetGroup *, INVAL_TYPE> groupTriple;
    vector< groupTriple > breadcrumbs;
    {
        TiXmlElement* pEntry;
        // we get the <Offsets>, look at the children
        pEntry = parent->FirstChildElement();
        if(!pEntry)
            return;
        const char *cstr_invalid = parent->Attribute("valid");
        INVAL_TYPE parent_inval = NOT_SET;
        if(cstr_invalid)
        {
            if(strcmp(cstr_invalid,"false") == 0)
                parent_inval = IS_INVALID;
            else if(strcmp(cstr_invalid,"true") == 0)
                parent_inval = IS_VALID;
        }
        OffsetGroup * currentGroup = reinterpret_cast<OffsetGroup *> (target);
        currentGroup->setInvalid(parent_inval);
        breadcrumbs.push_back(groupTriple(pEntry,currentGroup, parent_inval));
    }

    // work variables
    OffsetGroup * currentGroup = 0;
    TiXmlElement * currentElem = 0;
    INVAL_TYPE parent_inval = NOT_SET;
    //cerr << "<Offsets>"<< endl;
    while(1)
    {
        // get current work variables
        currentElem = breadcrumbs.back().first;
        currentGroup = breadcrumbs.back().second;
        parent_inval = breadcrumbs.back().third;

        // we reached the end of the current group?
        if(!currentElem)
        {
            // go one level up
            breadcrumbs.pop_back();
            // exit if no more work
            if(breadcrumbs.empty())
            {
                break;
            }
            else
            {
                //cerr << "</group>" << endl;
                continue;
            }
        }

        if(!currentGroup)
        {
            groupTriple & gp = breadcrumbs.back();
            gp.first = gp.first->NextSiblingElement();
            continue;
        }

        // skip non-elements
        if (currentElem->Type() != TiXmlNode::ELEMENT)
        {
            groupTriple & gp = breadcrumbs.back();
            gp.first = gp.first->NextSiblingElement();
            continue;
        }

        // we have a valid current element and current group
        // get properties
        string type = currentElem->Value();
        std::transform(type.begin(), type.end(), type.begin(), ::tolower);
        const char *cstr_name = currentElem->Attribute("name");
        if(!cstr_name)
        {
            // ERROR, missing attribute
        }

        // evaluate elements
        const char *cstr_value = currentElem->Attribute("value");
        const char *cstr_invalid = currentElem->Attribute("valid");

        INVAL_TYPE child_inval = parent_inval;
        if(cstr_invalid)
        {
            if(strcmp(cstr_invalid,"false") == 0)
                child_inval = IS_INVALID;
            else if(strcmp(cstr_invalid,"true") == 0)
                child_inval = IS_VALID;
        }
        if(type == "group")
        {
            // create or get group
            OffsetGroup * og;
            if(initial)
                og = currentGroup->createGroup(cstr_name);
//.........这里部分代码省略.........
开发者ID:wisq,项目名称:dfhack,代码行数:101,代码来源:VersionInfoFactory.cpp


注:本文中的TiXmlElement::Type方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。