2014-05-06 08:07:18 +00:00
|
|
|
#ifndef slic3r_PlaceholderParser_hpp_
|
|
|
|
#define slic3r_PlaceholderParser_hpp_
|
|
|
|
|
2015-12-07 23:39:54 +00:00
|
|
|
#include "libslic3r.h"
|
2014-05-06 08:07:18 +00:00
|
|
|
#include <map>
|
|
|
|
#include <string>
|
2015-05-02 19:43:22 +00:00
|
|
|
#include <vector>
|
2014-06-13 13:32:11 +00:00
|
|
|
#include "PrintConfig.hpp"
|
2014-05-06 08:07:18 +00:00
|
|
|
|
|
|
|
namespace Slic3r {
|
|
|
|
|
|
|
|
class PlaceholderParser
|
|
|
|
{
|
2017-11-17 10:15:46 +00:00
|
|
|
public:
|
2014-05-06 08:07:18 +00:00
|
|
|
PlaceholderParser();
|
2017-11-17 10:15:46 +00:00
|
|
|
|
2014-11-09 19:41:27 +00:00
|
|
|
void update_timestamp();
|
2015-12-07 18:39:49 +00:00
|
|
|
void apply_config(const DynamicPrintConfig &config);
|
2015-07-01 15:56:38 +00:00
|
|
|
void apply_env_variables();
|
2017-11-17 10:15:46 +00:00
|
|
|
|
|
|
|
// 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)); }
|
2017-12-04 10:57:54 +00:00
|
|
|
void set(const std::string &key, bool value) { this->set(key, new ConfigOptionBool(value)); }
|
2017-11-17 10:15:46 +00:00
|
|
|
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); }
|
2017-12-18 11:14:09 +00:00
|
|
|
const DynamicConfig& config() const { return m_config; }
|
|
|
|
const ConfigOption* option(const std::string &key) const { return m_config.option(key); }
|
2017-11-17 10:15:46 +00:00
|
|
|
|
2017-12-18 11:14:09 +00:00
|
|
|
// Fill in the template using a macro processing language.
|
|
|
|
// Throws std::runtime_error on syntax or runtime error.
|
2017-11-17 10:15:46 +00:00
|
|
|
std::string process(const std::string &templ, unsigned int current_extruder_id, const DynamicConfig *config_override = nullptr) const;
|
2015-07-01 17:35:22 +00:00
|
|
|
|
2017-12-18 11:14:09 +00:00
|
|
|
// Evaluate a boolean expression using the full expressive power of the PlaceholderParser boolean expression syntax.
|
|
|
|
// Throws std::runtime_error on syntax or runtime error.
|
2017-12-19 15:48:14 +00:00
|
|
|
static bool evaluate_boolean_expression(const std::string &templ, const DynamicConfig &config, const DynamicConfig *config_override = nullptr);
|
2017-12-18 11:14:09 +00:00
|
|
|
|
2017-05-03 16:28:22 +00:00
|
|
|
private:
|
2017-11-17 10:15:46 +00:00
|
|
|
DynamicConfig m_config;
|
2014-05-06 08:07:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|