Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbubnikv <bubnikv@gmail.com>2017-11-17 13:15:46 +0300
committerbubnikv <bubnikv@gmail.com>2017-11-17 13:15:46 +0300
commit47f193fe2dd78fd1f5d058ade3ff897ce85cfdb8 (patch)
tree7c33c5b647a0381d8949639658d035e2f9c84459 /xs/src/libslic3r/PlaceholderParser.hpp
parent200f176951d06cea9f2e33b7d8a325fb103d14d4 (diff)
The PlaceholderParser has been rewritten to use
a real boost::spirit::qi parser, accessing the DynamicConfig repository directly. This is a first step towards a full fledged expression interpreter.
Diffstat (limited to 'xs/src/libslic3r/PlaceholderParser.hpp')
-rw-r--r--xs/src/libslic3r/PlaceholderParser.hpp26
1 files changed, 15 insertions, 11 deletions
diff --git a/xs/src/libslic3r/PlaceholderParser.hpp b/xs/src/libslic3r/PlaceholderParser.hpp
index a8abf8871..9ec2eedea 100644
--- a/xs/src/libslic3r/PlaceholderParser.hpp
+++ b/xs/src/libslic3r/PlaceholderParser.hpp
@@ -11,23 +11,27 @@ namespace Slic3r {
class PlaceholderParser
{
-public:
- std::map<std::string, std::string> m_single;
- std::map<std::string, std::vector<std::string>> m_multiple;
-
+public:
PlaceholderParser();
+
void update_timestamp();
void apply_config(const DynamicPrintConfig &config);
void apply_env_variables();
- void set(const std::string &key, const std::string &value);
- void set(const std::string &key, int value);
- void set(const std::string &key, unsigned int value);
- void set(const std::string &key, double value);
- void set(const std::string &key, std::vector<std::string> values);
- std::string process(std::string str, unsigned int current_extruder_id) const;
+
+ // Add new ConfigOption values to m_config.
+ void set(const std::string &key, const std::string &value) { this->set(key, new ConfigOptionString(value)); }
+ void set(const std::string &key, int value) { this->set(key, new ConfigOptionInt(value)); }
+ void set(const std::string &key, unsigned int value) { this->set(key, int(value)); }
+ void set(const std::string &key, double value) { this->set(key, new ConfigOptionFloat(value)); }
+ void set(const std::string &key, const std::vector<std::string> &values) { this->set(key, new ConfigOptionStrings(values)); }
+ void set(const std::string &key, ConfigOption *opt) { m_config.set_key_value(key, opt); }
+ const ConfigOption* option(const std::string &key) const { return m_config.option(key); }
+
+ // Fill in the template.
+ std::string process(const std::string &templ, unsigned int current_extruder_id, const DynamicConfig *config_override = nullptr) const;
private:
- bool find_and_replace(std::string &source, std::string const &find, std::string const &replace) const;
+ DynamicConfig m_config;
};
}