diff options
author | Miodrag Milanovic <mmicko@gmail.com> | 2019-06-15 13:09:49 +0200 |
---|---|---|
committer | Miodrag Milanovic <mmicko@gmail.com> | 2019-06-15 13:09:49 +0200 |
commit | 95280060b869f266beaff023dd63d74905c39ef4 (patch) | |
tree | 98d49d09ef31161ea712341767ff7019616cb342 /common/nextpnr.h | |
parent | 66ea9f39f7f5d6e1152105328f9a48a367bd8ce0 (diff) | |
download | nextpnr-95280060b869f266beaff023dd63d74905c39ef4.tar.gz nextpnr-95280060b869f266beaff023dd63d74905c39ef4.tar.bz2 nextpnr-95280060b869f266beaff023dd63d74905c39ef4.zip |
No need for settings class
Diffstat (limited to 'common/nextpnr.h')
-rw-r--r-- | common/nextpnr.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/common/nextpnr.h b/common/nextpnr.h index 66134456..b796b8aa 100644 --- a/common/nextpnr.h +++ b/common/nextpnr.h @@ -32,6 +32,7 @@ #include <vector> #include <boost/functional/hash.hpp> +#include <boost/lexical_cast.hpp> #ifndef NEXTPNR_H #define NEXTPNR_H @@ -724,6 +725,18 @@ struct Context : Arch, DeterministicRNG void check() const; void archcheck() const; + + template <typename T> T setting(const char *name, T defaultValue) + { + IdString new_id = id(name); + if (settings.find(new_id) != settings.end()) + return boost::lexical_cast<T>(settings.find(new_id)->second.str); + else + settings[id(name)] = std::to_string(defaultValue); + + return defaultValue; + } + }; NEXTPNR_NAMESPACE_END |