| 81 | ///////////////////////// ConfFile ////////////////////////// |
| 82 | |
| 83 | ConfFile::ConfFile(const std::vector<conf_section_t>& sections) |
| 84 | { |
| 85 | for (auto& section : sections) { |
| 86 | auto [old_sec, sec_inserted] = emplace(section.heading, section); |
| 87 | if (!sec_inserted) { |
| 88 | // merge lines in section into old_sec |
| 89 | for (auto& line : section) { |
| 90 | auto [old_line, line_inserted] = old_sec->second.emplace(line); |
| 91 | // and replace the existing ones if any |
| 92 | if (!line_inserted) { |
| 93 | old_sec->second.erase(old_line); |
| 94 | old_sec->second.insert(line); |
| 95 | } |
| 96 | } |
| 97 | } |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | /* We load the whole file into memory and then parse it. Although this is not |
| 102 | * the optimal approach, it does mean that most of this code can be shared with |