| 223 | } |
| 224 | |
| 225 | std::vector<std::pair<std::string, std::string>> LayeredSettingsInterface::GetKeyValueList(const char* section) const |
| 226 | { |
| 227 | std::unordered_set<std::string_view> seen; |
| 228 | std::vector<std::pair<std::string, std::string>> ret; |
| 229 | for (u32 layer = FIRST_LAYER; layer <= LAST_LAYER; layer++) |
| 230 | { |
| 231 | if (SettingsInterface* sif = m_layers[layer]) |
| 232 | { |
| 233 | const size_t newly_added_begin = ret.size(); |
| 234 | std::vector<std::pair<std::string, std::string>> entries = sif->GetKeyValueList(section); |
| 235 | for (std::pair<std::string, std::string>& entry : entries) |
| 236 | { |
| 237 | if (seen.find(entry.first) != seen.end()) |
| 238 | continue; |
| 239 | ret.push_back(std::move(entry)); |
| 240 | } |
| 241 | // Mark keys as seen after processing all entries in case the layer has multiple entries for a specific key |
| 242 | for (auto cur = ret.begin() + newly_added_begin; cur != ret.end(); ++cur) |
| 243 | seen.insert(cur->first); |
| 244 | } |
| 245 | } |
| 246 | return ret; |
| 247 | } |
| 248 | |
| 249 | void LayeredSettingsInterface::SetKeyValueList(const char* section, const std::vector<std::pair<std::string, std::string>>& items) |
| 250 | { |