| 442 | } |
| 443 | |
| 444 | std::pair<VersionString, std::string> IddFile::parseVersionBuild(const openstudio::path& p) { |
| 445 | std::ifstream ifs(openstudio::toSystemFilename(p)); |
| 446 | |
| 447 | if (!ifs.good()) { |
| 448 | throw std::runtime_error("Unable to open file for reading: " + openstudio::toString(p)); |
| 449 | } |
| 450 | |
| 451 | ifs.seekg(0, std::ios_base::end); |
| 452 | const auto end = ifs.tellg(); |
| 453 | ifs.seekg(0, std::ios_base::beg); |
| 454 | |
| 455 | const auto length_to_read = std::min(std::streampos(10000), end); |
| 456 | |
| 457 | std::vector<char> data(length_to_read); |
| 458 | ifs.read(data.data(), length_to_read); |
| 459 | const std::string strdata(data.cbegin(), data.cend()); |
| 460 | |
| 461 | std::string build; |
| 462 | boost::smatch matches; |
| 463 | if (boost::regex_search(strdata, matches, iddRegex::build())) { |
| 464 | build = std::string(matches[1].first, matches[1].second); |
| 465 | } |
| 466 | |
| 467 | if (boost::regex_search(strdata, matches, iddRegex::version())) { |
| 468 | return std::make_pair(VersionString(std::string(matches[1].first, matches[1].second)), build); |
| 469 | } |
| 470 | |
| 471 | throw std::runtime_error("Unable to parse version from IDD: " + openstudio::toString(p)); |
| 472 | } |
| 473 | |
| 474 | bool IddFile::save(const openstudio::path& p, bool overwrite) { |
| 475 | path wp = completePathToFile(p, path(), "idd", true); |
nothing calls this directly
no test coverage detected