Simplify logic using freecad_dynamic_cast

This commit is contained in:
Benjamin Nauck
2025-01-17 18:45:34 +01:00
parent 45c997f40a
commit cb4ee4737d
5 changed files with 56 additions and 63 deletions

View File

@@ -329,17 +329,19 @@ bool Sheet::exportToFile(const std::string& filename,
std::stringstream field;
if (prop->isDerivedFrom((PropertyQuantity::getClassTypeId()))) {
field << static_cast<PropertyQuantity*>(prop)->getValue();
using Base::freecad_dynamic_cast;
if (auto p = freecad_dynamic_cast<PropertyQuantity>(prop)) {
field << p->getValue();
}
else if (prop->isDerivedFrom((PropertyFloat::getClassTypeId()))) {
field << static_cast<PropertyFloat*>(prop)->getValue();
else if (auto p = freecad_dynamic_cast<PropertyFloat>(prop)) {
field << p->getValue();
}
else if (prop->isDerivedFrom((PropertyInteger::getClassTypeId()))) {
field << static_cast<PropertyInteger*>(prop)->getValue();
else if (auto p = freecad_dynamic_cast<PropertyInteger>(prop)) {
field << p->getValue();
}
else if (prop->isDerivedFrom((PropertyString::getClassTypeId()))) {
field << static_cast<PropertyString*>(prop)->getValue();
else if (auto p = freecad_dynamic_cast<PropertyString>(prop)) {
field << p->getValue();
}
else {
assert(0);