| 133 | return success; |
| 134 | } |
| 135 | bool parseString( |
| 136 | const QString& str, |
| 137 | Base::Quantity& result, |
| 138 | double& value, |
| 139 | const App::ObjectIdentifier& path |
| 140 | ) const |
| 141 | { |
| 142 | App::ObjectIdentifier pathtmp = path; |
| 143 | try { |
| 144 | QString copy = str; |
| 145 | copy.remove(locale.groupSeparator()); |
| 146 | |
| 147 | // Expression parser |
| 148 | std::shared_ptr<Expression> expr( |
| 149 | ExpressionParser::parse(path.getDocumentObject(), copy.toUtf8().constData()) |
| 150 | ); |
| 151 | if (expr) { |
| 152 | |
| 153 | std::unique_ptr<Expression> res(expr->eval()); |
| 154 | NumberExpression* n = freecad_cast<NumberExpression*>(res.get()); |
| 155 | if (n) { |
| 156 | result = n->getQuantity(); |
| 157 | value = result.getValue(); |
| 158 | return true; |
| 159 | } |
| 160 | } |
| 161 | } |
| 162 | catch (Base::Exception&) { |
| 163 | return false; |
| 164 | } |
| 165 | return false; |
| 166 | } |
| 167 | Base::Quantity validateAndInterpret( |
| 168 | QString& input, |
| 169 | QValidator::State& state, |
no test coverage detected