Support vector<string> setting types

This commit is contained in:
Thomas Krijnen
2026-07-07 10:13:54 +02:00
parent b441fada90
commit 08ebd05be5
3 changed files with 20 additions and 8 deletions
+9 -1
View File
@@ -10,6 +10,7 @@
#include <type_traits>
#include <optional>
#include <variant>
#include <vector>
#include <boost/program_options.hpp>
#include <boost/optional.hpp>
@@ -521,6 +522,11 @@ namespace ifcopenshell {
static constexpr const char* name = "std::vector<double>";
};
template <>
struct readable_name<std::vector<std::string>> {
static constexpr const char* name = "std::vector<std::string>";
};
template <>
struct readable_name<IteratorOutputOptions> {
static constexpr const char* name = "IteratorOutputOptions";
@@ -545,7 +551,9 @@ namespace ifcopenshell {
template <typename settings_t>
class SettingsContainer {
public:
typedef std::variant<bool, int, double, std::string, std::set<int>, std::set<std::string>, std::vector<double>, IteratorOutputOptions, FunctionStepMethod, OutputDimensionalityTypes, TriangulationMethod> value_variant_t;
typedef std::variant<bool, int, double, std::string, std::set<int>, std::set<std::string>,
std::vector<double>, std::vector<std::string>, IteratorOutputOptions, FunctionStepMethod,
OutputDimensionalityTypes, TriangulationMethod> value_variant_t;
private:
settings_t settings;
+10 -6
View File
@@ -515,12 +515,16 @@ assign_matrix_access(revolve);
void set_(const std::string& name, const std::set<int>& val) {
return $self->set(name, val);
}
void set_(const std::string& name, const std::set<std::string>& val) {
return $self->set(name, val);
}
void set_(const std::string& name, const std::vector<double>& val) {
return $self->set(name, val);
}
void set_(const std::string& name, const std::vector<double>& val) {
return $self->set(name, val);
}
void set_(const std::string& name, const std::vector<std::string>& val) {
// Python sequences cannot distinguish std::vector<std::string> from std::set<std::string>.
if ($self->get_type(name) == "std::set<std::string>") {
return $self->set(name, std::set<std::string>(val.begin(), val.end()));
}
return $self->set(name, val);
}
ifcopenshell::geometry::Settings::value_variant_t get_(const std::string& name) {
return $self->get(name);
}
+1 -1
View File
@@ -286,7 +286,7 @@
} else if constexpr (std::is_same_v<std::remove_cv_t<std::remove_reference_t<T>>, std::set<std::string>>) {
std::vector<std::string> vs(t.begin(), t.end());
return pythonize_vector(vs);
} else if constexpr (std::is_same_v<std::remove_cv_t<std::remove_reference_t<T>>, std::vector<double>>) {
} else if constexpr (is_std_vector_v<std::remove_cv_t<std::remove_reference_t<T>>>) {
return pythonize_vector(t);
} else {
return pythonize(t);