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

Function decomposeQuantityString

src/utilities/units/QuantityRegex.cpp:290–308  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

288}
289
290std::pair<std::string, std::string> decomposeQuantityString(const std::string& s) {
291
292 std::pair<std::string, std::string> result;
293 boost::match_results<std::string::const_iterator> match;
294 if (!boost::regex_match(s, match, regexQuantity())) {
295 LOG_FREE_AND_THROW("openstudio.QuantityRegex", "Cannot decompose " << s << " into (value,unit) because it is not a quantity.");
296 }
297 // pull out number
298 result.first = std::string(match[1].first, match[1].second);
299 // see if there is / between number and unit
300 std::string temp(match[2].first, match[2].second);
301 if (temp == "/") {
302 result.second = "1/";
303 }
304 // pull out unit
305 result.second += std::string(match[3].first, match[3].second);
306
307 return result;
308}
309
310std::pair<std::string, std::string> decomposeScaledUnitString(const std::string& s) {
311 if (!isScaledUnit(s)) {

Callers 2

createQuantityMethod · 0.85
TEST_FFunction · 0.85

Calls

no outgoing calls

Tested by 1

TEST_FFunction · 0.68