1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-10 06:39:49 +00:00

add the section to the ini-keys

This commit is contained in:
Sebastian Wick 2012-03-30 23:12:52 +02:00
parent c160bc7080
commit 849c3a9bec

View File

@ -10,6 +10,7 @@ void MwIniImporter::setVerbose(bool verbose) {
strmap MwIniImporter::loadIniFile(std::string filename) { strmap MwIniImporter::loadIniFile(std::string filename) {
std::cout << "load ini file: " << filename << std::endl; std::cout << "load ini file: " << filename << std::endl;
std::string section("");
std::map<std::string, std::string> map; std::map<std::string, std::string> map;
boost::iostreams::stream<boost::iostreams::file_source>file(filename.c_str()); boost::iostreams::stream<boost::iostreams::file_source>file(filename.c_str());
@ -17,17 +18,25 @@ strmap MwIniImporter::loadIniFile(std::string filename) {
while (std::getline(file, line)) { while (std::getline(file, line)) {
// ignore sections for now // ignore sections for now
if(line.empty() || line[0] == ';' || line[0] == '[') { if(line.empty() || line[0] == ';') {
continue; continue;
} }
if(line[0] == '[') {
if(line.length() > 2) {
section = line.substr(1, line.length()-3);
continue;
}
throw IniParseException();
}
int pos = line.find("="); int pos = line.find("=");
if(pos < 1) { if(pos < 1) {
throw IniParseException(); throw IniParseException();
} }
map.insert(std::pair<std::string,std::string>( map.insert(std::pair<std::string,std::string>(
line.substr(0,pos), line.substr(pos+1) section + " " + line.substr(0,pos), line.substr(pos+1)
)); ));
} }