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

Method parse

src/energyplus/ErrorFile.cpp:46–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44 }
45
46 void ErrorFile::parse(openstudio::filesystem::ifstream& is) {
47 std::string line;
48
49 // matches[1], warning/error type
50 // matches[2], rest of line
51 boost::regex warningOrError(R"(^\s*\**\s+\*\*\s*([[:alpha:]]+)\s*\*\*(.*)$)");
52
53 // matches[1], rest of line
54 boost::regex warningOrErrorContinue(R"(^\s*\**\s+\*\*\s*~~~\s*\*\*(.*)$)");
55
56 // completed successfully
57 boost::regex completedSuccessful(R"(^\s*\*+ EnergyPlus Completed Successfully.*)");
58
59 // ground temp completed successfully
60 boost::regex groundTempCompletedSuccessful(R"(^\s*\*+ GroundTempCalc\S* Completed Successfully.*)");
61
62 // completed unsuccessfully
63 boost::regex completedUnsuccessful(R"(^\s*\*+ EnergyPlus Terminated.*)");
64
65 // repeat count
66
67 // read the file line by line using regexes
68 bool alreadyGotLine = false;
69
70 while (alreadyGotLine || std::getline(is, line)) {
71
72 alreadyGotLine = false;
73 boost::smatch matches;
74
75 // LOG(Trace, "Parsing ErrorFile Line '" << line << "'");
76
77 // parse the file
78 if (boost::regex_search(line, matches, warningOrError)) {
79
80 std::string warningOrErrorType = std::string(matches[1].first, matches[1].second);
81 boost::trim(warningOrErrorType);
82 std::string warningOrErrorString = std::string(matches[2].first, matches[2].second);
83 boost::trim(warningOrErrorString);
84
85 // read the rest of the multi line warning or error
86 while (true) {
87 // std::streampos pos = is.tellg();
88 if (!std::getline(is, line)) {
89 break;
90 }
91 if (boost::regex_search(line, matches, warningOrErrorContinue)) {
92 std::string temp = std::string(matches[1].first, matches[1].second);
93 boost::trim_right(temp);
94 warningOrErrorString += "\n" + temp;
95 } else {
96 // unget the line
97 // is.seekg(pos);
98 // Instead of rewind then reread (which fails on Windows if you have LF line endings)
99 // We just use this bool to avoid having to re-read the line.
100 alreadyGotLine = true;
101 break;
102 }
103 }

Callers 15

parse_pypi_versionFunction · 0.45
compareMethod · 0.45
compareMethod · 0.45
gFunction · 0.45
OtFunction · 0.45
$oFunction · 0.45
eFunction · 0.45
uFunction · 0.45
PFunction · 0.45
resetFunction · 0.45
setFunction · 0.45

Calls 2

valueMethod · 0.45
push_backMethod · 0.45

Tested by 15

compareMethod · 0.36
compareMethod · 0.36
resetFunction · 0.36
setFunction · 0.36
download_bcl_measureFunction · 0.36
bcl_measuresFunction · 0.36
update_measuresFunction · 0.36
compute_argumentsFunction · 0.36
create_measureFunction · 0.36
duplicate_measureFunction · 0.36
test_epJSON_StringMethod · 0.36