| 23 | #include "../../util/stringutil.h" |
| 24 | |
| 25 | ConfigFile::ConfigFile(BString fileName) { |
| 26 | std::vector<BString> lines; |
| 27 | readLinesFromFile(fileName, lines); |
| 28 | this->fileName = fileName; |
| 29 | for (auto& line : lines) { |
| 30 | std::vector<BString> parts; |
| 31 | line.split('=', parts); |
| 32 | if (parts.size() < 2) { |
| 33 | kwarn_fmt("%s has a malformed key/value pair", fileName.c_str()); |
| 34 | } else { |
| 35 | parts[0] = parts[0].trim(); |
| 36 | parts[1] = parts[1].trim(); |
| 37 | this->values.set(parts[0], parts[1]); |
| 38 | } |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | BString ConfigFile::readString(BString name, BString defaultValue) { |
| 43 | BString value; |