| 17 | } |
| 18 | |
| 19 | ConfigFile::ConfigFile(std::string const& configFile) { |
| 20 | std::ifstream file(configFile.c_str()); |
| 21 | |
| 22 | std::string line; |
| 23 | std::string name; |
| 24 | std::string value; |
| 25 | std::string inSection; |
| 26 | int posEqual; |
| 27 | while (std::getline(file,line)) { |
| 28 | |
| 29 | if (! line.length()) continue; |
| 30 | |
| 31 | if (line[0] == '#') continue; |
| 32 | if (line[0] == ';') continue; |
| 33 | |
| 34 | if (line[0] == '[') { |
| 35 | inSection=trim(line.substr(1,line.find(']')-1)); |
| 36 | continue; |
| 37 | } |
| 38 | |
| 39 | posEqual=line.find('='); |
| 40 | name = trim(line.substr(0,posEqual)); |
| 41 | value = trim(line.substr(posEqual+1)); |
| 42 | |
| 43 | content_[inSection+'/'+name]=Chameleon(value); |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | Chameleon const& ConfigFile::Value(std::string const& section, std::string const& entry) const { |
| 48 | |