diff options
author | hop311 <hop3114@gmail.com> | 2023-10-13 00:05:49 +0200 |
---|---|---|
committer | hop311 <hop3114@gmail.com> | 2023-10-13 00:05:49 +0200 |
commit | 6b3d2315225468e03bef30e942263fe9b8fc06fa (patch) | |
tree | fbcc59a1637cd13a0024ed1c8ff17dcf2e1a6ed7 /src/openvic-simulation/Modifier.cpp | |
parent | e50c67eb1aaa54f5fb31425f81616bea4e6b880a (diff) |
Further cleanup and rearrangement
Diffstat (limited to 'src/openvic-simulation/Modifier.cpp')
-rw-r--r-- | src/openvic-simulation/Modifier.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/openvic-simulation/Modifier.cpp b/src/openvic-simulation/Modifier.cpp index 5aadd79..4e5b860 100644 --- a/src/openvic-simulation/Modifier.cpp +++ b/src/openvic-simulation/Modifier.cpp @@ -131,7 +131,7 @@ bool ModifierManager::setup_modifier_effects() { return ret; } -node_callback_t ModifierManager::expect_modifier_value(callback_t<ModifierValue&&> modifier_callback, key_value_callback_t default_callback) const { +node_callback_t ModifierManager::expect_modifier_value_and_default(callback_t<ModifierValue&&> modifier_callback, key_value_callback_t default_callback) const { return [this, modifier_callback, default_callback](ast::NodeCPtr root) -> bool { ModifierValue modifier; bool ret = expect_dictionary( @@ -154,9 +154,13 @@ node_callback_t ModifierManager::expect_modifier_value(callback_t<ModifierValue& }; } -node_callback_t ModifierManager::_expect_modifier_value_and_keys(callback_t<ModifierValue&&> modifier_callback, key_map_t&& key_map) const { +node_callback_t ModifierManager::expect_modifier_value(callback_t<ModifierValue&&> modifier_callback) const { + return expect_modifier_value_and_default(modifier_callback, key_value_invalid_callback); +} + +node_callback_t ModifierManager::expect_modifier_value_and_key_map_and_default(callback_t<ModifierValue&&> modifier_callback, key_value_callback_t default_callback, key_map_t&& key_map) const { return [this, modifier_callback, key_map = std::move(key_map)](ast::NodeCPtr node) mutable -> bool { - bool ret = expect_modifier_value( + bool ret = expect_modifier_value_and_default( modifier_callback, dictionary_keys_callback(key_map, key_value_invalid_callback) )(node); ret &= check_key_map_counts(key_map); @@ -164,6 +168,10 @@ node_callback_t ModifierManager::_expect_modifier_value_and_keys(callback_t<Modi }; } +node_callback_t ModifierManager::expect_modifier_value_and_key_map(callback_t<ModifierValue&&> modifier_callback, key_map_t&& key_map) const { + return expect_modifier_value_and_key_map_and_default(modifier_callback, key_value_invalid_callback, std::move(key_map)); +} + namespace OpenVic { //so the compiler shuts up std::ostream& operator<<(std::ostream& stream, ModifierValue const& value) { for (ModifierValue::effect_map_t::value_type const& effect : value.values) { |