Exemplo n.º 1
0
bool cSubMenu::SaveXml(char *fname )
{

    if (_fname)
    {
        TiXmlDocument xml = TiXmlDocument(fname );
        TiXmlComment  comment;
        comment.SetValue(
            " Mini-VDR cSetupConfiguration File\n"
            " (c) Ralf Dotzert\n"
            "\n\n"
            " for Example see vdr-menu.xml.example\n\n"
        );

        TiXmlElement root("menus");
        root.SetAttribute("suffix",   _menuSuffix);
        for (cSubMenuNode *node = _menuTree.First(); node; node = _menuTree.Next(node))
            node->SaveXml(&root);

        if (xml.InsertEndChild(comment) != NULL &&
                xml.InsertEndChild(root) != NULL)
        {
            return xml.SaveFile(fname);
        }
    }
    else
    {
        return false;
    }

    return true;
}
Exemplo n.º 2
0
void kore::ProjectLoader::saveProject(const std::string& path) const {
  ResourceManager* ResMgr = ResourceManager::getInstance();

  TiXmlDocument doc;
  TiXmlDeclaration* decl = new TiXmlDeclaration("1.0", "", "yes");
  doc.LinkEndChild(decl);

  TiXmlComment * comment = new TiXmlComment();
  time_t rawtime;
  time(&rawtime);
  comment->SetValue(ctime(&rawtime));
  doc.LinkEndChild(comment);

  // Resources
  TiXmlElement* resources = new TiXmlElement("Resources");
  doc.LinkEndChild(resources);

  // Textures
  TiXmlElement* texture;
  std::map<std::string, TexturePtr>::iterator texIt;
  for(texIt = ResMgr->_textures.begin();
      texIt != ResMgr->_textures.end();
      texIt++) {
    texture = new TiXmlElement("Texture");
    STextureProperties prop = texIt->second->getProperties();
    texture->SetAttribute("name", texIt->second->getName().c_str());
    texture->SetAttribute("width", prop.width);
    texture->SetAttribute("height", prop.height);
    resources->LinkEndChild(texture);
  }

  // TODO(dospelt) the rest

  TiXmlElement* scene = new TiXmlElement("Scene");
  doc.LinkEndChild(scene);
  kore::SceneNodePtr root = kore::SceneManager::getInstance()->getRootNode();

  //saveSceneNode(scene, root);

  

  // finally, save to file
  if(doc.SaveFile(path.c_str())) {
    kore::Log::getInstance()->write("[DEBUG] writing file '%s'\n",
                                    path.c_str());
  } else {
    kore::Log::getInstance()->write("[ERROR] could not write file '%s'\n",
                                    path.c_str());
  }

  // TODO(dospelt) runtime error when deleting created pointers.
  // it seems they get automatically deleted when saving File -> tinyxmlDoku?

  // delete resources;
  // delete comment;
}
Exemplo n.º 3
0
/* Method save_xml */
void ClusterSettings::save_xml (const Glib::ustring& filename)
{
  /* Create xml document */
  TiXmlDocument doc;

  /* XML Declaration */
  TiXmlDeclaration *decl = new TiXmlDeclaration ("0.0", "", "");
  doc.LinkEndChild (decl);

  /* Root element */
  TiXmlElement *root = new TiXmlElement ("SensorsClusterSettings");
  doc.LinkEndChild (root);

  /* Comment */
  Glib::ustring message;
  message.assign (" File created by ComLibSim at [");
  message.append (filename);
  message.append ("] ");
  TiXmlComment *comment = new TiXmlComment ();
  comment->SetValue (message.c_str ());
  root->LinkEndChild (comment);

  /* Cluster element */
  TiXmlElement *cluster = new TiXmlElement ("Cluster");
  root->LinkEndChild (cluster);

  /* Set cluster attribute */
  cluster->SetAttribute ("name", m_Name.c_str ());

  /* Sensors element */
  TiXmlElement *sensorsNode = new TiXmlElement ("Sensors");
  root->LinkEndChild (sensorsNode);

  /* Set sensor element and attributes */
  std::list<SensorSettings>::iterator iter;
  for (iter=m_Sensors.begin (); iter != m_Sensors.end (); iter++)
  {
    const SensorSettings& sensor_iter = *iter;

    /* Sensor element */
    TiXmlElement *sensor = new TiXmlElement ("Sensor");
    sensorsNode->LinkEndChild (sensor);

    /* Set sensor attributes */
    sensor->SetAttribute ("tag", iter->get_tag ().c_str ());
    sensor->SetAttribute ("online", iter->get_online ());
    sensor->SetDoubleAttribute ("x", iter->get_x_coord ());
    sensor->SetDoubleAttribute ("y", iter->get_y_coord ());
    sensor->SetAttribute ("adata", iter->get_amount_data ());
    sensor->SetAttribute ("type", iter->get_type ().c_str ());
  }

  /* Save xml to file */
  doc.SaveFile (filename.c_str ());
}
Exemplo n.º 4
0
BOOL __stdcall DefaultLaserPen::save(LPCTSTR lpszFileName)
{
    assert( lpszFileName);
    FILE* stream = _tfopen(lpszFileName, _T("wb"));
    if (NULL == stream)
        return FALSE;	

	//tinyxml lib
	TiXmlDocument doc;
	TiXmlDeclaration* pDecl = new TiXmlDeclaration("1.0", "euc-kr", "");  
	doc.LinkEndChild(pDecl);

	TiXmlElement* pRoot = new TiXmlElement("laserpen");
	pRoot->SetAttribute("version", DA0LIB_VERSION);
	pRoot->SetAttribute("count", this->size() );
	doc.LinkEndChild(pRoot);

	TiXmlComment * pComment = new TiXmlComment();
	pComment->SetValue("2014 copyright to KOSES. all rights reserved. created by da0lib." );  
	pRoot->LinkEndChild( pComment );  

	CONTAINER_IT it = _pPimpl->container.begin();
	for (; it != _pPimpl->container.end(); it++)
    {
		LASERPEN* pPen = it->second;
		assert(pPen);

		TiXmlElement* p = new TiXmlElement("pen");
		p->SetAttribute("id", pPen->penid);
		p->SetAttribute("frequency", pPen->frequency);		
		p->SetDoubleAttribute("pulsewidth", pPen->pulsewidth);
		p->SetDoubleAttribute("output", pPen->output);

		p->SetDoubleAttribute("speedmark" , pPen->speedmark);
		p->SetDoubleAttribute("speedjump" , pPen->speedjump);
		p->SetDoubleAttribute("delayoff" , pPen->delayoff);
		p->SetDoubleAttribute("delayon" , pPen->delayon);

		p->SetDoubleAttribute("delayjump" , pPen->delayjump);
		p->SetDoubleAttribute("delaymark" , pPen->delaymark);		
		p->SetDoubleAttribute("delaypolygon" , pPen->delaypolygon);

		p->SetAttribute("wobbelfrequency" , pPen->wobbelfrequency);
		p->SetDoubleAttribute("wobbelamplitude" , pPen->wobbelamplitude);

		pRoot->LinkEndChild(p);
    }
	
	doc.SaveFile(stream);
    fclose( stream );
    return TRUE;
}
Exemplo n.º 5
0
/*
 * Generates setting placeholders for any missing sections
 * ** Plugins should verify that their settings exist and
 * ** create new placeholders if they do not exist!
 */
void Configuration::generateConfig()
{
	TiXmlDeclaration* decl = new TiXmlDeclaration("1.0", "", "");
	configs.LinkEndChild(decl);

	TiXmlElement* root = new TiXmlElement("osdb");
	configs.LinkEndChild(root);

	TiXmlComment* comment = new TiXmlComment();
	comment->SetValue(" Settings for OSDB ");
	root->LinkEndChild(comment);

	setConfigSetting("main", "logFilePath", "osdb.log");
	setConfigSetting("main", "useStdOut", "true");
}
Exemplo n.º 6
0
void SimXMLDocument::addComment(const char* comment)
{
   TiXmlComment cComment;
   cComment.SetValue(comment);

   if(m_paNode.empty()) 
   {
       Con::warnf("Cannot add comment without any elements: '%s'", comment);
       return;
   }

    const int iFinalElement = m_paNode.size() - 1;
    TiXmlElement* pNode = m_paNode[iFinalElement];
    if(!pNode)
    {
        return;
    }
    pNode->InsertEndChild( cComment );
}
Exemplo n.º 7
0
void COptions::WriteXMLData()
{
    // Create document
    TiXmlDocument newConfig;
    TiXmlDeclaration* decl = new TiXmlDeclaration( "1.0", "UTF-8", "" );
    newConfig.LinkEndChild( decl );

    // Root node
    TiXmlElement * root = new TiXmlElement( "Bombermaaan" );
    newConfig.LinkEndChild( root );

    // Comment
    TiXmlComment * comment = new TiXmlComment();
    comment->SetValue(" Configuration settings for the Bombermaaan game (http://bombermaaan.sf.net/) " );
    root->LinkEndChild( comment );

    // Configuration tree node - all options have this node as parent
    TiXmlElement * config = new TiXmlElement( "Configuration" );
    root->LinkEndChild( config );

    //! The revision number is currently 1
    TiXmlElement* configRev = new TiXmlElement( "ConfigRevision" );
    configRev->SetAttribute( "value", 1 );
    config->LinkEndChild( configRev );

    // TimeUp (when will arena close begin)
    TiXmlElement* configTimeUp = new TiXmlElement( "TimeUp" );
    configTimeUp->SetAttribute( "minutes", m_TimeUpMinutes );
    configTimeUp->SetAttribute( "seconds", m_TimeUpSeconds );
    config->LinkEndChild( configTimeUp );

    // TimeStart (the duration of a match)
    TiXmlElement* configTimeStart = new TiXmlElement( "TimeStart" );
    configTimeStart->SetAttribute( "minutes", m_TimeStartMinutes );
    configTimeStart->SetAttribute( "seconds", m_TimeStartSeconds );
    config->LinkEndChild( configTimeStart );

    // BattleMode
    TiXmlElement* configBattleMode = new TiXmlElement("BattleMode");
    configBattleMode->SetAttribute("value", m_BattleMode);
    config->LinkEndChild(configBattleMode);

    // BattleCount
    TiXmlElement* configBattleCount = new TiXmlElement( "BattleCount" );
    configBattleCount->SetAttribute( "value", m_BattleCount );
    config->LinkEndChild( configBattleCount );

    // LevelFileNumber
    TiXmlElement* configLevel = new TiXmlElement( "LevelFileNumber" );
    configLevel->SetAttribute( "value", m_Level );
    config->LinkEndChild( configLevel );

    // DisplayMode
    TiXmlElement* configDisplayMode = new TiXmlElement( "DisplayMode" );
    configDisplayMode->SetAttribute( "value", (int) m_DisplayMode );
    config->LinkEndChild( configDisplayMode );

    int i;

    // BomberTypes
    TiXmlElement* configBomberTypes = new TiXmlElement( "BomberTypes" );
    for ( i = 0; i < MAX_PLAYERS; i++ ) {
        std::ostringstream oss;
        oss << "bomber" << i;
        std::string attributeName = oss.str();
        configBomberTypes->SetAttribute( attributeName, (int) m_BomberType[i] );
    }
    config->LinkEndChild( configBomberTypes );

    // BomberTeams
    TiXmlElement* configBomberTeams = new TiXmlElement("BomberTeams");
    for (i = 0; i < MAX_PLAYERS; i++) {
        std::ostringstream oss;
        oss << "bomber" << i;
        std::string attributeName = oss.str();
        configBomberTeams->SetAttribute(attributeName, (int)m_BomberTeam[i]);
    }
    config->LinkEndChild(configBomberTeams);

    // PlayerInputs
    TiXmlElement* configPlayerInputs = new TiXmlElement( "PlayerInputs" );
    for ( i = 0; i < MAX_PLAYERS; i++ ) {
        std::ostringstream oss;
        oss << "bomber" << i;
        std::string attributeName = oss.str();
        configPlayerInputs->SetAttribute( attributeName, (int) m_PlayerInput[i] );
    }
    config->LinkEndChild( configPlayerInputs );

    // ControlList
    TiXmlElement* configControlList = new TiXmlElement( "ControlList" );
    for ( unsigned int j = 0; j < MAX_PLAYER_INPUT; j++ )
    {
        TiXmlElement* configControl = new TiXmlElement( "Control" );
        configControl->SetAttribute( "id", j );
        for ( unsigned int ctrl = 0; ctrl < NUM_CONTROLS; ctrl++ )
        {
            std::ostringstream oss;
            oss << "control" << ctrl;
            std::string attributeName = oss.str();
            configControl->SetAttribute( attributeName, (int) m_Control[j][ctrl] );
        }
        configControlList->LinkEndChild( configControl );
    }
    config->LinkEndChild( configControlList );


    //
    // Save file
    //
    bool saveOkay = newConfig.SaveFile( configFileName );

    // Log a message
    theLog.WriteLine( "Options         => Configuration file was %s written.", ( saveOkay ? "successfully" : "not" ) );
}
Exemplo n.º 8
0
void CfgMgrBldr::SwitchTo(const wxString& fileName)
{
    doc = new TiXmlDocument();

    if (!TinyXML::LoadDocument(fileName, doc))
    {
        doc->InsertEndChild(TiXmlDeclaration("1.0", "UTF-8", "yes"));
        doc->InsertEndChild(TiXmlElement("CodeBlocksConfig"));
        doc->FirstChildElement("CodeBlocksConfig")->SetAttribute("version", CfgMgrConsts::version);
    }

    if (doc->ErrorId())
        cbThrow(wxString::Format(_T("TinyXML error: %s\nIn file: %s\nAt row %d, column: %d."), cbC2U(doc->ErrorDesc()).c_str(), fileName.c_str(), doc->ErrorRow(), doc->ErrorCol()));

    TiXmlElement* docroot = doc->FirstChildElement("CodeBlocksConfig");

    if (doc->ErrorId())
        cbThrow(wxString::Format(_T("TinyXML error: %s\nIn file: %s\nAt row %d, column: %d."), cbC2U(doc->ErrorDesc()).c_str(), fileName.c_str(), doc->ErrorRow(), doc->ErrorCol()));

    const char *vers = docroot->Attribute("version");
    if (!vers || atoi(vers) != 1)
        cbMessageBox(_("ConfigManager encountered an unknown config file version. Continuing happily."), _("Warning"), wxICON_WARNING);

    doc->ClearError();

    wxString info;
#ifndef __GNUC__
    info.Printf(_T( " application info:\n"
                    "\t svn_revision:\t%u\n"
                    "\t build_date:\t%s, %s "), ConfigManager::GetRevisionNumber(), wxT(__DATE__), wxT(__TIME__));
#else
    info.Printf(_T( " application info:\n"
                    "\t svn_revision:\t%u\n"
                    "\t build_date:\t%s, %s\n"
                    "\t gcc_version:\t%d.%d.%d "), ConfigManager::GetRevisionNumber(), wxT(__DATE__), wxT(__TIME__),
                __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
#endif

    if (platform::windows)
        info.append(_T("\n\t Windows "));
    if (platform::linux)
        info.append(_T("\n\t Linux "));
    if (platform::macosx)
        info.append(_T("\n\t Mac OS X "));
    if (platform::unix)
        info.append(_T("\n\t Unix "));

    info.append(platform::unicode ? _T("Unicode ") : _T("ANSI "));

    TiXmlComment c;
    c.SetValue((const char*) info.mb_str());

    TiXmlNode *firstchild = docroot->FirstChild();
    if (firstchild && firstchild->ToComment())
    {
        docroot->RemoveChild(firstchild);
        firstchild = docroot->FirstChild();
    }

    if (firstchild)
        docroot->InsertBeforeChild(firstchild, c);
    else
        docroot->InsertEndChild(c);
}
Exemplo n.º 9
0
// save world information into file
void MapInfoXmlWriter::SaveWorld(const std::string Filename, const WorldInfo & wi)
{
	TiXmlDocument doc;
	TiXmlComment * comment;
	std::string s;

 	TiXmlDeclaration* decl = new TiXmlDeclaration( "1.0", "", "" );
	doc.LinkEndChild( decl );

	TiXmlElement * root = new TiXmlElement("World");
	doc.LinkEndChild( root );
	root->SetAttribute("name", wi.Name);
	root->SetAttribute("firstmap", wi.FirstMap);
	root->SetAttribute("firstsparea", wi.FirstSpawning);

	TiXmlElement * desc = new TiXmlElement( "description" );
	root->LinkEndChild(desc);
	desc->LinkEndChild(new TiXmlText(wi.Description));

	// block: teleport
	{
		comment = new TiXmlComment();
		s="Define the place it is possible to teleport to, the first place is the place where we arrive in the world";
		comment->SetValue(s.c_str());
		root->LinkEndChild( comment );

		TiXmlElement * tps = new TiXmlElement( "teleports" );
		root->LinkEndChild(tps);


		std::map<std::string, TPInfo>::const_iterator it = wi.Teleports.begin();
		std::map<std::string, TPInfo>::const_iterator end = wi.Teleports.end();
		for(; it != end; ++it)
		{
			TiXmlElement * tp = new TiXmlElement( "teleport" );
			tps->LinkEndChild(tp);

			tp->SetAttribute("name", it->second.Name);
			tp->SetAttribute("map", it->second.NewMap);
			tp->SetAttribute("sparea", it->second.Spawning);
		}
	}

		// file info block
		{
			TiXmlElement * files = new TiXmlElement( "files" );
			root->LinkEndChild(files);

			std::map<std::string, std::string>::const_iterator it2 = wi.Files.begin();
			std::map<std::string, std::string>::const_iterator end2 = wi.Files.end();
			for(; it2 != end2; ++it2)
			{
				TiXmlElement * file = new TiXmlElement( "file" );
				files->LinkEndChild(file);

				file->SetAttribute("name", it2->first);
				file->SetAttribute("path", it2->second);
			}
		}



	TiXmlElement * maps = new TiXmlElement( "maps" );
	root->LinkEndChild(maps);

	std::map<std::string, MapInfo>::const_iterator it = wi.Maps.begin();
	std::map<std::string, MapInfo>::const_iterator end = wi.Maps.end();
	for(; it != end; ++it)
	{
		comment = new TiXmlComment();
		s="Map of "+it->second.Description;
		comment->SetValue(s.c_str());
		maps->LinkEndChild( comment );


		TiXmlElement * map = new TiXmlElement( "Map" );
		maps->LinkEndChild(map);

		map->SetAttribute("name", it->first);
		map->SetAttribute("type", it->second.Type);
		map->SetAttribute("music", it->second.Music);
		map->SetAttribute("repeatmusic", it->second.MusicLoop);


		TiXmlElement * descm = new TiXmlElement( "description" );
		map->LinkEndChild(descm);
		descm->LinkEndChild(new TiXmlText(it->second.Description));


		// file info block
		{
			comment = new TiXmlComment();
			s="Give the path of the files containing the island information to be loaded";
			comment->SetValue(s.c_str());
			map->LinkEndChild( comment );

			TiXmlElement * files = new TiXmlElement( "files" );
			map->LinkEndChild(files);

			std::map<std::string, std::string>::const_iterator it2 = it->second.Files.begin();
			std::map<std::string, std::string>::const_iterator end2 = it->second.Files.end();
			for(; it2 != end2; ++it2)
			{
				TiXmlElement * file = new TiXmlElement( "file" );
				files->LinkEndChild(file);

				file->SetAttribute("name", it2->first);
				file->SetAttribute("path", it2->second);
			}
		}


		// light info block
		{
			comment = new TiXmlComment();
			s="Describe the lights present in the scene";
			comment->SetValue(s.c_str());
			map->LinkEndChild( comment );

			TiXmlElement * lights = new TiXmlElement( "lights" );
			map->LinkEndChild(lights);

			std::map<std::string, LighInfo>::const_iterator it2 = it->second.Lights.begin();
			std::map<std::string, LighInfo>::const_iterator end2 = it->second.Lights.end();
			for(; it2 != end2; ++it2)
			{
				TiXmlElement * light = new TiXmlElement( "light" );
				lights->LinkEndChild(light);

				light->SetAttribute("name", it2->first);
				light->SetAttribute("type", it2->second.Type);

				light->SetAttribute("posX", it2->second.PosX);
				light->SetAttribute("posY", it2->second.PosY);
				light->SetAttribute("posZ", it2->second.PosZ);
				light->SetAttribute("dirX", it2->second.DirX);
				light->SetAttribute("dirY", it2->second.DirY);
				light->SetAttribute("dirZ", it2->second.DirZ);
			}
		}


		// spawning areas info block
		{
			comment = new TiXmlComment();
			s="Describe the possible spawning areas of the main character";
			comment->SetValue(s.c_str());
			map->LinkEndChild( comment );

			TiXmlElement * spareas = new TiXmlElement( "spareas" );
			map->LinkEndChild(spareas);

			std::map<std::string, SpawningInfo>::const_iterator it2 = it->second.Spawnings.begin();
			std::map<std::string, SpawningInfo>::const_iterator end2 = it->second.Spawnings.end();
			for(; it2 != end2; ++it2)
			{
				TiXmlElement * sparea = new TiXmlElement( "sparea" );
				spareas->LinkEndChild(sparea);

				sparea->SetAttribute("name", it2->first);

				sparea->SetDoubleAttribute("posX", it2->second.PosX);
				sparea->SetDoubleAttribute("posY", it2->second.PosY);
				sparea->SetDoubleAttribute("posZ", it2->second.PosZ);
				sparea->SetAttribute("RotationAtArrival", it2->second.Rotation);
			}
		}


		// map exit info block
		{
			comment = new TiXmlComment();
			s="Describe the possible map exit places using square areas from TopLeft point to BottomRight point";
			comment->SetValue(s.c_str());
			map->LinkEndChild( comment );

			TiXmlElement * exits = new TiXmlElement( "exits" );
			map->LinkEndChild(exits);

			std::map<std::string, ExitInfo>::const_iterator it2 = it->second.Exits.begin();
			std::map<std::string, ExitInfo>::const_iterator end2 = it->second.Exits.end();
			for(; it2 != end2; ++it2)
			{
				TiXmlElement * exit = new TiXmlElement( "exit" );
				exits->LinkEndChild(exit);

				exit->SetAttribute("name", it2->first);

				exit->SetDoubleAttribute("TopRightX", it2->second.TopRightX);
				exit->SetDoubleAttribute("TopRightY", it2->second.TopRightY);
				exit->SetDoubleAttribute("TopRightZ", it2->second.TopRightZ);

				exit->SetDoubleAttribute("BottomLeftX", it2->second.BottomLeftX);
				exit->SetDoubleAttribute("BottomLeftY", it2->second.BottomLeftY);
				exit->SetDoubleAttribute("BottomLeftZ", it2->second.BottomLeftZ);

				exit->SetAttribute("newMap", it2->second.NewMap);
				exit->SetAttribute("spawning", it2->second.Spawning);
			}
		}

	}

	doc.SaveFile(Filename);
}
Exemplo n.º 10
0
Arquivo: input.cpp Projeto: zurn/Zakes
void input::saveKeys()
{
//	printf("saving control file\n");

	TiXmlDocument doc;
	TiXmlElement* msg;
	TiXmlDeclaration * decl = new TiXmlDeclaration("1.0", "", "");
	doc.LinkEndChild(decl );

	TiXmlElement * root = new TiXmlElement("controls");
	doc.LinkEndChild(root );

	TiXmlComment * comment = new TiXmlComment();
	comment->SetValue("Keyboard mappings");
	root->LinkEndChild(comment );

	TiXmlElement * msgs = new TiXmlElement("keys");
	root->LinkEndChild(msgs );

	msg = new TiXmlElement("accept");
	msg->SetAttribute("value", input::keys[KEY_ACCEPT]->binding);
	msgs->LinkEndChild(msg);

	msg = new TiXmlElement("accept_d1");
	msg->SetAttribute("value", input::keys[KEY_DBG_ACCEPT1]->binding);
	msgs->LinkEndChild(msg);

	msg = new TiXmlElement("accept_d2");
	msg->SetAttribute("value", input::keys[KEY_DBG_ACCEPT2]->binding);
	msgs->LinkEndChild(msg);

	msg = new TiXmlElement("cancel");
	msg->SetAttribute("value", input::keys[KEY_CANCEL]->binding);
	msgs->LinkEndChild(msg);

	msg = new TiXmlElement("up");
	msg->SetAttribute("value", input::keys[KEY_UP]->binding);
	msgs->LinkEndChild(msg);

	msg = new TiXmlElement("up_d");
	msg->SetAttribute("value", input::keys[KEY_DBG_UP]->binding);
	msgs->LinkEndChild(msg);

	msg = new TiXmlElement("down");
	msg->SetAttribute("value", input::keys[KEY_DOWN]->binding);
	msgs->LinkEndChild(msg);

	msg = new TiXmlElement("down_d");
	msg->SetAttribute("value", input::keys[KEY_DBG_DOWN]->binding);
	msgs->LinkEndChild(msg);

	msg = new TiXmlElement("left");
	msg->SetAttribute("value", input::keys[KEY_LEFT]->binding);
	msgs->LinkEndChild(msg);

	msg = new TiXmlElement("left_d");
	msg->SetAttribute("value", input::keys[KEY_DBG_LEFT]->binding);
	msgs->LinkEndChild(msg);

	msg = new TiXmlElement("right");
	msg->SetAttribute("value", input::keys[KEY_RIGHT]->binding);
	msgs->LinkEndChild(msg);

	msg = new TiXmlElement("right_d");
	msg->SetAttribute("value", input::keys[KEY_DBG_RIGHT]->binding);
	msgs->LinkEndChild(msg);

	msg = new TiXmlElement("upleft");
	msg->SetAttribute("value", input::keys[KEY_UPLEFT]->binding);
	msgs->LinkEndChild(msg);

	msg = new TiXmlElement("upright");
	msg->SetAttribute("value", input::keys[KEY_UPRIGHT]->binding);
	msgs->LinkEndChild(msg);

	msg = new TiXmlElement("downleft");
	msg->SetAttribute("value", input::keys[KEY_DOWNLEFT]->binding);
	msgs->LinkEndChild(msg);

	msg = new TiXmlElement("downright");
	msg->SetAttribute("value", input::keys[KEY_DOWNRIGHT]->binding);
	msgs->LinkEndChild(msg);

	msg = new TiXmlElement("attack");
	msg->SetAttribute("value", input::keys[KEY_ATTACK]->binding);
	msgs->LinkEndChild(msg);

	msg = new TiXmlElement("spells");
	msg->SetAttribute("value", input::keys[KEY_SPELLS]->binding);
	msgs->LinkEndChild(msg);

	msg = new TiXmlElement("inventory");
	msg->SetAttribute("value", input::keys[KEY_INVENTORY]->binding);
	msgs->LinkEndChild(msg);

	msg = new TiXmlElement("interact");
	msg->SetAttribute("value", input::keys[KEY_INTERACT]->binding);
	msgs->LinkEndChild(msg);

	msg = new TiXmlElement("search");
	msg->SetAttribute("value", input::keys[KEY_SEARCH]->binding);
	msgs->LinkEndChild(msg);

	msg = new TiXmlElement("options");
	msg->SetAttribute("value", input::keys[KEY_OPTIONS]->binding);
	msgs->LinkEndChild(msg);

	msg = new TiXmlElement("quit");
	msg->SetAttribute("value", input::keys[KEY_QUIT]->binding);
	msgs->LinkEndChild(msg);

	msg = new TiXmlElement("run");
	msg->SetAttribute("value", input::keys[KEY_RUN]->binding);
	msgs->LinkEndChild(msg);

	msg = new TiXmlElement("db_quit");
	msg->SetAttribute("value", input::keys[KEY_DBG_QUIT]->binding);
	msgs->LinkEndChild(msg);

	msg = new TiXmlElement("db_shot");
	msg->SetAttribute("value", input::keys[KEY_DBG_SHOT]->binding);
	msgs->LinkEndChild(msg);

	msg = new TiXmlElement("dbg1");
	msg->SetAttribute("value", input::keys[KEY_DBG_1]->binding);
	msgs->LinkEndChild(msg);

	msg = new TiXmlElement("dbg2");
	msg->SetAttribute("value", input::keys[KEY_DBG_2]->binding);
	msgs->LinkEndChild(msg);


	doc.SaveFile(INPUT_CONFIG);

}
void CSettingsManager::write_SettingsXML()
{
  try
  {
    if(m_Settings.size() > 0)
    {
      TiXmlDocument doc;
      // ToDo: check all TiXml* generations!
      TiXmlDeclaration *declaration = new TiXmlDeclaration("1.0", "", "");
      doc.LinkEndChild(declaration);
      TiXmlComment *autoGenComment = new TiXmlComment();
      autoGenComment->SetValue(" THIS IS A AUTO GENERTATED FILE. DO NOT EDIT! ");
      doc.LinkEndChild(autoGenComment);

      for(SettingsMap::iterator mapIter = m_Settings.begin(); mapIter != m_Settings.end(); mapIter++)
      {
        vector<string> tokens;
        strTokenizer(mapIter->first, SETTINGS_SEPERATOR_STR, tokens);
        if(tokens.size() != 3)
        {
          doc.Clear();
          KODI->Log(LOG_ERROR, "Line: %i func: %s, Saving XML-File failed! Wrong SettingsMap string! Please call contact Addon author!\n", __LINE__, __func__, m_XMLFilename.c_str());
          return;
        }

        TiXmlElement *mainCategory = NULL;
        // check if this main category is already available
        for(TiXmlNode *element = doc.FirstChild(); element && !mainCategory; element = element->NextSiblingElement())
        {
          if(element->Value() == tokens[0])
          {
            mainCategory = static_cast<TiXmlElement*>(element);
          }
        }

        if(!mainCategory)
        { // create new main category
          mainCategory = new TiXmlElement(tokens[0]);
          doc.LinkEndChild(mainCategory);
        }

        TiXmlElement *settingsGroup = new TiXmlElement("settings_group");
        settingsGroup->SetAttribute("sub_category", tokens[1].c_str());
        settingsGroup->SetAttribute("group_name", tokens[2].c_str());
        mainCategory->LinkEndChild(settingsGroup);

        for(CSettingsList::iterator setIter=mapIter->second.begin(); setIter != mapIter->second.end(); setIter++)
        {
          if(!*setIter)
          {
            KODI->Log(LOG_ERROR, "Line: %i func: %s, invalid settings element! Please call contact Addon author!\n", __LINE__, __func__);
            return;
          }
          TiXmlElement *setting = new TiXmlElement("setting");
          setting->SetAttribute("key", (*setIter)->get_Key().c_str());

          switch((*setIter)->get_Type())
          {
            case ISettingsElement::STRING_SETTING:
              setting->SetAttribute("string", STRING_SETTINGS(*setIter)->get_Setting().c_str());
            break;

            case ISettingsElement::UNSIGNED_INT_SETTING:
              setting->SetAttribute("unsigned_int", toString(UNSIGNED_INT_SETTINGS(*setIter)->get_Setting()).c_str());
            break;

            case ISettingsElement::INT_SETTING:
              setting->SetAttribute("int", INT_SETTINGS(*setIter)->get_Setting());
            break;

            case ISettingsElement::FLOAT_SETTING:
              setting->SetDoubleAttribute("float", (double)FLOAT_SETTINGS(*setIter)->get_Setting());
            break;

            case ISettingsElement::DOUBLE_SETTING:
              setting->SetDoubleAttribute("double", DOUBLE_SETTINGS(*setIter)->get_Setting());
            break;

            case ISettingsElement::BOOL_SETTING:
              if(BOOL_SETTINGS(*setIter)->get_Setting())
              {
                setting->SetAttribute("bool", "true");
              }
              else
              {
                setting->SetAttribute("bool", "false");
              }
            break;

            default:
              KODI->Log(LOG_ERROR, "Line: %i func: %s, invalid settings type! Please call contact Addon author!\n", __LINE__, __func__);
              return;
            break;
          }

          settingsGroup->LinkEndChild(setting);
        }
      }

      if(!doc.SaveFile(m_XMLFilename.c_str()))
      {
        KODI->Log(LOG_ERROR, "Couldn't save XML settings to file %s", m_XMLFilename.c_str());
      }
    }
  }
  catch(bad_alloc &e)
  {
    KODI->Log(LOG_ERROR, "In function: %s a invalid memory allocation accured! Not enough free memory? Exception message: %s\n", __func__, e.what());
  }
}