TextDiff.h header
#include <ew/app/TextDiff.h>
Namespace ew::app
DiffLine struct
struct ew::app::DiffLine
One line of a line-level diff: what happened to it, and the line's text.
Members
DiffOp ew::app::DiffLine::op =
The change this line represents.
QString ew::app::DiffLine::text
The line's text (without its trailing newline).
DiffStats struct
struct ew::app::DiffStats
A tally of a diff's changes, for a compact summary line.
Members
int ew::app::DiffStats::inserted = 0
Number of lines added in the new text.
int ew::app::DiffStats::deleted = 0
Number of lines removed from the old text.
int ew::app::DiffStats::unchanged = 0
Number of lines shared by both texts.
Enumerations
enum class DiffOp { Equal, Insert, Delete }
The kind of change a diff line represents.
Functions
std::vector< DiffLine > ew::app::diffLines(const QString &before, const QString &after)
Computes a line-level diff from before to after via a longest-common-subsequence edit script. Each text is split on newlines; shared lines become Equal, lines only in after become Insert, and lines only in before become Delete. The result is ordered top-to-bottom as a unified diff would read – a replaced region lists its deletions before the insertions that replace them – so a viewer can render it directly. Comparing identical texts yields all-Equal.
DiffStats ew::app::diffStats(const std::vector< DiffLine > &diff)
Tallies the Insert/Delete/Equal operations in diff.