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


C++ tinyxml2::XMLElement类代码示例

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


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

示例1: getVector

  EReturn getVector(const tinyxml2::XMLElement & xml_vector,
      Eigen::VectorXd & eigen_vector)
  {
    //!< Temporaries
    double temp_entry;
    int i = 0;

    if (!xml_vector.GetText())
    {
      INDICATE_FAILURE
      ;
      eigen_vector = Eigen::VectorXd(); //!< Null matrix again
      return PAR_ERR;
    }
    std::istringstream text_parser(xml_vector.GetText());

    //!< Initialise looping
    text_parser >> temp_entry;
    while (!(text_parser.fail() || text_parser.bad()))  //!< No commenting!
    {
      eigen_vector.conservativeResize(++i); //!< Allocate storage for this entry (by increasing i)
      eigen_vector(i - 1) = temp_entry;
      text_parser >> temp_entry;
    }
    return (i > 0) ? SUCCESS : PAR_ERR;
  }
开发者ID:bmagyar,项目名称:exotica,代码行数:26,代码来源:Tools.cpp

示例2: cf

bool ChannelFavoritesSerializer::GetFavoritesResponseXmlDataDeserializer::VisitEnter(const tinyxml2::XMLElement& element, const tinyxml2::XMLAttribute* attribute)
{
    if (strcmp(element.Name(), "favorite") == 0)
    {
        std::string id = Util::GetXmlFirstChildElementText(&element, "id");
        std::string name = Util::GetXmlFirstChildElementText(&element, "name");

        //channels
        ChannelFavorite::favorite_channel_list_t channels;
        const tinyxml2::XMLElement* channels_element = element.FirstChildElement("channels");
        if (channels_element != NULL)
        {
            const tinyxml2::XMLElement* channel_element = channels_element->FirstChildElement();
            while (channel_element != NULL)
            {
                if (strcmp(channel_element->Name(), "channel") == 0)
                {
                    if (channel_element->GetText() != NULL)
                        channels.push_back(channel_element->GetText());
                }
                channel_element = channel_element->NextSiblingElement();
            }

        }

        ChannelFavorite cf(id, name, channels);

        m_favoritesList.favorites_.push_back(cf);

        return false;
    }

    return true;
}
开发者ID:MrMC,项目名称:pvr.dvblink,代码行数:34,代码来源:favorites.cpp

示例3:

Vector3d<float> XMLHelper::parse(tinyxml2::XMLElement& elem)
{
	const auto x = elem.FloatAttribute("x");
	const auto y = elem.FloatAttribute("y");
	const auto z = elem.FloatAttribute("z");
	return Vector3d<float>(x, y, z);
}
开发者ID:SatoshiMabuchi,项目名称:CrystalGraphics,代码行数:7,代码来源:CGBFile.cpp

示例4: ReadAttributedObject

/**
 * Reads the attributed object id, comments, and artifacts.
 */
bool Translator::ReadAttributedObject( AttributedObject& aobj, 
		Context& ctxt, const tinyxml2::XMLElement & elem, bool bIdAttributeRequired )
{
	//Grab the ID.
	pcstr szid = elem.Attribute("id");
	if( szid == NULL)
	{
		if( bIdAttributeRequired )
			throw GnssMetadata::TranslationException( "Required id attribute not defined.");
	}
	else
		aobj.Id(szid);

	//Parse the comments.
	const XMLElement* pelem = elem.FirstChildElement("comment");
	for( ;pelem != NULL; pelem = pelem->NextSiblingElement("comment"))
	{
		const char* szFmt = pelem->Attribute("format");
		Comment::CommentFormat fmt = (strcmp(szFmt, "text") == 0)
			? Comment::text : Comment::html;
		Comment comment( pelem->GetText(), fmt);
		aobj.Comments().push_back( comment);
	}

	//Parse the Artifacts.
	pelem = elem.FirstChildElement("artifact");
	for( ;pelem != NULL; pelem = pelem->NextSiblingElement("artifact"))
	{
		AnyUri auri( pelem->GetText());
		aobj.Artifacts().push_back( auri);
	}

	return true;
}
开发者ID:mbmathews,项目名称:metadata,代码行数:37,代码来源:Translator.cpp

示例5: decodeXML

void Restaurant::decodeXML(tinyxml2::XMLElement & xml)
{
	Item::decodeXML(xml);
	variant = xml.IntAttribute("variant");
	open    = xml.BoolAttribute("open");
	updateSprite();
}
开发者ID:Hmaal,项目名称:OpenSkyscraper,代码行数:7,代码来源:Restaurant.cpp

示例6: WriteAttributedObject

/**
 * Writes the attributed object id, comments, and artifacts.
 */
void Translator::WriteAttributedObject(const AttributedObject& aobj, Context& ctxt, tinyxml2::XMLElement & elem, bool bIdAttributeRequired)
{
	//Write the ID.
	if( aobj.Id().length() > 0 )
		elem.SetAttribute( "id", aobj.Id().c_str());
	else if( bIdAttributeRequired )
		throw GnssMetadata::TranslationException( "Required id attribute not defined.");



	//Write the comments.
	CommentList::const_iterator citer = aobj.Comments().begin();
	for(; citer != aobj.Comments().end(); citer++)
	{
		XMLElement* pec = elem.GetDocument()->NewElement( "comment");
		const Comment& cmt = *citer;
		const char* szFormat = (cmt.Format() == Comment::text) ? "text":"html";
		pec->SetAttribute("format",szFormat);
		pec->SetText( cmt.Value().c_str());
		elem.InsertEndChild(pec);
	}

	//Write the Artifacts.
	AnyUriList::const_iterator aiter = aobj.Artifacts().begin();
	for(; aiter != aobj.Artifacts().end(); aiter++)
	{
		XMLElement* pec = elem.GetDocument()->NewElement( "artifact");
		pec->SetText( aiter->Value().c_str());
		elem.InsertEndChild(pec);
	}
}
开发者ID:mbmathews,项目名称:metadata,代码行数:34,代码来源:Translator.cpp

示例7: RecordedTV

bool GetObjectResponseSerializer::ItemXmlDataDeserializer::VisitEnter(const tinyxml2::XMLElement& element, const tinyxml2::XMLAttribute* attribute)
{
	Item * item;
	if (strcmp(element.Name(), "recorded_tv") == 0) 
	{     
		std::string objectId = Util::GetXmlFirstChildElementText(&element, "object_id");
		std::string parentId = Util::GetXmlFirstChildElementText(&element, "parent_id");
		std::string url = Util::GetXmlFirstChildElementText(&element, "url");
		std::string thumbnail = Util::GetXmlFirstChildElementText(&element, "thumbnail");
		std::string channelName = Util::GetXmlFirstChildElementText(&element, "channel_name");
		bool canBeDeleted = Util::GetXmlFirstChildElementTextAsBoolean(&element, "can_be_deleted");
		long size = Util::GetXmlFirstChildElementTextAsLong(&element, "size");
		long creationTime = Util::GetXmlFirstChildElementTextAsLong(&element, "creation_time");
		int channelNumber = Util::GetXmlFirstChildElementTextAsInt(&element, "channel_number");
		int channelSubnumber = Util::GetXmlFirstChildElementTextAsInt(&element, "channel_subnumber");
		RECORDEDTV_STATE state = (RECORDEDTV_STATE)  Util::GetXmlFirstChildElementTextAsInt(&element, "state");

		item = new RecordedTV(objectId, parentId, url,thumbnail,channelName,canBeDeleted,size,creationTime,channelNumber,channelSubnumber, state);

		tinyxml2::XMLElement * vElement = (tinyxml2::XMLElement*)(&element)->FirstChildElement("video_info");

		VideoInfoSerializer::Deserialize((XmlObjectSerializer<Response>&)m_parent, *vElement, ((RecordedTV*) item)->VInfo);
		
		m_items.push_back(item);
		return false;
	}

	if (strcmp(element.Name(), "video") == 0) 
	{     
		std::string objectId = Util::GetXmlFirstChildElementText(&element, "object_id");
		std::string parentId = Util::GetXmlFirstChildElementText(&element, "parent_id");
		std::string url = Util::GetXmlFirstChildElementText(&element, "url");
		std::string thumbnail = Util::GetXmlFirstChildElementText(&element, "thumbnail");
		std::string channelName = Util::GetXmlFirstChildElementText(&element, "channel_name");
		bool canBeDeleted = Util::GetXmlFirstChildElementTextAsBoolean(&element, "can_be_deleted");
		long size = Util::GetXmlFirstChildElementTextAsLong(&element, "size");
		long creationTime = Util::GetXmlFirstChildElementTextAsLong(&element, "creation_time");

		item = new Video(objectId, parentId, url,thumbnail,canBeDeleted,size,creationTime);
		m_items.push_back(item);
		return false;
	}

	if (strcmp(element.Name(), "audio") == 0) 
	{     
		item = new Audio();
		m_items.push_back(item);
		return false;
	}

	if (strcmp(element.Name(), "image") == 0) 
	{     
		item = new Image();
		m_items.push_back(item);
		return false;
	}

	return true;

}
开发者ID:avdleeuw,项目名称:dvblinkremote,代码行数:60,代码来源:get_object_request.cpp

示例8: WriteSaveSlot

	/**
	*	@brief This function takes the passed in SaveSlot, and writes it to the .xml file.
	*	@param This is the SaveSlot to be written.
	*/
	void WriteSaveSlot(SaveSlot s){
		string d = "SaveSlot" + std::to_string(s.m_id);
		const char * c = d.c_str();
		tinyxml2::XMLElement * saveSlot = xmlDoc.NewElement(c);

		//Inserts Values to the .xml file
		tinyxml2::XMLElement * pElement = xmlDoc.NewElement("TimePlayed");
		pElement->SetText(s.m_timePlayed);
		saveSlot->InsertEndChild(pElement);

		pElement = xmlDoc.NewElement("CurrentGold");
		pElement->SetText(s.m_currentGold);
		saveSlot->InsertEndChild(pElement);

		pElement = xmlDoc.NewElement("Levels");

		for (int i = 0; i < 7; i++){
			string level = "LVL" + std::to_string(i + 1);
			const char * c = level.c_str();
			tinyxml2::XMLElement * pListElement = xmlDoc.NewElement(c);
			pListElement->SetText(s.m_LVL_DATA[level]);

			pElement->InsertEndChild(pListElement);

			saveGame->InsertEndChild(saveSlot);
			saveSlot->InsertEndChild(pElement);
		}

		pElement = xmlDoc.NewElement("Achievements");
		for (int i = 0; i < 21; i++) {
			string ach = "ACH" + std::to_string(i + 1);
			const char * c = ach.c_str();
			tinyxml2::XMLElement * pListElement = xmlDoc.NewElement(c);
			pListElement->SetText(s.m_ACH_DATA[ach]);

			pElement->InsertEndChild(pListElement);

			saveSlot->InsertEndChild(pElement);
			saveGame->InsertEndChild(saveSlot);
		}

		pElement = xmlDoc.NewElement("Statistics");
		for (int i = 0; i < 10; i++) {
			string stat = "STAT" + std::to_string(i + 1);
			const char * c = stat.c_str();
			tinyxml2::XMLElement * pListElement = xmlDoc.NewElement(c);
			pListElement->SetText(s.m_ACH_DATA[stat]);

			pElement->InsertEndChild(pListElement);

			saveSlot->InsertEndChild(pElement);
			saveGame->InsertEndChild(saveSlot);
		}
	}
开发者ID:Joshmoo2009,项目名称:FYP_1516_JoshMooney,代码行数:58,代码来源:XMLLoader.hpp

示例9: getMatrix

  EReturn getMatrix(const tinyxml2::XMLElement & xml_matrix,
      Eigen::MatrixXd & eigen_matrix)
  {
    int dimension = 0;

    if (xml_matrix.QueryIntAttribute("dim", &dimension)
        != tinyxml2::XML_NO_ERROR)
    {
      INDICATE_FAILURE
      ;
      eigen_matrix = Eigen::MatrixXd(); //!< Null matrix again
      return PAR_ERR;
    }

    if (dimension < 1)
    {
      INDICATE_FAILURE
      ;
      eigen_matrix = Eigen::MatrixXd(); //!< Null matrix again
      return PAR_ERR;
    }
    eigen_matrix.resize(dimension, dimension);

    if (!xml_matrix.GetText())
    {
      INDICATE_FAILURE
      ;
      eigen_matrix = Eigen::MatrixXd(); //!< Null matrix again
      return PAR_ERR;
    }

    std::istringstream text_parser(xml_matrix.GetText());
    double temp_entry;
    for (int i = 0; i < dimension; i++) //!< Note that this does not handle comments!
    {
      for (int j = 0; j < dimension; j++)
      {
        text_parser >> temp_entry;
        if (text_parser.fail() || text_parser.bad()) //!< If a failure other than end of file
        {
          INDICATE_FAILURE
          ;
          eigen_matrix.resize(0, 0);
          return PAR_ERR;
        }
        else
        {
          eigen_matrix(i, j) = temp_entry;
        }
      }
    }

    return SUCCESS;
  }
开发者ID:bmagyar,项目名称:exotica,代码行数:54,代码来源:Tools.cpp

示例10: Load

void Fruit::Load(tinyxml2::XMLElement const& element)
{
    char const* sprite = element.Attribute("Sprite");
    assert(sprite);
    m_Sprite.Load(sprite);
    m_Sprite.SetOriginToCentre();

    m_Score = element.IntAttribute("Score");
    m_Appear1 = element.IntAttribute("Appear1");
    m_Appear2 = element.IntAttribute("Appear2");
    m_Time = element.FloatAttribute("Time");
}
开发者ID:spinglass,项目名称:NicMan,代码行数:12,代码来源:Fruit.cpp

示例11: clearCars

void Elevator::decodeXML(tinyxml2::XMLElement & xml)
{
	clearCars();
	Item::decodeXML(xml);
	size.y = xml.IntAttribute("height");
	for (tinyxml2::XMLElement * e = xml.FirstChildElement("unserviced"); e; e = e->NextSiblingElement("unserviced")) {
		unservicedFloors.insert(e->IntAttribute("floor"));
	}
	for (tinyxml2::XMLElement * e = xml.FirstChildElement("car"); e; e = e->NextSiblingElement("car")) {
		Car * car = new Car(this);
		car->decodeXML(*e);
		cars.insert(car);
	}
	updateSprite();
}
开发者ID:Hmaal,项目名称:OpenSkyscraper,代码行数:15,代码来源:Elevator.cpp

示例12: Channel

bool GetChannelsResponseSerializer::GetChannelsResponseXmlDataDeserializer::VisitEnter(const tinyxml2::XMLElement& element, const tinyxml2::XMLAttribute* attribute)
{
  if (strcmp(element.Name(), "channel") == 0) 
  {     
    long channelDvbLinkId = Util::GetXmlFirstChildElementTextAsLong(&element, "channel_dvblink_id");
    std::string channelId = Util::GetXmlFirstChildElementText(&element, "channel_id");
    std::string channelName = Util::GetXmlFirstChildElementText(&element, "channel_name");
    int channelNumber = Util::GetXmlFirstChildElementTextAsInt(&element, "channel_number");
    int channelSubNumber = Util::GetXmlFirstChildElementTextAsInt(&element, "channel_subnumber");
    Channel::DVBLinkChannelType channelType = (Channel::DVBLinkChannelType)Util::GetXmlFirstChildElementTextAsInt(&element, "channel_type");
    std::string channelLogoUrl = Util::GetXmlFirstChildElementText(&element, "channel_logo");

    Channel* channel = new Channel(channelId, channelDvbLinkId, channelName, channelType, channelLogoUrl, channelNumber, channelSubNumber);

    if (m_parent.HasChildElement(*&element, "channel_child_lock"))
    {
      channel->ChildLock = Util::GetXmlFirstChildElementTextAsBoolean(&element, "channel_child_lock");
    }

    m_channelList.push_back(channel);

    return false;
  }

  return true;
}
开发者ID:janbar,项目名称:pvr.dvblink,代码行数:26,代码来源:channel.cpp

示例13: VisitExit

bool XmlSaxHander::VisitExit( const tinyxml2::XMLElement& element )
{
    //log("VisitExit %s",element.Value());

    SAXParser::endElement(_ccsaxParserImp, (const CC_XML_CHAR *)element.Value());
    return true;
}
开发者ID:DominicD,项目名称:Hyperdrive,代码行数:7,代码来源:CCSAXParser.cpp

示例14: ReadElement

/**
 * Processes the current element within the context of the attributed object.
 */
bool XmlProcessor::ReadElement( Context & ctxt, const tinyxml2::XMLElement & elem, AccessorAdaptorBase* pAdaptor)
{
	TranslatorId id = TE_END;
	const char* szNodeName = elem.Name();

	//Use the current translator if available to lookup appropriate
	//translator for the current element.   If not available,
	//do a global search.
	if( ctxt.pParent != NULL)
	{
		id = TranslatorIdFromElemName( szNodeName, ctxt.pParent->GetAllowedNodes() );	
	}
	else //Do a global lookup.  
	{
		for( int i = 0; i < COUNT_TRANSLATORS && id == TE_END; i++)
		{
			NodeEntry* pNodes = _Translators[i].translator.GetAllowedNodes();
			if(pNodes == NULL) continue;

			id = TranslatorIdFromElemName( szNodeName, pNodes);	
		}
	}

	//Get the translator and attempt to process the current
	//element.
	Translator& trans = TranslatorFromId( id);
	return trans.OnRead( ctxt, elem, pAdaptor);
}
开发者ID:mbmathews,项目名称:metadata,代码行数:31,代码来源:XmlProcessor.cpp

示例15: while

	void Animation2D::Read(const tinyxml2::XMLElement& el_ )
	{
		Animation::Read(el_);

		const tinyxml2::XMLElement *pElemFrame = el_.FirstChildElement("EventList")->FirstChildElement("Event");

		//float totalTime = 0.0f;

		while (pElemFrame != nullptr)
		{
			SetFrameEvent *pFrameEvent = NEW_AO SetFrameEvent();
			pFrameEvent->Read(const_cast<tinyxml2::XMLElement *>(pElemFrame));
			AddEvent(pFrameEvent);

			pElemFrame = pElemFrame->NextSiblingElement();

			/*unsigned int spriteID;
			pElemFrame->QueryUnsignedAttribute("spriteID", &spriteID);
			float time;
			pElemFrame->QueryFloatAttribute("time", &time);

			std::ostringstream str;
			str << spriteID;

			SetFrameEvent *pFrameEvent = NEW_AO SetFrameEvent();
			pFrameEvent->FrameID(str.str().c_str());
			pFrameEvent->Time(time + totalTime);
			AddEvent(pFrameEvent);

			pElemFrame = pElemFrame->NextSiblingElement();
			totalTime += time;*/
		}
	}
开发者ID:xcasadio,项目名称:casaengine,代码行数:33,代码来源:Animation2D.cpp


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