From 7efca35c277bee219cb298c3fa0d19c494c8c73f Mon Sep 17 00:00:00 2001 From: bubnikv Date: Tue, 21 Jan 2020 09:55:36 +0100 Subject: [PATCH] Don't store "print_host", "printhost_apikey", "printhost_cafile" into the G-code. --- src/libslic3r/GCode.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index bd22c29e5..517b5281b 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -34,6 +35,8 @@ #include "miniz_extension.hpp" +using namespace std::literals::string_view_literals; + #if 0 // Enable debugging and asserts, even in the release build. #define DEBUG @@ -2268,8 +2271,20 @@ void GCode::apply_print_config(const PrintConfig &print_config) void GCode::append_full_config(const Print &print, std::string &str) { const DynamicPrintConfig &cfg = print.full_print_config(); + // Sorted list of config keys, which shall not be stored into the G-code. Initializer list. + static constexpr auto banned_keys = { + "compatible_printers"sv, + "compatible_prints"sv, + "print_host"sv, + "printhost_apikey"sv, + "printhost_cafile"sv + }; + assert(std::is_sorted(banned_keys.begin(), banned_keys.end())); + auto is_banned = [](const std::string &key) { + return std::binary_search(banned_keys.begin(), banned_keys.end(), key); + }; for (const std::string &key : cfg.keys()) - if (key != "compatible_prints" && key != "compatible_printers" && ! cfg.option(key)->is_nil()) + if (! is_banned(key) && ! cfg.option(key)->is_nil()) str += "; " + key + " = " + cfg.opt_serialize(key) + "\n"; }