#include <tchar.h>
#include <fstream>
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int lineCount = 0;
ifstream ifs("eve-items2.xml");
ofstream ofs("EVEDB_Items.xml");
ofs << "<?xml version='1.0' encoding='UTF-8'?>" << endl;
ofs << "<!-- Generated by LavishSettings v2 -->" << endl;
ofs << "<InnerSpaceSettings>" << endl;
ofs << " <Set Name=\"EVEDB_Items\">" << endl;
while( !ifs.bad() && !ifs.eof() )
{
char buf[4096];
ifs.getline(buf,sizeof(buf));
if( buf[0] == 0 ) break;
lineCount++;
if( strstr(buf,"<Item Id=\"") )
{
char itemID[33];
char itemName[129];
char *pTok;
// this is a hack. it assumes that the ID is first and Name second.
pTok = strtok(buf,"\"");
pTok = strtok(NULL,"\"");
strcpy(itemID,pTok);
pTok = strtok(NULL,"\"");
pTok = strtok(NULL,"\"");
strcpy(itemName,pTok);
ofs << " <Set Name=\"" << itemName << "\">" << endl;
ofs << " <Setting Name=\"itemID\">" << itemID << "</Setting>" << endl ;
ofs << " </Set>" << endl;
}
}
ofs << " </Set>" << endl;
ofs << "</InnerSpaceSettings>" << endl;
ifs.close();
ofs.close();
cout << "Read " << lineCount << " lines." << endl;
return 0;
}