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

Method parseVersionBuild

src/utilities/idd/IddFile.cpp:444–472  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

442}
443
444std::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
474bool IddFile::save(const openstudio::path& p, bool overwrite) {
475 path wp = completePathToFile(p, path(), "idd", true);

Callers

nothing calls this directly

Calls 7

toSystemFilenameFunction · 0.85
cbeginMethod · 0.80
cendMethod · 0.80
VersionStringClass · 0.70
toStringFunction · 0.50
readMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected