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

Method getSafeUserString

src/Base/Quantity.cpp:296–314  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

294}
295
296std::string Quantity::getSafeUserString() const
297{
298 auto userStr = getUserString();
299 if (myValue != 0.0) {
300 bool useFallback {false};
301 try {
302 useFallback = (parse(userStr).getValue() == 0);
303 }
304 catch (const Base::ParserError&) {
305 useFallback = true;
306 }
307 if (useFallback) {
308 auto unitStr = getUnit().getString();
309 userStr = fmt::format("{}{}{}", myValue, unitStr.empty() ? "" : " ", unitStr);
310 }
311 }
312
313 return Tools::escapeQuotesFromString(userStr);
314}
315
316/// true if unit equals to 1, therefore quantity has no dimension
317bool Quantity::isDimensionless() const

Callers 15

setRawTextMethod · 0.80
get_temperatureMethod · 0.80
getAmbientTempMethod · 0.80
getFilmCoefMethod · 0.80
getDFluxMethod · 0.80
getPressureMethod · 0.80
get_temperatureMethod · 0.80
get_cfluxMethod · 0.80
getNormalStiffnessMethod · 0.80
getForceMethod · 0.80
getForceMethod · 0.80

Calls 6

parseFunction · 0.50
getUnitFunction · 0.50
formatFunction · 0.50
getValueMethod · 0.45
getStringMethod · 0.45
emptyMethod · 0.45

Tested by 3

setMethod · 0.64
setWithPrecisionMethod · 0.64
setWithDenominatorMethod · 0.64