diff options
author | Hop311 <Hop3114@gmail.com> | 2024-10-31 21:50:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-31 21:50:36 +0100 |
commit | b602c10cf890c5973c1efbe8d958bf9b67499efe (patch) | |
tree | 3b34e78831ab11d6333ce2822b10244995a69848 /src/openvic-simulation/defines/Define.cpp | |
parent | 968c60580997d26035496cc675138e580354332f (diff) | |
parent | dbf58b1b1d318b4a82cf22b5b8e720c753388f4b (diff) |
Merge pull request #222 from OpenVicProject/defines-variables
Load defines directly into named and typed variables rather than using an IdentifierRegistry
Diffstat (limited to 'src/openvic-simulation/defines/Define.cpp')
-rw-r--r-- | src/openvic-simulation/defines/Define.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/openvic-simulation/defines/Define.cpp b/src/openvic-simulation/defines/Define.cpp new file mode 100644 index 0000000..8d910cb --- /dev/null +++ b/src/openvic-simulation/defines/Define.cpp @@ -0,0 +1,25 @@ +#include "Define.hpp" + +#include "openvic-simulation/dataloader/NodeTools.hpp" + +using namespace OpenVic; +using namespace OpenVic::NodeTools; + +DefineManager::DefineManager() : start_date {}, end_date {} {} + +bool DefineManager::load_defines_file(ast::NodeCPtr root) { + return expect_dictionary_keys( + "defines", ONE_EXACTLY, expect_dictionary_keys( + "start_date", ONE_EXACTLY, expect_date_identifier_or_string(assign_variable_callback(start_date)), + "end_date", ONE_EXACTLY, expect_date_identifier_or_string(assign_variable_callback(end_date)), + + ai_defines.get_name(), ONE_EXACTLY, ai_defines.expect_defines(), + country_defines.get_name(), ONE_EXACTLY, country_defines.expect_defines(), + diplomacy_defines.get_name(), ONE_EXACTLY, diplomacy_defines.expect_defines(), + economy_defines.get_name(), ONE_EXACTLY, economy_defines.expect_defines(), + graphics_defines.get_name(), ONE_EXACTLY, graphics_defines.expect_defines(), + military_defines.get_name(), ONE_EXACTLY, military_defines.expect_defines(), + pops_defines.get_name(), ONE_EXACTLY, pops_defines.expect_defines() + ) + )(root); +} |