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

Function decomposeDirectScaledUnit

src/utilities/units/QuantityRegex.cpp:220–235  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

218}
219
220std::pair<std::string, std::pair<unsigned, std::string>> decomposeDirectScaledUnit(const std::string& s) {
221 if (!isDirectScaledUnit(s)) {
222 LOG_FREE_AND_THROW("openstudio.QuantityRegex",
223 "Cannot decompose " << s << " into a numerator and scaled denominator because it is not an direct scaled unit.");
224 }
225 std::pair<std::string, std::pair<unsigned, std::string>> result;
226 boost::match_results<std::string::const_iterator> match;
227
228 boost::regex_search(s, match, regexDirectScaledUnit());
229 result.first = std::string(match[1].first, match[1].second);
230 std::string powerOfTen(match[2].first, match[2].second);
231 result.second.first = powerOfTen.size() - 1;
232 result.second.second = std::string(match[3].first, match[3].second);
233
234 return result;
235}
236
237bool isDirectScaledUnit(const std::string& s) {
238 return boost::regex_match(s, regexDirectScaledUnit());

Callers 2

convertToStandardFormFunction · 0.85
TEST_FFunction · 0.85

Calls 2

isDirectScaledUnitFunction · 0.85
sizeMethod · 0.45

Tested by 1

TEST_FFunction · 0.68