• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ TiXmlAttribute类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: tokenize

//---------------------------------------------------------
bool ofxXmlSettings::attributeExists(const string& tag, const string& attribute, int which) {
    vector<string> tokens = tokenize(tag,":");
    TiXmlHandle tagHandle = storedHandle;
    for (int x = 0; x < tokens.size(); x++) {
        if (x == 0)
            tagHandle = tagHandle.ChildElement(tokens.at(x), which);
        else
            tagHandle = tagHandle.FirstChildElement(tokens.at(x));
    }

    if (tagHandle.ToElement()) {
        TiXmlElement* elem = tagHandle.ToElement();

        // Do stuff with the element here
        for (TiXmlAttribute* a = elem->FirstAttribute(); a; a = a->Next()) {
            if (a->Name() == attribute)
                return true;
        }
    }
    return false;
}
开发者ID:ryankee,项目名称:openFrameworks,代码行数:22,代码来源:ofxXmlSettings.cpp


示例2: readElement

daeElementRef daeTinyXMLPlugin::readElement(TiXmlElement* tinyXmlElement, daeElement* parentElement) {
    std::vector<attrPair> attributes;
    for (TiXmlAttribute* attrib = tinyXmlElement->FirstAttribute(); attrib != NULL; attrib = attrib->Next())
        attributes.push_back(attrPair(attrib->Name(), attrib->Value()));

    daeElementRef element = beginReadElement(parentElement, tinyXmlElement->Value(),
                                             attributes, getCurrentLineNumber(tinyXmlElement));
    if (!element) {
        // We couldn't create the element. beginReadElement already printed an error message.
        return NULL;
    }

    if (tinyXmlElement->GetText() != NULL)
        readElementText(element, tinyXmlElement->GetText(), getCurrentLineNumber(tinyXmlElement));

    // Recurse children
    for (TiXmlElement* child = tinyXmlElement->FirstChildElement(); child != NULL; child = child->NextSiblingElement())
        element->placeElement(readElement(child, element));

    return element;
}
开发者ID:ANR2ME,项目名称:collada-dom,代码行数:21,代码来源:daeTinyXMLPlugin.cpp


示例3: CopyTo

void TiXmlElement::CopyTo( TiXmlElement* target ) const
{
	// superclass:
	TiXmlNode::CopyTo( target );

	// Element class: 
	// Clone the attributes, then clone the children.
	TiXmlAttribute* attribute = 0;
	for(	attribute = attributeSet.First();
	attribute;
	attribute = attribute->Next() )
	{
		target->SetAttribute( attribute->Name(), attribute->Value() );
	}

	TiXmlNode* node = 0;
	for ( node = firstChild; node; node = node->NextSibling() )
	{
		target->LinkEndChild( node->Clone() );
	}
}
开发者ID:carussell,项目名称:nvvg,代码行数:21,代码来源:tinyxml.cpp


示例4: propName

		bool AgentInitializer::parsePropertySpec( TiXmlElement * node ) {
			if ( node->ValueStr() == "Property" ) {
				const char * cName = node->Attribute( "name" );
				if ( cName == 0x0 ) {
					logger << Logger::ERR_MSG << "AgentSet Property tag specified on line " << node->Row() << " without a \"name\" attribute.";
					return false;
				}
				::std::string propName( cName );
				return processProperty( propName, node ) != FAILURE;
			} else if ( VERBOSE ) {
				logger << Logger::WARN_MSG << "Unexpected tag when looking for a property of an AgentSet parameter set: " << node->ValueStr() << "\n";
				TiXmlAttribute * attr;
				for ( attr = node->FirstAttribute(); attr; attr = attr->Next() ) {
					if ( setFromXMLAttribute( attr->Name(), attr->ValueStr() ) == FAILURE ) {
						return false;
					}
				}
			}
			// Unexpected tags are ignored
			return true;
		}
开发者ID:argenos,项目名称:Menge,代码行数:21,代码来源:AgentInitializer.cpp


示例5: getIntAttribute

    int XmlUtils::getIntAttribute(const TiXmlElement* element, const char* name, int def)
    {
        TiXmlAttribute* attribute = element->GetAttribute(name);
        if (attribute == nullptr)
            return def;

        const std::string& string = attribute->ValueStr();
        try {
            size_t pos = 0;
            int value = std::stoi(string, &pos);
            if (pos == string.length())
                return value;
        } catch (const std::exception& e) {
            B3D_LOGE(locationOf(element) << "Value of attribute \"" << name
                << "\" is not a valid integer (" << e.what() << ").");
            throw ParseError();
        }

        B3D_LOGE(locationOf(element) << "Value of attribute \"" << name << "\" is not a valid integer.");
        throw ParseError();
    }
开发者ID:dreamsxin,项目名称:bombyx3d,代码行数:21,代码来源:XmlUtils.cpp


示例6: getVipAttr

void CRedisProxyCfg::getVipAttr(const TiXmlElement* vidNode) {
    TiXmlAttribute *addrAttr = (TiXmlAttribute *)vidNode->FirstAttribute();
    for (; addrAttr != NULL; addrAttr = addrAttr->Next()) {
        const char* name = addrAttr->Name();
        const char* value = addrAttr->Value();
        if (value == NULL) value = "";
        if (0 == strcasecmp(name, "if_alias_name")) {
            strcpy(m_vip.if_alias_name, value);
            continue;
        }
        if (0 == strcasecmp(name, "vip_address")) {
            strcpy(m_vip.vip_address, value);
            continue;
        }
        if (0 == strcasecmp(name, "enable")) {
            if(strcasecmp(value, "0") != 0 && strcasecmp(value, "") != 0 ) {
                m_vip.enable = true;
            }
        }
    }
}
开发者ID:SimpleDays,项目名称:onecache,代码行数:21,代码来源:redis-proxy-config.cpp


示例7: process_tixml_element

//-----------------------------------------------------------------------------
bool xml_c::process_tixml_element( void* tixml_element, xml_element_ptr element ) {
  // TODO: robust error checking
 
  TiXmlElement* tixml_e = (TiXmlElement*) tixml_element;
  const char* pkey = tixml_e->Value();
  const char* ptext = tixml_e->GetText();

  element->set_name( pkey );
  if( ptext ) 
    element->set_value( ptext );

  TiXmlAttribute* a = tixml_e->FirstAttribute();
  while( a!= NULL ) {
    std::string name = a->Name();
    std::string value = a->Value();
    
    xml_attribute_ptr attrib = xml_attribute_ptr( new xml_attribute_c() );
    attrib->set_name( a->Name() );
    attrib->set_value( a->Value() );
    element->append( attrib );

    a = a->Next();
  }

  TiXmlElement* tixml_child;

  for( tixml_child = tixml_e->FirstChildElement(); tixml_child != NULL; tixml_child = tixml_child->NextSiblingElement() ) {
    xml_element_ptr child = xml_element_ptr( new xml_element_c() );
    element->append( child );
    process_tixml_element( tixml_child, child );
  }
 

  return true;
}
开发者ID:jacquelinekay,项目名称:reveal,代码行数:36,代码来源:xml.cpp


示例8: LoadFromXml

bool Rule::LoadFromXml(TiXmlElement *node)
{
    TiXmlAttribute *attr = node->ToElement()->FirstAttribute();

    for (; attr; attr = attr->Next())
    {
        if (string(attr->Name()) != "name" && string(attr->Name()) != "type")
            params.Add(attr->Name(), attr->ValueStr());
    }

    TiXmlElement *cnode = node->FirstChildElement();

    for (; cnode; cnode = cnode->NextSiblingElement())
    {
        if (cnode->ValueStr() == "calaos:condition")
        {
            Condition *cond = RulesFactory::CreateCondition(cnode);
            if (cond)
                AddCondition(cond);
        }
        else if (cnode->ValueStr() == "calaos:action")
        {
            Action *action = RulesFactory::CreateAction(cnode);
            if (action)
                AddAction(action);
        }
    }

    return true;
}
开发者ID:omusico,项目名称:calaos_base,代码行数:30,代码来源:Rule.cpp


示例9: fprintf

SmartPointer<RobotController> RobotControllerFactory::Load(TiXmlElement* in,Robot& robot)
{
  if(0!=strcmp(in->Value(),"controller")) {
    fprintf(stderr,"Controller does not have type \"controller\", got %s\n",in->Value());
    return NULL;
  }
  if(in->Attribute("type")==NULL) {
    fprintf(stderr,"Controller does not have \"type\" attribute\n");
    return NULL;
  }
  SmartPointer<RobotController> c = CreateByName(in->Attribute("type"),robot);
  if(!c) {
    fprintf(stderr,"Unable to load controller of type %s\n",in->Attribute("type"));
    fprintf(stderr,"Candidates: \n");
    for(map<std::string,SmartPointer<RobotController> >::iterator i=controllers.begin();i!=controllers.end();i++)
      fprintf(stderr,"  %s\n",i->first.c_str());
    return NULL;
  }
  TiXmlAttribute* attr = in->FirstAttribute();
  while(attr != NULL) {
    if(0==strcmp(attr->Name(),"type")) {
      attr = attr->Next();
      continue;
    }
    if(!c->SetSetting(attr->Name(),attr->Value())) {
      fprintf(stderr,"Load controller  %s from XML: Unable to set setting %s\n",in->Attribute("type"),attr->Name());
      return NULL;
    }
    attr = attr->Next();
  }
  return c;
}
开发者ID:stevekuznetsov,项目名称:Klampt,代码行数:32,代码来源:Controller.cpp


示例10: dump_attribs_to_stdout

    int xmlStructure::dump_attribs_to_stdout ( TiXmlElement* pElement, unsigned int indent )
    {
        if ( !pElement )
            return 0;

        TiXmlAttribute* pAttrib = pElement->FirstAttribute();
        int i = 0;
        int ival;
        double dval;
        const char* pIndent = getIndent ( indent );
        printf ( "\n" );
        while ( pAttrib )
        {
            printf ( "%s%s: value=[%s]", pIndent, pAttrib->Name(), pAttrib->Value() );

            if ( pAttrib->QueryIntValue ( &ival ) == TIXML_SUCCESS )
                printf ( " int=%d", ival );
            if ( pAttrib->QueryDoubleValue ( &dval ) == TIXML_SUCCESS )
                printf ( " d=%1.1f", dval );
            printf ( "\n" );
            i++;
            pAttrib = pAttrib->Next();
        }
        return i;
    }
开发者ID:akivajp,项目名称:travatar,代码行数:25,代码来源:xmlStructure.cpp


示例11: ParseFilterInVCProjectFile

bool CConverToMK::ParseFilterInVCProjectFile( TiXmlElement* pkElement,
											 StringVector& kVector)
{
	if (0 == pkElement)
	{
		return false;
	}

	TiXmlElement* pkFilter = pkElement->FirstChildElement();

	if (0 == pkFilter)
	{
		return false;
	}

	do
	{
		TiXmlAttribute* pkAttr = pkFilter->FirstAttribute();

		string strType = pkFilter->Value();

		if (strcmp("Filter",strType.c_str()) == 0)
		{
			ParseFilterInVCProjectFile(pkFilter,kVector);
		}
		else if (strcmp("File",strType.c_str()) == 0)
		{
			string strName = pkAttr->Value();

			if (!IsFilterWord(strName.c_str()))
			{
				continue;
			}

			kVector.push_back(strName);
		}
	} while (pkFilter = pkFilter->NextSiblingElement());

	return true;
}
开发者ID:jonesgithub,项目名称:HHHH,代码行数:40,代码来源:ConverToMK.cpp


示例12: while

void CUICommandNode::RemoveSameProperty(TiXmlNode* pBeforeElem, TiXmlNode* pAfterElem)
{
	TiXmlAttribute* pBeforeAttrib = pBeforeElem->ToElement()->FirstAttribute();
	TiXmlAttribute* pAfterAttrib = pAfterElem->ToElement()->FirstAttribute();

	while(pBeforeAttrib)
	{
		TiXmlAttribute* pBeforeAttribNext = pBeforeAttrib->Next();
		TiXmlAttribute* pAfterAttribNext = pAfterAttrib->Next();
		if(strcmp(pBeforeAttrib->Name(), "name")!=0 && strcmp(pBeforeAttrib->Value(), pAfterAttrib->Value())==0)
		{
			pBeforeElem->ToElement()->RemoveAttribute(pBeforeAttrib->Name());
			pAfterElem->ToElement()->RemoveAttribute(pAfterAttrib->Name());
		}
		pBeforeAttrib = pBeforeAttribNext;
		pAfterAttrib = pAfterAttribNext;
	}
}
开发者ID:pyq881120,项目名称:urltraveler,代码行数:18,代码来源:UICommandHistory.cpp


示例13: ResolveExpressions

void CGUIIncludes::ResolveExpressions(TiXmlElement *node)
{
  if (!node)
    return;

  TiXmlNode *child = node->FirstChild();
  if (child && child->Type() == TiXmlNode::TINYXML_TEXT && m_expressionNodes.count(node->ValueStr()))
  {
    child->SetValue(ResolveExpressions(child->ValueStr()));
  }
  else
  {
    TiXmlAttribute *attribute = node->FirstAttribute();
    while (attribute)
    {
      if (m_expressionAttributes.count(attribute->Name()))
        attribute->SetValue(ResolveExpressions(attribute->ValueStr()));

      attribute = attribute->Next();
    }
  }
}
开发者ID:Razzeee,项目名称:xbmc,代码行数:22,代码来源:GUIIncludes.cpp


示例14: while

bool CButtonTranslator::LoadLircMap()
{
  // load our xml file, and fill up our mapping tables
  TiXmlDocument xmlDoc;

  // Load the config file
  CStdString lircmapPath = g_settings.GetUserDataItem("Lircmap.xml");
  CLog::Log(LOGINFO, "Loading %s", lircmapPath.c_str());
  if (!xmlDoc.LoadFile(lircmapPath))
  {
    g_LoadErrorStr.Format("%s, Line %d\n%s", lircmapPath.c_str(), xmlDoc.ErrorRow(), xmlDoc.ErrorDesc());
    return true; // This is so people who don't have the file won't fail, just warn
  }

  lircRemotesMap.clear();
  TiXmlElement* pRoot = xmlDoc.RootElement();
  CStdString strValue = pRoot->Value();
  if (strValue != "lircmap")
  {
    g_LoadErrorStr.Format("%sl Doesn't contain <lircmap>", lircmapPath.c_str());
    return false;
  }

  // run through our window groups
  TiXmlNode* pRemote = pRoot->FirstChild();
  while (pRemote)
  {
    const char *szRemote = pRemote->Value();
    if (szRemote)
    {
      TiXmlAttribute* pAttr = pRemote->ToElement()->FirstAttribute();
      const char* szDeviceName = pAttr->Value();
      MapRemote(pRemote, szDeviceName);
    }
    pRemote = pRemote->NextSibling();
  }
  
  return true;
}
开发者ID:Avoidnf8,项目名称:xbmc-fork,代码行数:39,代码来源:ButtonTranslator.cpp


示例15: handle

void SE_ShaderHandler::handle(SE_Element* parent, TiXmlElement* xmlElement, unsigned int indent)
{
    if(!xmlElement)
        return;
    TiXmlAttribute* pAttribute = xmlElement->FirstAttribute();
    SE_ResourceManager* resourceManager = SE_Application::getInstance()->getResourceManager();
    std::string vertexShaderFilePath;
    std::string fragmentShaderFilePath;
    while(pAttribute)
    {
        const char* name = pAttribute->Name();
        const char* value = pAttribute->Value();
        if(!strcmp(name , "VertexShader"))
        {
            vertexShaderFilePath = std::string(resourceManager->getDataPath()) + SE_SEP + value;
        }
        else if(!strcmp(name, "FragmentShader"))
        {
            fragmentShaderFilePath = std::string(resourceManager->getDataPath()) + SE_SEP + value;
        }
        pAttribute = pAttribute->Next();
    }
    char* vertexShader;
    char* fragmentShader;
    int vertexShaderLen =0;
    int fragmentShaderLen = 0;
    SE_IO::readFileAll(vertexShaderFilePath.c_str(), vertexShader, vertexShaderLen);
    SE_IO::readFileAll(fragmentShaderFilePath.c_str(), fragmentShader, fragmentShaderLen);
    char* vs = new char[vertexShaderLen + 1];
    char* fs = new char[fragmentShaderLen + 1];
    memset(vs, 0, vertexShaderLen + 1);
    memset(fs, 0, fragmentShaderLen + 1);
    memcpy(vs, vertexShader, vertexShaderLen);
    memcpy(fs, fragmentShader, fragmentShaderLen);
    SE_ProgramDataID id("main_vertex_shader");
    //resourceManager->setShaderProgram(id, vs, fs);
    delete[] vertexShader;
    delete[] fragmentShader;
}
开发者ID:26597925,项目名称:3DHome,代码行数:39,代码来源:SE_ElementManager.cpp


示例16: setKeyMappingNode

void CRedisProxyCfg::setKeyMappingNode(TiXmlElement* pNode) {
    TiXmlElement* pNext = pNode->FirstChildElement();
    for (; pNext != NULL; pNext = pNext->NextSiblingElement()) {
        CKeyMapping hashMap;
        if (0 == strcasecmp(pNext->Value(), "key")) {
            TiXmlAttribute *addrAttr = pNext->FirstAttribute();
            for (; addrAttr != NULL; addrAttr = addrAttr->Next()) {
                const char* name = addrAttr->Name();
                const char* value = addrAttr->Value();
                if (value == NULL) value = "";
                if (0 == strcasecmp(name, "key_name")) {
                    strcpy(hashMap.key, value);
                    continue;
                }
                if (0 == strcasecmp(name, "group_name")) {
                    strcpy(hashMap.group_name, value);
                }
            }
            m_keyMappingList->push_back(hashMap);
        }
    }
}
开发者ID:SimpleDays,项目名称:onecache,代码行数:22,代码来源:redis-proxy-config.cpp


示例17: parse_element

View* XmlParser::parse_element(TiXmlElement *e, View *parent /* = NULL */)
{
	if (!e)
	{
		return NULL;
	}
	View *view = ResourceCreator::instance().get_view(e->Value());
	if (!view)
	{
		return NULL;
	}
	if (parent)
	{
		view->set_parent(parent);
		parent->push_child(view);
	}
	TiXmlAttribute *a = e->FirstAttribute();
	PropMap props;
	while(a)
	{
		props.insert(make_pair(a->Name(), a->Value()));
		a = a->Next();
	}
	view->parse(props);

	TiXmlNode *node = e->FirstChild();
	if (!node)
	{
		return view;
	}
	TiXmlElement *sub = node->ToElement();
	while (sub)
	{
		View* sv = parse_element(sub, view);
		sub = sub->NextSiblingElement();
	}
	return view;
}
开发者ID:cody0755,项目名称:MyResume,代码行数:38,代码来源:XmlParser.cpp


示例18: PROFILE_SCOPE

inline bool TamlXmlParser::parseAttributes( TiXmlElement* pXmlElement, TamlVisitor& visitor )
{
    // Debug Profiling.
    PROFILE_SCOPE(TamlXmlParser_ParseAttribute);

    // Calculate if element is at the root or not.
    const bool isRoot = pXmlElement->GetDocument()->RootElement() == pXmlElement;

    // Create a visitor property state.
    TamlVisitor::PropertyState propertyState;
    propertyState.setObjectName( pXmlElement->Value(), isRoot );

    // Iterate attributes.
    for ( TiXmlAttribute* pAttribute = pXmlElement->FirstAttribute(); pAttribute; pAttribute = pAttribute->Next() )
    {
        // Configure property state.
        propertyState.setProperty( pAttribute->Name(), pAttribute->Value() );

        // Visit this attribute.
        const bool visitStatus = visitor.visit( *this, propertyState );

        // Was the property value changed?
        if ( propertyState.getPropertyValueDirty() )
        {
            // Yes, so update the attribute.
            pAttribute->SetValue( propertyState.getPropertyValue() );

            // Flag the document as dirty.
            mDocumentDirty = true;
        }

        // Finish if requested.
        if ( !visitStatus )
            return false;
    }

    return true;
}
开发者ID:03050903,项目名称:Torque3D,代码行数:38,代码来源:tamlXmlParser.cpp


示例19: xml_QueryNode_Attribute

/*!
*  /brief 通过节点查询。
*
*  /param XmlFile   xml文件全路径。
*  /param strNodeName  要查询的节点名
*  /param AttMap      要查询的属性值,这是一个map,前一个为属性名,后一个为属性值
*  /return 是否成功。true为成功,false表示失败。
*/
bool xml_QueryNode_Attribute(TiXmlElement *pRootEle, std::string strNodeName,
        std::map<std::string, std::string> &AttMap)
{
    // 定义一个TiXmlDocument类指针
    typedef std::pair<std::string, std::string> String_Pair;
    if (NULL == pRootEle) {
        return false;
    }
    TiXmlElement *pNode = NULL;
    xml_GetNodePointerByName(pRootEle, strNodeName, pNode);
    if (NULL != pNode) {
        TiXmlAttribute* pAttr = NULL;
        for (pAttr = pNode->FirstAttribute(); pAttr; pAttr = pAttr->Next()) {
            std::string strAttName = pAttr->Name();
            std::string strAttValue = pAttr->Value();
            AttMap.insert(String_Pair(strAttName, strAttValue));
        }
        return true;
    } else {
        return false;
    }
    return true;
}
开发者ID:ubuntu-chu,项目名称:commu_manager,代码行数:31,代码来源:parse.cpp


示例20:

int em::EmXml::ReadRootAttrMap( EmMapStr &rMapStr )
{
	int iResult = 0;
	rMapStr.clear();

	TiXmlElement *pElemRoot = m_pDoc->RootElement();
	if(pElemRoot == NULL)
	{
		return 0;
	}
	TiXmlAttribute *pAttr = pElemRoot->FirstAttribute();
	while(true)
	{
		if(pAttr == NULL)
		{
			break;
		}
		rMapStr[  pAttr->Name() ] =  pAttr->Value() ;
		pAttr = pAttr->Next();
	}
	iResult = rMapStr.size();
	return iResult;
}
开发者ID:lidongqiang,项目名称:FWFactoryTool,代码行数:23,代码来源:EmXml.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ TiXmlAttributeA类代码示例发布时间:2022-05-31
下一篇:
C++ TiValue类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap