mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 02:23:34 +00:00
Don't accept non-finite floats #4329
This commit is contained in:
@@ -315,3 +315,35 @@ void IfcWriteArgument::set(IfcUtil::IfcBaseInterface* const& value) {
|
||||
container_ = boost::blank();
|
||||
}
|
||||
}
|
||||
|
||||
void IfcWriteArgument::set(IfcUtil::IfcBaseInterface*const& v) {
|
||||
if (v) {
|
||||
container = v->as<IfcUtil::IfcBaseClass>();
|
||||
} else {
|
||||
container = boost::blank();
|
||||
}
|
||||
}
|
||||
|
||||
// Overloads to raise exceptions on non-finite values
|
||||
void IfcWriteArgument::set(const double& v) {
|
||||
if (!std::isfinite(v)) {
|
||||
throw IfcParse::IfcException("Only finite values are allowed");
|
||||
}
|
||||
container = v;
|
||||
}
|
||||
|
||||
void IfcWriteArgument::set(const std::vector<double>& v) {
|
||||
if (std::any_of(v.begin(), v.end(), [](double v) {return !std::isfinite(v); })) {
|
||||
throw IfcParse::IfcException("Only finite values are allowed");
|
||||
}
|
||||
container = v;
|
||||
}
|
||||
|
||||
void IfcWriteArgument::set(const std::vector< std::vector<double> >& v) {
|
||||
if (std::any_of(v.begin(), v.end(), [](const std::vector<double>& vs) {
|
||||
return std::any_of(vs.begin(), vs.end(), [](double v) {return !std::isfinite(v); });
|
||||
})) {
|
||||
throw IfcParse::IfcException("Only finite values are allowed");
|
||||
}
|
||||
container = v;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user