Test dynamic IPv4 + Subnet masks

This commit is contained in:
2025-12-02 16:25:42 +01:00
parent 4dbde290c2
commit eb7f4930e2
9 changed files with 59 additions and 16 deletions

View File

@@ -118,7 +118,7 @@ namespace ColumnLynx::Utils {
return out;
}
std::unordered_map<std::string, std::string> getConfigMap(std::string path) {
std::unordered_map<std::string, std::string> getConfigMap(std::string path, std::vector<std::string> requiredKeys) {
// TODO: Currently re-reads every time.
std::vector<std::string> readLines;
@@ -129,6 +129,16 @@ namespace ColumnLynx::Utils {
readLines.push_back(line);
}
if (!requiredKeys.empty()) {
// Check if they exist using unordered_set magic
std::unordered_set<std::string> setA(readLines.begin(), readLines.end());
for (std::string x : requiredKeys) {
if (!setA.count(x)) {
throw std::runtime_error("Config doesn't contain all required keys! (Missing: '" + x + "')");
}
}
}
// Parse them into the struct
std::unordered_map<std::string, std::string> config;
char delimiter = '=';