mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
Support vector<string> setting types
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user