MCPcopy Create free account
hub / github.com/NatLabRockies/OpenStudio / convertToStandardForm

Function convertToStandardForm

src/utilities/units/UnitFactory.cpp:680–700  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

678}
679
680std::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
702std::string replaceUnitString(const std::string& text, const std::string& newUnitString) {
703 std::string toReplace = extractUnitString(text);

Callers

nothing calls this directly

Calls 8

isDirectScaledUnitFunction · 0.85
createScaleMethod · 0.80
resizeMethod · 0.80
sFunction · 0.50
emptyMethod · 0.45
sizeMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected