| 294 | } |
| 295 | |
| 296 | std::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 |
| 317 | bool Quantity::isDimensionless() const |