mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
#4329 Don't accept non-finite floats
This commit is contained in:
@@ -295,4 +295,28 @@ void IfcWriteArgument::set(IfcUtil::IfcBaseInterface*const& v) {
|
||||
} 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;
|
||||
}
|
||||
|
||||
@@ -142,7 +142,12 @@ namespace IfcWrite {
|
||||
|
||||
// Overload to detect null values
|
||||
void set(IfcUtil::IfcBaseInterface*const & v);
|
||||
|
||||
|
||||
// Overloads to raise exceptions on non-finite values
|
||||
void set(const double& v);
|
||||
void set(const std::vector<double>& v);
|
||||
void set(const std::vector< std::vector<double> >& v);
|
||||
|
||||
operator int() const;
|
||||
operator bool() const;
|
||||
operator boost::logic::tribool() const;
|
||||
|
||||
Reference in New Issue
Block a user