mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-26 18:21:59 +00:00
aggregate of int/real compatibility in parsing #5302
This commit is contained in:
@@ -130,10 +130,48 @@ namespace {
|
|||||||
if (aggregate_storage.which() == 0) {
|
if (aggregate_storage.which() == 0) {
|
||||||
aggregate_storage = std::vector<std::decay_t<decltype(v)>>{ v };
|
aggregate_storage = std::vector<std::decay_t<decltype(v)>>{ v };
|
||||||
} else {
|
} else {
|
||||||
auto* vec_ptr = boost::get<std::vector<std::decay_t<decltype(v)>>>(&aggregate_storage);
|
if (auto* vec_ptr = boost::get<std::vector<std::decay_t<decltype(v)>>>(&aggregate_storage)) {
|
||||||
if (vec_ptr) {
|
|
||||||
vec_ptr->push_back(v);
|
vec_ptr->push_back(v);
|
||||||
} else {
|
} else {
|
||||||
|
if constexpr (std::is_same_v<std::decay_t<decltype(v)>, int>) {
|
||||||
|
auto* vec_ptr2 = boost::get<std::vector<double>>(&aggregate_storage);
|
||||||
|
if (vec_ptr2) {
|
||||||
|
// double[] + int
|
||||||
|
vec_ptr2->push_back((double) v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if constexpr (std::is_same_v<std::decay_t<decltype(v)>, double>) {
|
||||||
|
auto* vec_ptr2 = boost::get<std::vector<int>>(&aggregate_storage);
|
||||||
|
if (vec_ptr2) {
|
||||||
|
// int[] -> double[] + double
|
||||||
|
std::vector<double> ps(vec_ptr2->begin(), vec_ptr2->end());
|
||||||
|
ps.push_back(v);
|
||||||
|
aggregate_storage = ps;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if constexpr (std::is_same_v<std::decay_t<decltype(v)>, std::vector<int>>) {
|
||||||
|
auto* vec_ptr2 = boost::get<std::vector<std::vector<double>>>(&aggregate_storage);
|
||||||
|
if (vec_ptr2) {
|
||||||
|
// double[][] + int[]
|
||||||
|
std::vector<double> vd(v.begin(), v.end());
|
||||||
|
vec_ptr2->push_back(vd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if constexpr (std::is_same_v<std::decay_t<decltype(v)>, std::vector<double>>) {
|
||||||
|
auto* vec_ptr2 = boost::get<std::vector<std::vector<int>>>(&aggregate_storage);
|
||||||
|
if (vec_ptr2) {
|
||||||
|
// int[][] -> double[][] + double[]
|
||||||
|
std::vector<std::vector<double>> vvd;
|
||||||
|
for (auto& vv : *vec_ptr2) {
|
||||||
|
std::vector<double> vd(vv.begin(), vv.end());
|
||||||
|
vvd.push_back(vd);
|
||||||
|
}
|
||||||
|
vvd.push_back(v);
|
||||||
|
aggregate_storage = vvd;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// @todo would be cool if we can trace this back to file offset
|
// @todo would be cool if we can trace this back to file offset
|
||||||
auto current = boost::apply_visitor([](auto v) {
|
auto current = boost::apply_visitor([](auto v) {
|
||||||
if constexpr (!std::is_same_v<decltype(v), Blank>) {
|
if constexpr (!std::is_same_v<decltype(v), Blank>) {
|
||||||
@@ -145,6 +183,7 @@ namespace {
|
|||||||
return std::string{};
|
return std::string{};
|
||||||
}
|
}
|
||||||
}, aggregate_storage);
|
}, aggregate_storage);
|
||||||
|
|
||||||
Logger::Error("Inconsistent aggregate valuation while attempting to append " + std::string(typeid(decltype(v)).name()) + " to an aggregate of " + current);
|
Logger::Error("Inconsistent aggregate valuation while attempting to append " + std::string(typeid(decltype(v)).name()) + " to an aggregate of " + current);
|
||||||
|
|
||||||
// @todo boolean -> logical upgrade
|
// @todo boolean -> logical upgrade
|
||||||
|
|||||||
Reference in New Issue
Block a user