MCPcopy Create free account
hub / github.com/KDE/kate / parseDiffNumStat

Method parseDiffNumStat

addons/project/git/gitstatus.cpp:209–246  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

207}
208
209void GitUtils::parseDiffNumStat(QList<GitUtils::StatusItem> &items, const QByteArray &raw)
210{
211 // format:
212 // 12\t10\tFileName
213 // 12 = add, 10 = sub, fileName at the end
214 for (auto line : ByteArraySplitter(raw, '\0')) {
215 size_t addEnd = line.find_first_of('\t');
216 if (addEnd == std::string_view::npos) {
217 continue;
218 }
219
220 size_t subStart = line.find_first_not_of('\t', addEnd);
221 if (subStart == std::string_view::npos) {
222 continue;
223 }
224
225 size_t subEnd = line.find_first_of('\t', subStart);
226 if (subEnd == std::string_view::npos) {
227 continue;
228 }
229
230 std::string_view addStr = line.substr(0, addEnd);
231 std::string_view subStr = line.substr(subStart, subEnd - subStart);
232 std::string_view fileStr = line.substr(subEnd + 1, line.size() - (subEnd + 1));
233
234 auto add = toInt(addStr);
235 auto sub = toInt(subStr);
236
237 if (!add.has_value()) {
238 continue;
239 }
240 if (!sub.has_value()) {
241 continue;
242 }
243
244 addNumStat(items, add.value(), sub.value(), fileStr);
245 }
246}
247
248QList<GitUtils::StatusItem> GitUtils::parseDiffNameStatus(const QByteArray &raw)
249{

Callers

nothing calls this directly

Calls 5

ByteArraySplitterClass · 0.85
toIntFunction · 0.85
addNumStatFunction · 0.85
sizeMethod · 0.80
valueMethod · 0.80

Tested by

no test coverage detected