#include <iostream>
#include <map>
#include <fstream>
#include <string>
#include <vector>
class DataFile
{
public:
DataFile() { }
~DataFile() { }
// Beschreibung: Datenfile laden
// Rückgabewert: true oder false
// Parameter: Datei, Trennzeichen
bool Load(
const std::string &strFilename,
const std::string &strSeparators = "\t:=")
{
m_mSettings.clear();
std::ifstream file(strFilename.c_str(), std::ios::in);
if(!file) return false;
std::string strTemp;
while(std::getline(file, strTemp))
{
// Trim(strTemp);
// leerzeilen und kommentare ignorieren
if(
strTemp.length() > 0 &&
strTemp[0] != '#' &&
strTemp[0] != '@' &&
strTemp[0] != '\n')
{
std::vector<std::string> v;
// Split(strTemp, strSeparators.c_str(), v);
m_mSettings.insert(SettingsList::value_type(v[0], v[1]));
}
}
file.close();
return true;
}
// Beschreibung: Einstellung holen
// Rückgabewert:
// Parameter: Name, Referenz auf Objekt
template<typename T> void GetSetting(const std::string &strKey, T &t)
{
SettingsList::const_iterator it = m_mSettings.find(strKey);
if(it == m_mSettings.end()) return;
// Convert((it)->second, t);
}
private:
typedef std::multimap<std::string, std::string> SettingsList;
SettingsList m_mSettings;
};