mirror of
https://github.com/diamante0018/BlackOpsPlugin.git
synced 2025-07-08 20:21:50 +00:00
small refactor
This commit is contained in:
@ -17,7 +17,7 @@ std::string info_string::get(const std::string& key) const {
|
||||
return value->second;
|
||||
}
|
||||
|
||||
return "";
|
||||
return {};
|
||||
}
|
||||
|
||||
void info_string::parse(std::string buffer) {
|
||||
@ -25,24 +25,25 @@ void info_string::parse(std::string buffer) {
|
||||
buffer = buffer.substr(1);
|
||||
}
|
||||
|
||||
auto key_values = string::split(buffer, '\\');
|
||||
const auto key_values = string::split(buffer, '\\');
|
||||
for (size_t i = 0; !key_values.empty() && i < (key_values.size() - 1);
|
||||
i += 2) {
|
||||
const auto& key = key_values[i];
|
||||
const auto& value = key_values[i + 1];
|
||||
this->key_value_pairs_[key] = value;
|
||||
if (!this->key_value_pairs_.contains(key)) {
|
||||
this->key_value_pairs_[key] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string info_string::build() const {
|
||||
std::string info_string;
|
||||
for (auto i = this->key_value_pairs_.begin();
|
||||
i != this->key_value_pairs_.end(); ++i) {
|
||||
for (const auto& [key, value] : this->key_value_pairs_) {
|
||||
info_string.append("\\");
|
||||
|
||||
info_string.append(i->first); // Key
|
||||
info_string.append(key);
|
||||
info_string.append("\\");
|
||||
info_string.append(i->second); // Value
|
||||
info_string.append(value);
|
||||
}
|
||||
|
||||
return info_string;
|
||||
|
Reference in New Issue
Block a user