Implement a shared config between servers (#795)

* Implement a shared config between servers

* Auto move config file on CMake run
This commit is contained in:
Jett
2022-10-30 00:17:35 +01:00
committed by GitHub
parent d8e73def9d
commit a745cdb727
8 changed files with 41 additions and 90 deletions

View File

@@ -12,6 +12,15 @@ dConfig::dConfig(const std::string& filepath) {
if (line[0] != '#') ProcessLine(line);
}
}
std::ifstream sharedConfig("sharedconfig.ini", std::ios::in);
if (!sharedConfig.good()) return;
while (std::getline(sharedConfig, line)) {
if (line.length() > 0) {
if (line[0] != '#') ProcessLine(line);
}
}
}
dConfig::~dConfig(void) {
@@ -40,6 +49,12 @@ void dConfig::ProcessLine(const std::string& line) {
if (!seglist[1].empty() && seglist[1][seglist[1].size() - 1] == '\r')
seglist[1].erase(seglist[1].size() - 1);
for (const auto& key : m_Keys) {
if (seglist[0] == key) {
return; // first loaded key is preferred due to loading shared config secondarily
}
}
m_Keys.push_back(seglist[0]);
m_Values.push_back(seglist[1]);
}