From dc08bcafaeba8b6abc816bab7c6468b7c601732a Mon Sep 17 00:00:00 2001 From: Joseph Lenox Date: Sat, 5 May 2018 16:13:34 -0500 Subject: [PATCH] Added template function to make getting references to ConfigOptions easier to write. --- xs/src/libslic3r/Config.hpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/xs/src/libslic3r/Config.hpp b/xs/src/libslic3r/Config.hpp index a4c7fa470..e2049cd32 100644 --- a/xs/src/libslic3r/Config.hpp +++ b/xs/src/libslic3r/Config.hpp @@ -16,6 +16,13 @@ public: void write_ini(const std::string& file) { save(file); } void read_ini(const std::string& file) { load(file); } + + /// Template function to retrieve and cast in hopefully a slightly nicer + /// format than longwinded dynamic_cast<> + template + T& get(const t_config_option_key& opt_key, bool create=false) { + return *(dynamic_cast(this->optptr(opt_key, create))); + } }; } // namespace Slic3r