Quark  0.1
DiffChunk Class Reference

TODO: rewrite comment A DiffChunk maps a DiffRange in one DiffSequence (the "base") to a corresponding DiffRange in one or two other files ("theirs" and "yours"). More...

#include <DiffChunk.h++>

Public Types

enum  Type {
  TYPE_UNCHANGED, TYPE_INSERT, TYPE_DELETE, TYPE_CHANGED,
  TYPE_CONFLICT
}
 

Public Member Functions

 DiffChunk ()
 
 DiffChunk (const DiffRange &baseRange, const DiffRange &yoursRange, bool yoursModified)
 
 DiffChunk (const DiffRange &baseRange, const DiffRange &yoursRange, bool yoursModified, const DiffRange &theirsRange, bool theirsModified, bool conflict)
 
 ~DiffChunk ()
 
Type type (DiffRole role, DiffDirection dir) const
 
bool isUnchanged () const
 
bool isModified (DiffRole destination) const
 
bool isBothModified () const
 
bool isConflict () const
 
const DiffRangebaseRange () const
 
DiffRangebaseRange ()
 
const DiffRangesourceRange () const
 
DiffRangesourceRange ()
 
const DiffRangedestinationRange () const
 
DiffRangedestinationRange ()
 
const DiffRangeyoursRange () const
 
DiffRangeyoursRange ()
 
const DiffRangetheirsRange () const
 
DiffRangetheirsRange ()
 
const DiffRangerange (DiffRole role) const
 
void setSubDiff (DiffResult *subDiff)
 
const DiffResultsubDiff () const
 

Detailed Description

TODO: rewrite comment A DiffChunk maps a DiffRange in one DiffSequence (the "base") to a corresponding DiffRange in one or two other files ("theirs" and "yours").

For a two-way merge, the "base range" is the DiffRange in the "old" sequence, and the "yours range" in the DiffRange in the "new" sequence.

For a three-way merge, the "base" range is the DiffRange in the "base" sequence, and the "yours range" and "theirs range" are the DiffRanges in the "yours" and "theirs" sequences.

In addition to the two or three DiffRanges, the DiffChunk also has three boolean flags that indicate how the subsequences defined by the two or three DiffRanges relate to each other:

yours_modified_ - Indicates whether the range of elements in "yours" differs from the range of elements in "base". theirs_modified_ - Indicates whether the range of elements in "theirs" differs form the range of elements in "base". conflict_ - Indicates whether the range of elements in "theirs" differs from the range of elements in "yours".

Using these flags, and the lengths of the element ranges, it is possible to deduce the type of edit that occurred. For example: if yours_modified_ is true, theirs_modified_ is false, conflict_ is (necessarily) false, the base range is empty, the theirs range is (necessarily) empty, and the yours range is non-empty, then the chunk represents an insert of one or more new elements in "yours".

Member Enumeration Documentation

◆ Type

enum Type
Enumerator
TYPE_UNCHANGED 
TYPE_INSERT 
TYPE_DELETE 
TYPE_CHANGED 
TYPE_CONFLICT 

Constructor & Destructor Documentation

◆ DiffChunk() [1/3]

DiffChunk ( )

◆ DiffChunk() [2/3]

DiffChunk ( const DiffRange baseRange,
const DiffRange yoursRange,
bool  yoursModified 
)

◆ DiffChunk() [3/3]

DiffChunk ( const DiffRange baseRange,
const DiffRange yoursRange,
bool  yoursModified,
const DiffRange theirsRange,
bool  theirsModified,
bool  conflict 
)

◆ ~DiffChunk()

~DiffChunk ( )

Member Function Documentation

◆ baseRange() [1/2]

const DiffRange& baseRange ( ) const
inline

◆ baseRange() [2/2]

DiffRange& baseRange ( )
inline

◆ destinationRange() [1/2]

const DiffRange& destinationRange ( ) const
inline

◆ destinationRange() [2/2]

DiffRange& destinationRange ( )
inline

◆ isBothModified()

bool isBothModified ( ) const
inline

◆ isConflict()

bool isConflict ( ) const
inline

◆ isModified()

bool isModified ( DiffRole  destination) const

◆ isUnchanged()

bool isUnchanged ( ) const
inline

◆ range()

const DiffRange& range ( DiffRole  role) const

◆ setSubDiff()

void setSubDiff ( DiffResult subDiff)
inline

◆ sourceRange() [1/2]

const DiffRange& sourceRange ( ) const
inline

◆ sourceRange() [2/2]

DiffRange& sourceRange ( )
inline

◆ subDiff()

const DiffResult* subDiff ( ) const
inline

◆ theirsRange() [1/2]

const DiffRange& theirsRange ( ) const
inline

◆ theirsRange() [2/2]

DiffRange& theirsRange ( )
inline

◆ type()

Type type ( DiffRole  role,
DiffDirection  dir 
) const

◆ yoursRange() [1/2]

const DiffRange& yoursRange ( ) const
inline

◆ yoursRange() [2/2]

DiffRange& yoursRange ( )
inline

The documentation for this class was generated from the following file: