MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / parseString

Method parseString

src/Gui/QuantitySpinBox.cpp:135–166  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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,

Callers 5

parseStringFunction · 0.80
openFunction · 0.80
insertFunction · 0.80
getGuiDataFunction · 0.80
buildPsets.pyFile · 0.80

Calls 8

getDocumentObjectMethod · 0.80
constDataMethod · 0.80
evalMethod · 0.80
parseFunction · 0.50
removeMethod · 0.45
getMethod · 0.45
getQuantityMethod · 0.45
getValueMethod · 0.45

Tested by

no test coverage detected