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:
authorAlessandro Ranellucci <aar@cpan.org>2014-11-09 14:25:59 +0300
committerAlessandro Ranellucci <aar@cpan.org>2014-11-09 14:25:59 +0300
commit3e4c57216412504e63154b6887bf14f89f4b559f (patch)
treef10ff527410e38394adebe4190a5a9467bc7ddf6 /xs/src/libslic3r/Config.cpp
parent6b4015f9accdefc544d14ba5c31a4af7f724479b (diff)
Ported some methods including add_model_object() and apply_config() to XS
Diffstat (limited to 'xs/src/libslic3r/Config.cpp')
-rw-r--r--xs/src/libslic3r/Config.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/xs/src/libslic3r/Config.cpp b/xs/src/libslic3r/Config.cpp
index 417054e18..b3fe6b877 100644
--- a/xs/src/libslic3r/Config.cpp
+++ b/xs/src/libslic3r/Config.cpp
@@ -27,6 +27,27 @@ ConfigBase::apply(const ConfigBase &other, bool ignore_nonexistent) {
}
}
+bool
+ConfigBase::equals(ConfigBase &other) {
+ return this->diff(other).empty();
+}
+
+// this will *ignore* options not present in both configs
+t_config_option_keys
+ConfigBase::diff(ConfigBase &other) {
+ t_config_option_keys diff;
+
+ t_config_option_keys my_keys;
+ this->keys(&my_keys);
+ for (t_config_option_keys::const_iterator opt_key = my_keys.begin(); opt_key != my_keys.end(); ++opt_key) {
+ if (other.has(*opt_key) && other.serialize(*opt_key) != this->serialize(*opt_key)) {
+ diff.push_back(*opt_key);
+ }
+ }
+
+ return diff;
+}
+
std::string
ConfigBase::serialize(const t_config_option_key opt_key) {
ConfigOption* opt = this->option(opt_key);
@@ -248,6 +269,18 @@ ConfigBase::set_deserialize(const t_config_option_key opt_key, SV* str) {
return this->set_deserialize(opt_key, value);
}
+
+void
+ConfigBase::set_ifndef(t_config_option_key opt_key, SV* value, bool deserialize)
+{
+ if (!this->has(opt_key)) {
+ if (deserialize) {
+ this->set_deserialize(opt_key, value);
+ } else {
+ this->set(opt_key, value);
+ }
+ }
+}
#endif
DynamicConfig& DynamicConfig::operator= (DynamicConfig other)