XLE  v0.02.0
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | List of all members
DiffMatchPatch.diff_match_patch Class Reference

Public Member Functions

List< Diffdiff_main (string text1, string text2)
 
List< Diffdiff_main (string text1, string text2, bool checklines)
 
int diff_commonPrefix (string text1, string text2)
 
int diff_commonSuffix (string text1, string text2)
 
void diff_cleanupSemantic (List< Diff > diffs)
 
void diff_cleanupSemanticLossless (List< Diff > diffs)
 
void diff_cleanupEfficiency (List< Diff > diffs)
 
void diff_cleanupMerge (List< Diff > diffs)
 
int diff_xIndex (List< Diff > diffs, int loc)
 
string diff_prettyHtml (List< Diff > diffs)
 
string diff_text1 (List< Diff > diffs)
 
string diff_text2 (List< Diff > diffs)
 
int diff_levenshtein (List< Diff > diffs)
 
string diff_toDelta (List< Diff > diffs)
 
List< Diffdiff_fromDelta (string text1, string delta)
 
int match_main (string text, string pattern, int loc)
 
List< Patchpatch_make (string text1, string text2)
 
List< Patchpatch_make (List< Diff > diffs)
 
List< Patchpatch_make (string text1, string text2, List< Diff > diffs)
 
List< Patchpatch_make (string text1, List< Diff > diffs)
 
List< Patchpatch_deepCopy (List< Patch > patches)
 
Object[] patch_apply (List< Patch > patches, string text)
 
string patch_addPadding (List< Patch > patches)
 
void patch_splitMax (List< Patch > patches)
 
string patch_toText (List< Patch > patches)
 
List< Patchpatch_fromText (string textline)
 

Static Public Member Functions

static string unescapeForEncodeUriCompatability (string str)
 

Public Attributes

float Diff_Timeout = 1.0f
 
short Diff_EditCost = 4
 
float Match_Threshold = 0.5f
 
int Match_Distance = 1000
 
float Patch_DeleteThreshold = 0.5f
 
short Patch_Margin = 4
 

Protected Member Functions

List< Diffdiff_bisect (string text1, string text2, DateTime deadline)
 
Object[] diff_linesToChars (string text1, string text2)
 
void diff_charsToLines (ICollection< Diff > diffs, List< string > lineArray)
 
int diff_commonOverlap (string text1, string text2)
 
string[] diff_halfMatch (string text1, string text2)
 
int match_bitap (string text, string pattern, int loc)
 
Dictionary< char, int > match_alphabet (string pattern)
 
void patch_addContext (Patch patch, string text)
 

Detailed Description

Class containing the diff, match and patch methods. Also Contains the behaviour settings.

Member Function Documentation

List<Diff> DiffMatchPatch.diff_match_patch.diff_bisect ( string  text1,
string  text2,
DateTime  deadline 
)
inlineprotected

Find the 'middle snake' of a diff, split the problem in two and return the recursively constructed diff. See Myers 1986 paper: An O(ND) Difference Algorithm and Its Variations.

Parameters
text1Old string to be diffed.
text2New string to be diffed.
deadlineTime at which to bail if not yet complete.
Returns
List of Diff objects.
void DiffMatchPatch.diff_match_patch.diff_charsToLines ( ICollection< Diff diffs,
List< string >  lineArray 
)
inlineprotected

Rehydrate the text in a diff from a string of line hashes to real lines of text.

Parameters
diffsList of Diff objects.
lineArrayList of unique strings.
void DiffMatchPatch.diff_match_patch.diff_cleanupEfficiency ( List< Diff diffs)
inline

Reduce the number of edits by eliminating operationally trivial equalities.

Parameters
diffsList of Diff objects.
void DiffMatchPatch.diff_match_patch.diff_cleanupMerge ( List< Diff diffs)
inline

Reorder and merge like edit sections. Merge equalities. Any edit section can move as long as it doesn't cross an equality.

Parameters
diffsList of Diff objects.
void DiffMatchPatch.diff_match_patch.diff_cleanupSemantic ( List< Diff diffs)
inline

Reduce the number of edits by eliminating semantically trivial equalities.

Parameters
diffsList of Diff objects.
void DiffMatchPatch.diff_match_patch.diff_cleanupSemanticLossless ( List< Diff diffs)
inline

Look for single edits surrounded on both sides by equalities which can be shifted sideways to align the edit to a word boundary. e.g: The c<ins>at c</ins>ame. -> The <ins>cat </ins>came.

Parameters
diffsList of Diff objects.
int DiffMatchPatch.diff_match_patch.diff_commonOverlap ( string  text1,
string  text2 
)
inlineprotected

Determine if the suffix of one string is the prefix of another.

Parameters
text1First string.
text2Second string.
Returns
The number of characters common to the end of the first string and the start of the second string.
int DiffMatchPatch.diff_match_patch.diff_commonPrefix ( string  text1,
string  text2 
)
inline

Determine the common prefix of two strings.

Parameters
text1First string.
text2Second string.
Returns
The number of characters common to the start of each string.
int DiffMatchPatch.diff_match_patch.diff_commonSuffix ( string  text1,
string  text2 
)
inline

Determine the common suffix of two strings.

Parameters
text1First string.
text2Second string.
Returns
The number of characters common to the end of each string.
List<Diff> DiffMatchPatch.diff_match_patch.diff_fromDelta ( string  text1,
string  delta 
)
inline

Given the original text1, and an encoded string which describes the operations required to transform text1 into text2, comAdde the full diff.

Parameters
text1Source string for the diff.
deltaDelta text.
Returns
Array of Diff objects or null if invalid.
Exceptions
ArgumentExceptionIf invalid input.
string [] DiffMatchPatch.diff_match_patch.diff_halfMatch ( string  text1,
string  text2 
)
inlineprotected

Do the two texts share a Substring which is at least half the length of the longer text? This speedup can produce non-minimal diffs.

Parameters
text1First string.
text2Second string.
Returns
Five element String array, containing the prefix of text1, the suffix of text1, the prefix of text2, the suffix of text2 and the common middle. Or null if there was no match.
int DiffMatchPatch.diff_match_patch.diff_levenshtein ( List< Diff diffs)
inline

Compute the Levenshtein distance; the number of inserted, deleted or substituted characters.

Parameters
diffsList of Diff objects.
Returns
Number of changes.
Object [] DiffMatchPatch.diff_match_patch.diff_linesToChars ( string  text1,
string  text2 
)
inlineprotected

Split two texts into a list of strings. Reduce the texts to a string of hashes where each Unicode character represents one line.

Parameters
text1First string.
text2Second string.
Returns
Three element Object array, containing the encoded text1, the encoded text2 and the List of unique strings. The zeroth element of the List of unique strings is intentionally blank.
List<Diff> DiffMatchPatch.diff_match_patch.diff_main ( string  text1,
string  text2 
)
inline

Find the differences between two texts. Run a faster, slightly less optimal diff. This method allows the 'checklines' of diff_main() to be optional. Most of the time checklines is wanted, so default to true.

Parameters
text1Old string to be diffed.
text2New string to be diffed.
Returns
List of Diff objects.
List<Diff> DiffMatchPatch.diff_match_patch.diff_main ( string  text1,
string  text2,
bool  checklines 
)
inline

Find the differences between two texts.

Parameters
text1Old string to be diffed.
text2New string to be diffed.
checklinesSpeedup flag. If false, then don't run a line-level diff first to identify the changed areas. If true, then run a faster slightly less optimal diff.
Returns
List of Diff objects.
string DiffMatchPatch.diff_match_patch.diff_prettyHtml ( List< Diff diffs)
inline

Convert a Diff list into a pretty HTML report.

Parameters
diffsList of Diff objects.
Returns
HTML representation.
string DiffMatchPatch.diff_match_patch.diff_text1 ( List< Diff diffs)
inline

Compute and return the source text (all equalities and deletions).

Parameters
diffsList of Diff objects.
Returns
Source text.
string DiffMatchPatch.diff_match_patch.diff_text2 ( List< Diff diffs)
inline

Compute and return the destination text (all equalities and insertions).

Parameters
diffsList of Diff objects.
Returns
Destination text.
string DiffMatchPatch.diff_match_patch.diff_toDelta ( List< Diff diffs)
inline

Crush the diff into an encoded string which describes the operations required to transform text1 into text2. E.g. =3-2+ing -> Keep 3 chars, delete 2 chars, insert 'ing'. Operations are tab-separated. Inserted text is escaped using xx notation.

Parameters
diffsArray of Diff objects.
Returns
Delta text.
int DiffMatchPatch.diff_match_patch.diff_xIndex ( List< Diff diffs,
int  loc 
)
inline

loc is a location in text1, comAdde and return the equivalent location in text2. e.g. "The cat" vs "The big cat", 1->1, 5->8

Parameters
diffsList of Diff objects.
locLocation within text1.
Returns
Location within text2.
Dictionary<char, int> DiffMatchPatch.diff_match_patch.match_alphabet ( string  pattern)
inlineprotected

Initialise the alphabet for the Bitap algorithm.

Parameters
patternThe text to encode.
Returns
Hash of character locations.
int DiffMatchPatch.diff_match_patch.match_bitap ( string  text,
string  pattern,
int  loc 
)
inlineprotected

Locate the best instance of 'pattern' in 'text' near 'loc' using the Bitap algorithm. Returns -1 if no match found.

Parameters
textThe text to search.
patternThe pattern to search for.
locThe location to search around.
Returns
Best match index or -1.
int DiffMatchPatch.diff_match_patch.match_main ( string  text,
string  pattern,
int  loc 
)
inline

Locate the best instance of 'pattern' in 'text' near 'loc'. Returns -1 if no match found.

Parameters
textThe text to search.
patternThe pattern to search for.
locThe location to search around.
Returns
Best match index or -1.
void DiffMatchPatch.diff_match_patch.patch_addContext ( Patch  patch,
string  text 
)
inlineprotected

Increase the context until it is unique, but don't let the pattern expand beyond Match_MaxBits.

Parameters
patchThe patch to grow.
textSource text.
string DiffMatchPatch.diff_match_patch.patch_addPadding ( List< Patch patches)
inline

Add some padding on text start and end so that edges can match something. Intended to be called only from within patch_apply.

Parameters
patchesArray of Patch objects.
Returns
The padding string added to each side.
Object [] DiffMatchPatch.diff_match_patch.patch_apply ( List< Patch patches,
string  text 
)
inline

Merge a set of patches onto the text. Return a patched text, as well as an array of true/false values indicating which patches were applied.

Parameters
patchesArray of Patch objects
textOld text.
Returns
Two element Object array, containing the new text and an array of bool values.
List<Patch> DiffMatchPatch.diff_match_patch.patch_deepCopy ( List< Patch patches)
inline

Given an array of patches, return another array that is identical.

Parameters
patchesArray of Patch objects.
Returns
Array of Patch objects.
List<Patch> DiffMatchPatch.diff_match_patch.patch_fromText ( string  textline)
inline

Parse a textual representation of patches and return a List of Patch objects.

Parameters
textlineText representation of patches.
Returns
List of Patch objects.
Exceptions
ArgumentExceptionIf invalid input.
List<Patch> DiffMatchPatch.diff_match_patch.patch_make ( string  text1,
string  text2 
)
inline

Compute a list of patches to turn text1 into text2. A set of diffs will be computed.

Parameters
text1Old text.
text2New text.
Returns
List of Patch objects.
List<Patch> DiffMatchPatch.diff_match_patch.patch_make ( List< Diff diffs)
inline

Compute a list of patches to turn text1 into text2. text1 will be derived from the provided diffs.

Parameters
diffsArray of Diff objects for text1 to text2.
Returns
List of Patch objects.
List<Patch> DiffMatchPatch.diff_match_patch.patch_make ( string  text1,
string  text2,
List< Diff diffs 
)
inline

Compute a list of patches to turn text1 into text2. text2 is ignored, diffs are the delta between text1 and text2.

Parameters
text1Old text
text2Ignored.
diffsArray of Diff objects for text1 to text2.
Returns
List of Patch objects.
Deprecated:
Prefer patch_make(string text1, List<Diff> diffs).
List<Patch> DiffMatchPatch.diff_match_patch.patch_make ( string  text1,
List< Diff diffs 
)
inline

Compute a list of patches to turn text1 into text2. text2 is not provided, diffs are the delta between text1 and text2.

Parameters
text1Old text.
diffsArray of Diff objects for text1 to text2.
Returns
List of Patch objects.
void DiffMatchPatch.diff_match_patch.patch_splitMax ( List< Patch patches)
inline

Look through the patches and break up any which are longer than the maximum limit of the match algorithm. Intended to be called only from within patch_apply.

Parameters
patchesList of Patch objects.
string DiffMatchPatch.diff_match_patch.patch_toText ( List< Patch patches)
inline

Take a list of patches and return a textual representation.

Parameters
patchesList of Patch objects.
Returns
Text representation of patches.
static string DiffMatchPatch.diff_match_patch.unescapeForEncodeUriCompatability ( string  str)
inlinestatic

Unescape selected chars for compatability with JavaScript's encodeURI. In speed critical applications this could be dropped since the receiving application will certainly decode these fine. Note that this function is case-sensitive. Thus "%3F" would not be unescaped. But this is ok because it is only called with the output of HttpUtility.UrlEncode which returns lowercase hex.

Example: "%3f" -> "?", "%24" -> "$", etc.

Parameters
strThe string to escape.
Returns
The escaped string.

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