Exemple #1
0
	void XmlTree (std::ostream & out)
	{
		XML::Tree tree;
		XML::Node * root = tree.SetRoot ("UnitTest");
		std::auto_ptr<XML::Node> child1 (new XML::Node ("child"));
		child1->AddAttribute ("num", "1");
		child1->AddTransformAttribute ("level", "1");
		child1->AddTransformAttribute ("upperExamples", 
				"some upper chars: А, ▓, ├ or нт and finally Ш.");
		child1->AddTransformText ("This text contains all 5 special characters:\n"
			"ampersand: &, quotation mark: \", apostrophe: ', less than: < "
			"and greater than char: >.");
		root->AddChild (child1);

		root->AddText ("This is my next child");

		XML::Node * node = root->AddChild ("child");
		node->AddAttribute ("num", 2);
		node->AddAttribute ("level", 1);
		XML::Node * grandChild = node->AddEmptyChild ("Grandchild");
		grandChild->AddAttribute ("age", 2);
		tree.Write (out);

		XML::Node const * firstChild = *tree.GetRoot ()->FirstChild ();
		out << "\n\nTransform back upper-ascii characters: " 
			<< firstChild->GetTransformAttribValue ("upperExamples") << std::endl;
		out << "\nTransform back the text: " 
			<< (*firstChild->FirstChild ())->GetTransformAttribValue ("Text") << std::endl;
	}
		void Configuration::Node::Save(Xml::Node node,wcstring const key) const
		{
			NST_ASSERT( node && (!key || *key) );

			if (map.empty())
			{
				if (key)
					node.AddChild( key, string.Ptr() );
			}
			else
			{
				if (key)
					node = node.AddChild( key );

				for (Map::const_iterator it(map.begin()), end(map.end()); it != end; ++it)
					it->second.Save( node, it->first.Ptr() );
			}
		}
Exemple #3
0
gboolean gtkui_cheats_write_list(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer userdata) {
	// Write entries to the cheat file
	bool enabled;
	gchar *ggcode, *parcode, *rawcode, *description;
	
	char buf[9];
	wchar_t wbuf[9];
	
	gtk_tree_model_get(model, iter, 0, &enabled, 1, &ggcode, 2, &parcode, 3, &rawcode, 4, &description, -1);
	
	Xml::Node node(saveroot.AddChild(L"cheat"));
	node.AddAttribute(L"enabled", enabled ? L"1" : L"0");
	
	if (ggcode) {
		snprintf(buf, sizeof(buf), "%s", ggcode);
		mbstowcs(wbuf, buf, 9);
		node.AddChild(L"genie", wbuf);
	}
	if (parcode) {
		snprintf(buf, sizeof(buf), "%s", parcode);
		mbstowcs(wbuf, buf, 9);
		node.AddChild(L"rocky", wbuf);
	}
	if (rawcode) {
		snprintf(buf, sizeof(buf), "0x%c%c%c%c", rawcode[0], rawcode[1], rawcode[2], rawcode[3]);
		mbstowcs(wbuf, buf, 9);
		node.AddChild(L"address", wbuf);
		
		snprintf(buf, sizeof(buf), "0x%c%c", rawcode[5], rawcode[6]);
		mbstowcs(wbuf, buf, 9);
		node.AddChild(L"value", wbuf);
		
		snprintf(buf, sizeof(buf), "0x%c%c", rawcode[8], rawcode[9]);
		mbstowcs(wbuf, buf, 9);
		node.AddChild(L"compare", wbuf);
	}
	if (description) {
		char descbuf[512];
		wchar_t wdescbuf[512];
		
		snprintf(descbuf, sizeof(descbuf), "%s", description);
		mbstowcs(wdescbuf, descbuf, 512);
		node.AddChild(L"description", wdescbuf);
	}
		
	g_free(ggcode);
	g_free(parcode);
	g_free(rawcode);
	g_free(description);
	
	return false;
}