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


C++ TiXmlAttribute类代码示例

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


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


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