| 678 | } |
| 679 | |
| 680 | std::string convertToStandardForm(const std::string& unitString) { |
| 681 | std::string result(unitString); |
| 682 | if (isDirectScaledUnit(unitString)) { |
| 683 | std::pair<std::string, std::pair<unsigned, std::string>> fragments = decomposeDirectScaledUnit(unitString); |
| 684 | ScaleConstant s; |
| 685 | s = ScaleFactory::instance().createScale(-static_cast<int>(fragments.second.first)); |
| 686 | if (s().value != 0.0) { |
| 687 | std::stringstream ss; |
| 688 | ss << s().abbr << "("; |
| 689 | if (!fragments.second.second.empty()) { |
| 690 | ss << fragments.first << fragments.second.second; |
| 691 | } else { |
| 692 | fragments.first.resize(fragments.first.size() - 1); // remove '/' |
| 693 | ss << fragments.first; |
| 694 | } |
| 695 | ss << ")"; |
| 696 | result = ss.str(); |
| 697 | } |
| 698 | } |
| 699 | return result; |
| 700 | } |
| 701 | |
| 702 | std::string replaceUnitString(const std::string& text, const std::string& newUnitString) { |
| 703 | std::string toReplace = extractUnitString(text); |
nothing calls this directly
no test coverage detected