mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 17:58:20 +00:00
Fix some schema generation issues
This commit is contained in:
+43
-22
@@ -205,32 +205,53 @@ struct hash<express::Entity> {
|
||||
|
||||
} // namespace boost
|
||||
|
||||
template <typename T, typename U>
|
||||
std::vector<T> cast_vector(const std::vector<U>& vs) {
|
||||
std::vector<T> result;
|
||||
for (const auto& v : vs) {
|
||||
if constexpr (std::is_base_of_v<T, U>) {
|
||||
// For a base or identity transform we can just rely on static cast
|
||||
result.push_back(v);
|
||||
} else if constexpr (std::is_base_of_v<express::Select, U> && std::is_same_v<T, express::Base>) {
|
||||
// From a select to concrete we simply call the appropriate method
|
||||
result.push_back(v.concrete());
|
||||
} else {
|
||||
if (auto u = v.template as<T>()) {
|
||||
result.push_back(u);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
namespace {
|
||||
template <typename>
|
||||
struct is_std_vector : std::false_type {};
|
||||
|
||||
template <typename X, typename A>
|
||||
struct is_std_vector<std::vector<X, A>> : std::true_type {};
|
||||
|
||||
template <typename T>
|
||||
constexpr bool is_std_vector_v = is_std_vector<T>::value;
|
||||
|
||||
template <typename T>
|
||||
struct is_std_vector_vector : std::false_type {};
|
||||
|
||||
template <typename T, typename Alloc, typename Alloc2>
|
||||
struct is_std_vector_vector<std::vector<std::vector<T, Alloc>, Alloc2>> : std::true_type {};
|
||||
|
||||
template <typename T>
|
||||
constexpr bool is_std_vector_vector_v = is_std_vector_vector<T>::value;
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
std::vector<std::vector<T>> cast_vector_vector(const std::vector<std::vector<U>>& vs) {
|
||||
std::vector<std::vector<T>> result;
|
||||
for (const auto& v : vs) {
|
||||
result.push_back(cast_vector<T>(v));
|
||||
auto cast_vector(const std::vector<U>& vs) {
|
||||
if constexpr (is_std_vector<U>::value) {
|
||||
using V = typename U::value_type;
|
||||
std::vector<std::vector<T>> result;
|
||||
result.reserve(vs.size());
|
||||
for (const auto& v : vs) {
|
||||
result.push_back(cast_vector<T>(v));
|
||||
}
|
||||
return result;
|
||||
} else {
|
||||
std::vector<T> result;
|
||||
for (const auto& v : vs) {
|
||||
if constexpr (std::is_base_of_v<T, U>) {
|
||||
// For a base or identity transform we can just rely on static cast
|
||||
result.push_back(v);
|
||||
} else if constexpr (std::is_base_of_v<express::Select, U> && std::is_same_v<T, express::Base>) {
|
||||
// From a select to concrete we simply call the appropriate method
|
||||
result.push_back(v.concrete());
|
||||
} else {
|
||||
if (auto u = v.template as<T>()) {
|
||||
result.push_back(u);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user