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

Method ExtractHunksDifferences

FileFilter/UnifiedDiffParser.cpp:200–225  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

198
199 //-------------------------------------------------------------------------
200 UnifiedDiffParser::HunksDifferences
201 UnifiedDiffParser::ExtractHunksDifferences(
202 const Stream& stream,
203 const std::wstring& hunksDifferencesLine) const
204 {
205 std::wstring range = L"(\\d+)(?:,(\\d+))?";
206 std::wregex hunkRegex{ L"^@@\\s*-" + range + L"\\s*\\+" + range + L"\\s*@@" };
207 std::wcmatch match;
208
209 if (std::regex_search(hunksDifferencesLine.c_str(), match, hunkRegex))
210 {
211 if (match.size() == 5 && match[1].matched && match[3].matched)
212 {
213 HunksDifferences hunksDifferences;
214 hunksDifferences.startFrom = std::stoi(match[1]);
215 hunksDifferences.countFrom = match[2].matched ? std::stoi(match[2]) : 1;
216 hunksDifferences.startTo = std::stoi(match[3]);
217 hunksDifferences.countTo = match[4].matched ? std::stoi(match[4]) : 1;
218
219 return hunksDifferences;
220 }
221 }
222
223 ThrowError(stream, UnifiedDiffParserException::ErrorInvalidHunks);
224 return{};
225 }
226
227 //-------------------------------------------------------------------------
228 std::vector<int> UnifiedDiffParser::ExtractUpdatedLines(

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected