mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-08-21 16:23:46 +08:00
Params: add new method to get all keys (#25779)
* allKeys * cleanup and test Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> old-commit-hash: 85b433760a2c1a139062a40040e096b9de880e33
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include <dirent.h>
|
||||
#include <sys/file.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <csignal>
|
||||
#include <unordered_map>
|
||||
|
||||
@@ -203,6 +204,14 @@ Params::Params(const std::string &path) {
|
||||
params_path = path.empty() ? default_param_path : ensure_params_path(prefix, path);
|
||||
}
|
||||
|
||||
std::vector<std::string> Params::allKeys() const {
|
||||
std::vector<std::string> ret;
|
||||
for (auto &p : keys) {
|
||||
ret.push_back(p.first);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool Params::checkKey(const std::string &key) {
|
||||
return keys.find(key) != keys.end();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user