MCPcopy Create free account
hub / github.com/OpenCppCoverage/OpenCppCoverage / Export

Method Export

Exporter/Html/HtmlFileCoverageExporter.cpp:108–136  ·  view source on GitHub ↗

-------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

106
107 //-------------------------------------------------------------------------
108 bool HtmlFileCoverageExporter::Export(
109 const Plugin::FileCoverage& fileCoverage,
110 std::wostream& output) const
111 {
112 auto filePath = fileCoverage.GetPath();
113
114 std::wifstream ifs{filePath.string()};
115 if (!ifs)
116 THROW(L"Cannot open file : " + filePath.wstring());
117
118 std::wstring line;
119 const Plugin::LineCoverage* previousLineCoverage = nullptr;
120 int styleChangesCount = 0;
121 int lineCount = 0;
122 for (int i = 1; std::getline(ifs, line); ++i)
123 {
124 auto lineCoverage = fileCoverage[i];
125
126 line = boost::spirit::classic::xml::encode(line);
127 if (AddLineCoverageColor(output, line, lineCoverage, previousLineCoverage))
128 ++styleChangesCount;
129 ++lineCount;
130 previousLineCoverage = lineCoverage;
131 }
132 AddEndStyleIfNeeded(output, previousLineCoverage);
133 output.flush();
134
135 return MustEnableCodePrettify(lineCount, styleChangesCount);
136 }
137
138 //-------------------------------------------------------------------------
139 bool HtmlFileCoverageExporter::MustEnableCodePrettify(

Callers

nothing calls this directly

Calls 2

AddLineCoverageColorFunction · 0.85
AddEndStyleIfNeededFunction · 0.85

Tested by

no test coverage detected