| 9 | } |
| 10 | |
| 11 | bool PropertyManager::loadFromFile() { |
| 12 | orderedProps.clear(); |
| 13 | keyIndex.clear(); |
| 14 | |
| 15 | std::ifstream file(filePath); |
| 16 | if (!file.is_open()) { |
| 17 | LOGW("PropertyManager: Could not open %s for loading.", filePath.c_str()); |
| 18 | return false; |
| 19 | } |
| 20 | |
| 21 | std::string line; |
| 22 | while (std::getline(file, line)) { |
| 23 | if (line.empty() || line[0] == '#') |
| 24 | continue; |
| 25 | |
| 26 | auto pos = line.find('='); |
| 27 | if (pos == std::string::npos) |
| 28 | continue; |
| 29 | |
| 30 | std::string key = line.substr(0, pos); |
| 31 | std::string val = line.substr(pos + 1); |
| 32 | |
| 33 | size_t idx = orderedProps.size(); |
| 34 | orderedProps.emplace_back(key, val); |
| 35 | keyIndex[key] = idx; |
| 36 | } |
| 37 | |
| 38 | file.close(); |
| 39 | return true; |
| 40 | } |
| 41 | |
| 42 | bool PropertyManager::saveToFile() { |
| 43 | std::ofstream file(filePath, std::ios::trunc); |
nothing calls this directly
no outgoing calls
no test coverage detected