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


C++ XMLElement::InsertEndChild方法代码示例

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


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

示例1: 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

示例2: 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

示例3: GenerateSaveFile

	/**
	*	@brief This generates a new saveData.xml for the game insertting all the approprate
	*	formatting for reading later.
	*	@see SaveSlot
	*/
	void GenerateSaveFile(){
		cLog::inst()->print(3, "XML Loader", "Generating new save_data.xml");

		//create and insert the root node of the .xml document
		tinyxml2::XMLNode *pRoot = xmlDoc.NewElement("Root");
		xmlDoc.InsertFirstChild(pRoot);

		tinyxml2::XMLElement *saveGame = xmlDoc.NewElement("SaveGame");
		for (int i = 0; i < 3; i++)
		{
			string d = "SaveSlot" + std::to_string(i + 1);
			const char * c = d.c_str();
			tinyxml2::XMLElement * saveSlot = xmlDoc.NewElement(c);

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

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

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

				pElement->InsertEndChild(pListElement);
			}

			saveSlot->InsertEndChild(pElement);

			//Insert Achievement Tracking into the saveData.sav
			pElement = xmlDoc.NewElement("Achievements");
			for (int i = 0; i < 21; i++)
			{
				string d = "ACH" + std::to_string(i + 1);
				const char * c = d.c_str();
				tinyxml2::XMLElement * pListElement = xmlDoc.NewElement(c);
				pListElement->SetText(0);

				pElement->InsertEndChild(pListElement);
			}

			saveSlot->InsertEndChild(pElement);

			//Insert Stat Tracking into the saveData.sav
			pElement = xmlDoc.NewElement("Statistics");
			for (int i = 0; i < 10; i++)
			{
				string d = "STAT" + std::to_string(i + 1);
				const char * c = d.c_str();
				tinyxml2::XMLElement * pListElement = xmlDoc.NewElement(c);
				pListElement->SetText(0);

				pElement->InsertEndChild(pListElement);
			}

			saveSlot->InsertEndChild(pElement);

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

		tinyxml2::XMLError eResult = xmlDoc.SaveFile("Assets/save_data.xml");

	}
开发者ID:Joshmoo2009,项目名称:FYP_1516_JoshMooney,代码行数:76,代码来源:XMLLoader.hpp

示例4: Save

void UIAnimation::Save(tinyxml2::XMLElement& elem)
{
	if (mGlobalAnim){
		elem.SetAttribute("globalName", mName.c_str());
	}
	else {
		elem.SetAttribute("id", mID);
		elem.SetAttribute("name", mName.c_str());
		elem.SetAttribute("length", mLength);
		elem.SetAttribute("loop", mLoop);
		if (!mKeyTextColor.empty()){
			auto textColorElem = elem.GetDocument()->NewElement("TextColor");
			elem.InsertEndChild(textColorElem);
			for (auto& it : mKeyTextColor)
			{
				auto keyelem = textColorElem->GetDocument()->NewElement("key");
				textColorElem->InsertEndChild(keyelem);
				keyelem->SetAttribute("time", it.first);
				keyelem->SetAttribute("color", StringMathConverter::ToString(it.second).c_str());
			}
		}

		if (!mKeyBackColor.empty()){
			auto backColorElem = elem.GetDocument()->NewElement("BackColor");
			elem.InsertEndChild(backColorElem);
			for (auto& it : mKeyBackColor)
			{
				auto keyelem = backColorElem->GetDocument()->NewElement("key");
				backColorElem->InsertEndChild(keyelem);
				keyelem->SetAttribute("time", it.first);
				keyelem->SetAttribute("color", StringMathConverter::ToString(it.second).c_str());
			}
		}

		if (!mKeyMaterialColor.empty()){
			auto materialColorElem = elem.GetDocument()->NewElement("MaterialColor");
			elem.InsertEndChild(materialColorElem);
			for (auto& it : mKeyMaterialColor)
			{
				auto keyelem = materialColorElem->GetDocument()->NewElement("key");
				materialColorElem->InsertEndChild(keyelem);
				keyelem->SetAttribute("time", it.first);
				keyelem->SetAttribute("color", StringMathConverter::ToString(it.second).c_str());
			}
		}

		if (!mKeyPos.empty()){
			auto posElem = elem.GetDocument()->NewElement("Pos");
			elem.InsertEndChild(posElem);
			for (auto& it : mKeyPos)
			{
				auto keyelem = posElem->GetDocument()->NewElement("key");
				posElem->InsertEndChild(keyelem);
				keyelem->SetAttribute("time", it.first);
				keyelem->SetAttribute("pos", StringMathConverter::ToString(it.second).c_str());
			}
		}

		if (!mKeyScale.empty()){
			auto scaleElem = elem.GetDocument()->NewElement("Scale");
			elem.InsertEndChild(scaleElem);
			for (auto& it : mKeyScale)
			{
				auto keyelem = scaleElem->GetDocument()->NewElement("key");
				scaleElem->InsertEndChild(keyelem);
				keyelem->SetAttribute("time", it.first);
				keyelem->SetAttribute("scale", StringMathConverter::ToString(it.second).c_str());
			}
		}

		if (!mKeyAlpha.empty()){
			auto alphaElem = elem.GetDocument()->NewElement("Alpha");
			elem.InsertEndChild(alphaElem);
			for (auto& it : mKeyAlpha)
			{
				auto keyelem = alphaElem->GetDocument()->NewElement("key");
				alphaElem->InsertEndChild(keyelem);
				keyelem->SetAttribute("time", it.first);
				keyelem->SetAttribute("alpha", StringConverter::ToString(it.second).c_str());
			}
		}
	}
}
开发者ID:fastbird,项目名称:fastbirdEngine,代码行数:83,代码来源:UIAnimation.cpp


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