TextMerge.h header

#include <ew/app/TextMerge.h>

Namespace ew::app

MergeRegion struct

struct ew::app::MergeRegion

One contiguous region of a three-way merge, classified by how the two sides changed the common base. A region carries all three renderings (base / local / remote) so a UI can show the full context of a conflict and offer either side.

Members

enum class Kind { Unchanged, LocalChange, RemoteChange, BothSame, Conflict }

How local and remote diverged from the base over this region.

Kind ew::app::MergeRegion::kind =

The classification of this region.

std::vector<QString> ew::app::MergeRegion::base

The region's lines as they appear in the common ancestor.

std::vector<QString> ew::app::MergeRegion::local

The region's lines as they appear in the local version.

std::vector<QString> ew::app::MergeRegion::remote

The region's lines as they appear in the remote version.

MergeResult struct

struct ew::app::MergeResult

The outcome of a three-way merge: the ordered regions plus convenience renderings.

Members

std::vector<MergeRegion> ew::app::MergeResult::regions

The merge regions, in reading order, covering the whole document.

bool ew::app::MergeResult::hasConflicts() const

Whether any region is a conflict (local and remote changed the same lines differently).

int ew::app::MergeResult::conflictCount() const

The number of conflict regions.

QString ew::app::MergeResult::mergedText(const QString &localLabel=QStringLiteral("local"), const QString &remoteLabel=QStringLiteral("remote")) const

The merged text with conflicts left as diff3-style markers (<<<<<<< localLabel / ======= / >>>>>>> remoteLabel) and every non-conflict region auto-resolved. Lines are joined with ' ' to mirror how the text was split.

QString ew::app::MergeResult::resolvedText(bool preferLocal) const

The fully-resolved text, taking the local side of every conflict when preferLocal is true and the remote side otherwise. Non-conflict regions resolve to whichever side changed.

Functions

MergeResult ew::app::threeWayMerge(const QString &base, const QString &local, const QString &remote)

Performs a line-level three-way merge of local and remote against their common ancestor base (diff3). Each text is split on newlines; lines both sides left alone stay, a change made by only one side is taken automatically, an identical change made by both sides is taken once, and a region both sides changed differently becomes a Conflict. This is the offline-first conflict-resolution core: it needs no network and is fully deterministic.