Exemple #1
0
void SaveIni(INIFile &theINI, const char *filename)
{
	std::fstream file(filename, std::ios::out);
	if(!file.good())
		return;
	
	// just iterate the hashes and values and dump them to a file.
	INIFile::iterator section= theINI.begin();
	while(section != theINI.end())
	{
		if(section->first > "") 
			file << std::endl << "[" << section->first << "]" << std::endl;
		INISection::iterator pair = section->second.begin();
	
		while(pair != section->second.end())
		{
			if(pair->second > "")
				file << pair->first << "=" << pair->second << std::endl;
			else
				file << pair->first << std::endl;
			pair++;
		}
		section++;
	}
	file.close();
}
Exemple #2
0
void DumpIni(INIFile &ini)
{
	// This is essentially SaveIni() except it just dumps to stdout
	INIFile::iterator section= ini.begin();
	while(section != ini.end())
	{
		cout << std::endl << "[" << section->first << "]" << std::endl;
		INISection sectionvals = section->second;
		INISection::iterator pair = sectionvals.begin();
	
		while(pair != sectionvals.end())
		{
			cout << pair->first ;
			if(pair->second > "")
				cout << "=" << pair->second;
			cout << std::endl;
			pair++;
		}
		section++;
	}
}