| 218 | } |
| 219 | |
| 220 | std::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 | |
| 237 | bool isDirectScaledUnit(const std::string& s) { |
| 238 | return boost::regex_match(s, regexDirectScaledUnit()); |