Skip to content
Snippets Groups Projects
Commit 91ece017 authored by Giovanna Lazzari Miotto's avatar Giovanna Lazzari Miotto :mushroom:
Browse files

[config] Add wrapper around key-value map

parent a454cc90
No related branches found
No related tags found
No related merge requests found
......@@ -56,9 +56,8 @@ config::config(std::string filename) {
}
void config::print() const {
for (std::map<std::string, std::string>::const_iterator it = vmap.begin(); it != vmap.end();
it++) {
LOG(INFO) << "key " << it->first << " value " << it->second;
for (const auto& it : vmap) {
LOG(INFO) << "key " << it.first << " value " << it.second;
}
}
......
......@@ -11,6 +11,26 @@
#include "processor.h"
class config {
class ConfigMap {
std::map<std::string, std::string> _configMap;
public:
std::string &operator[](std::string &key) { return _configMap[key]; }
std::string at(std::string key) const {
try {
return _configMap.at(key);
} catch (std::exception &e) {
std::cout << "Error fetching value for key `" << key << "`!" << std::endl;
std::cout << e.what() << std::endl;
throw;
}
}
std::map<std::string, std::string>::const_iterator begin() const { return _configMap.begin(); }
std::map<std::string, std::string>::const_iterator end() const { return _configMap.end(); }
};
using MapType = ConfigMap;
public:
enum class InputType { WZDMA, FILEDMA, TCPIP, MICRONDMA, FILE };
......@@ -152,6 +172,6 @@ class config {
const std::string getSconeBoard() const { return vmap.at("scone_board"); }
private:
std::map<std::string, std::string> vmap;
MapType vmap;
};
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment