A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://www.ncbi.nlm.nih.gov/IEB/ToolBox/CPP_DOC/doxyhtml/group__Diff.html below:

NCBI C++ ToolKit: Diff

  CDiffOperation::SPos::SPos (size_type p1=NPOS, size_type p2=NPOS)     CDiffOperation::CDiffOperation (EType operation, CTempString str)   Constructor. More...
  EType  CDiffOperation::GetOperation () const   Get type of operation. More...
  bool  CDiffOperation::IsInsert (void) const   Check type of operation. More...
  bool  CDiffOperation::IsDelete (void) const   bool  CDiffOperation::IsEqual (void) const   CTempString  CDiffOperation::GetString (void) const   Get string for current operation. More...
  size_type  CDiffOperation::GetLength (void) const   Get string length. More...
  SPos  CDiffOperation::GetOffset (void) const   Get offset of the current difference in the original text. More...
  SPos  CDiffOperation::GetLine (void) const   Get line number of the current difference (line-mode diff only). More...
  bool  CDiffOperation::operator== (const CDiffOperation &diff_op) const   Compare substrings and operation types only, all other attributes (offset, row, col and etc) are not used in comparison. More...
  bool  CDiffOperation::operator!= (const CDiffOperation &diff_op) const   void  CDiffOperation::SetOperation (EType operation)   void  CDiffOperation::SetString (CTempString str, size_type len=NPOS)   void  CDiffOperation::SetLength (size_type length)   void  CDiffOperation::SetOffset (SPos offset)   void  CDiffOperation::SetLine (SPos line)     CDiffList::CDiffList (void)   Constructor. More...
  size_type  CDiffList::GetEditDistance (void) const   Compute the edit distance (Levenshtein distance). More...
  CTempString  CDiffList::GetLongestCommonSubstring (void) const   Find the longest common substring for current difference list. More...
  void  CDiffList::CleanupAndMerge (void)   Reorder and merge like edit sections, merge equalities. More...
  void  CDiffList::CalculateOffsets (void)   Calculate offsets for all substrings in the difference list and find its position from the start of the original strings, used in diff. More...
  const TListCDiffList::GetList (void) const   Get list of the diff operations as list<>. More...
  void  CDiffList::Clear (void)   Remove all elements from the list. More...
  void  CDiffList::Prepend (CDiffOperation::EType operation, CTempString str)   Add element to the front of the list. More...
  void  CDiffList::Prepend (const CDiffOperation &op)   Add element to the front of the list. More...
  void  CDiffList::Append (CDiffOperation::EType operation, CTempString str)   Add element to the end of the list. More...
  void  CDiffList::Append (const CDiffOperation &op)   Add element to the end of the list. More...
  void  CDiffList::x_CleanupAndMerge_Equities (void)   Merge adjacent parts with the same operation. More...
  bool  CDiffList::x_CleanupAndMerge_SingleEdits (void)   Look for single edits surrounded on both sides by equalities which can be shifted sideways to eliminate an equality. More...
  void  CDiffBase::SetTimeout (const CTimeout &tmo)   Set timeout. More...
  bool  CDiffBase::IsTimeoutExpired () const   Check if timeout is expired. More...
    CDiffBase::CDiffBase (void)   Constructor. More...
  void  CDiffBase::Reset (void)   Reset internal state and prepare to next Diff() More...
  CDiffListCDiff::Diff (CTempString s1, CTempString s2, TFlags flags=0)   Find the differences between two texts (character mode). More...
  bool  CDiff::x_DiffHalfMatch (CTempString s1, CTempString s2, TDiffHalfMatchList &hm) const   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. More...
  bool  CDiff::x_DiffHalfMatchI (CTempString long_str, CTempString short_str, size_type i, TDiffHalfMatchList &hm) const   Does a substring of short string exist within long string such that the substring is at least half the length of long string? More...
  void  CDiff::x_DiffBisect (CTempString s1, CTempString s2, CDiffList &diffs) const   Find the 'middle snake' of a diff, split the problem in two and return the recursively constructed diff. More...
  void  CDiff::x_DiffBisectSplit (CTempString s1, CTempString s2, int x, int y, CDiffList &diffs) const   Given the location of the 'middle snake', split the diff in two parts and recurse. More...
  void  CDiff::x_Diff (CTempString s1, CTempString s2, CDiffList &diffs) const   Find the differences between two texts. More...
  CDiffListCDiffText::Diff (CTempString text1, CTempString text2, TFlags flags=0)   Find the differences between two texts (line mode). More...
  CNcbiOstreamCDiffText::PrintUnifiedDiff (CNcbiOstream &out, CTempString text1, CTempString text2, unsigned int num_common_lines=3)   Find the differences between two texts and print result into output stream in unified-like format. More...
  virtual const char *  CDiffException::GetErrCodeString (void) const override   Get error code interpreted as text. More...
    CDiffException::NCBI_EXCEPTION_DEFAULT (CDiffException, CException)   ◆ size_type [1/3] ◆ size_type [2/3]

Size type definition.

Definition at line 188 of file diff.hpp.

◆ size_type [3/3]

Type definition.

Definition at line 292 of file diff.hpp.

◆ TDiffHalfMatchList ◆ TFlags [1/2]

Bitwise OR of "EFlags".

Definition at line 346 of file diff.hpp.

◆ TFlags [2/2]

Bitwise OR of "Flags".

Definition at line 407 of file diff.hpp.

◆ TList

Storage class type for the list of diff operations.

Definition at line 190 of file diff.hpp.

◆ EErrCode Enumerator eEmpty  eBadFlags 

Definition at line 475 of file diff.hpp.

◆ EFlags [1/2]

Processing flags.

Enumerator fNoCleanup 

By default Diff() automatically call CleanupAndMerge() for the generated list of differences to have a shorter and cleaner list of results.

It is on by default for regular character-based diff. But if you need faster (and less optimal) result, you can skip it.

fCalculateOffsets 

Automatically call CalculateOffests() for the generated list of differences.

Definition at line 336 of file diff.hpp.

◆ EFlags [2/2]

Processing flags.

Enumerator fCleanup 

Automatically call CleanupAndMerge() for the generated list of differences after Diff() to have a shorter and cleaner list of results.

It is off by default for line-based diffs.

fCalculateOffsets 

Automatically call CalculateOffests() for the generated list of differences.

fIgnoreEOL 

Ignore differences in end-of-line types on string comparison.

fRemoveEOL 

Remove end-of-line symbols from each string added to the list, which can be obtained using CDiffOperation::GetString().

This flag is incompatible with fCleanup, exception will be thrown if they where used together. The fRemoveEOL affect a visual appearance of the string, and do not have an influence on how lines with different kind of EOLs compares, use fIgnoreEOL in addition if necessary.

Definition at line 388 of file diff.hpp.

◆ EType

Type of the current diff operation.

Enumerator eDelete 

String that exists in old text, and deleted in new one.

eEqual 

String exists in both texts.

eInsert 

String that exists in new text, and deleted in old one.

Definition at line 72 of file diff.hpp.

◆ Append() [1/2] ◆ Append() [2/2] ◆ CalculateOffsets() void CDiffList::CalculateOffsets ( void  )

Calculate offsets for all substrings in the difference list and find its position from the start of the original strings, used in diff.

For performance reasons, Diff() do not operate with offsets of the substrings and do not store them, but as original strings can be easy reconstructed from the list of diffs, that offsets also can be calculated afterwards.

For DELETE or EQUAl type operations the calculated value is an offset of the substring in the first (original) string used in diff. For INSERT type operation the calculated value is an offset in the second (result) string used in diff.

Note
This method cannot calculate rows and columns for regular diffs, use line-mode diffs that do this automatically.
See also
CDiffOperation::GetOffset()

Definition at line 152 of file diff.cpp.

References DIFF_DELETE, DIFF_EQUAL, DIFF_INSERT, eEmpty, CDiffList::m_List, NCBI_THROW, NON_CONST_ITERATE, and NPOS.

Referenced by CDiff::Diff(), and CDiffText::Diff().

◆ CDiffBase() CDiffBase::CDiffBase ( void  ) inlineprivate ◆ CDiffList() CDiffList::CDiffList ( void  ) inline ◆ CDiffOperation()

Constructor.

Parameters
operation Type of the current diff operation. str The string associated with this diff operation.

Definition at line 58 of file diff.cpp.

◆ CleanupAndMerge() void CDiffList::CleanupAndMerge ( void  ) ◆ Clear() void CDiffList::Clear ( void  ) inline ◆ Diff() [1/2]

Find the differences between two texts (character mode).

Parameters
s1 Old string to be diffed. s2 New string to be diffed. @flags Processing flags.
Returns
The list of operations that should be done to convert string 's1' to 's2'.
See also
SetTimeout(), CDiffText

Definition at line 364 of file diff.cpp.

References CDiffList::Append(), CDiffList::CalculateOffsets(), CDiffList::CleanupAndMerge(), NStr::CommonPrefixSize(), NStr::CommonSuffixSize(), DIFF_EQUAL, CTempString::empty(), F_ISSET, CDiff::fCalculateOffsets, CDiff::fNoCleanup, CTimeout::IsInfinite(), CDiffBase::IsTimeoutExpired(), CTempString::length(), CDiffBase::m_Deadline, CDiffBase::m_Diffs, CDiffBase::m_Timeout, NULL, CDiffList::Prepend(), CDiff_Base::Reset(), CTempString::substr(), and CDiff::x_Diff().

◆ Diff() [2/2]

Find the differences between two texts (line mode).

Run a line-based diff, that operates with whole lines, and not trying to find a differences inside added/deleted blocks of lines.

Parameters
text1 Old text to be diffed. text2 New text to be diffed. @flags Processing flags. Default: non-optimal line-based diff that have all EOLs.
Returns
The list of operations that should be done to convert text 's1' to 's2'.
See also
SetTimeout(), CDiff

Definition at line 766 of file diff.cpp.

References _TROUBLE, _VERIFY, CDiffList::Append(), CDiffList::CalculateOffsets(), CDiffList::CleanupAndMerge(), dtl::Diff< elem, sequence, comparator >::compose(), CTempString::data(), DIFF_DELETE, DIFF_EQUAL, DIFF_INSERT, F_ISSET, CDiffText::fCalculateOffsets, CDiffText::fCleanup, CDiffText::fIgnoreEOL, CDiffText::fRemoveEOL, dtl::Diff< elem, sequence, comparator >::getSes(), i, CTimeout::IsInfinite(), CDiffBase::IsTimeoutExpired(), len, CTempString::length(), line1, line2, CDiffBase::m_Deadline, CDiffBase::m_Diffs, CDiffList::m_List, CDiffBase::m_Timeout, NCBI_THROW, NPOS, NULL, dtl::Diff< elem, sequence, comparator >::onHuge(), CDiffBase::Reset(), dtl::SES_ADD, dtl::SES_COMMON, dtl::SES_DELETE, CDiffOperation::SetLength(), CDiffOperation::SetLine(), NStr::Split(), and str().

Referenced by CDiffText::PrintUnifiedDiff().

◆ GetEditDistance()

Compute the edit distance (Levenshtein distance).

Can be used to check how much strings differ.

Returns
Return number of single-character edits in the current difference list, including the number of inserted, deleted or substituted characters, required to be done to convert one string to another. Return zero if diffed strings are equal.

Definition at line 70 of file diff.cpp.

References DIFF_DELETE, DIFF_EQUAL, DIFF_INSERT, eEmpty, CDiffList::GetList(), ITERATE, max(), and NCBI_THROW.

◆ GetErrCodeString() const char * CDiffException::GetErrCodeString ( void  ) const overridevirtual ◆ GetLength() size_type CDiffOperation::GetLength ( void  ) const inline

Get string length.

For character-based diffs it is the same as GetString().length(). But in the line-based diffs the string can be truncated and it may not have ending EOL. So, the original string can be reconstructed using: CTempString(op.GetString().data(), op.GetLength())

Definition at line 113 of file diff.hpp.

References CDiffOperation::m_Length.

◆ GetLine()

Get line number of the current difference (line-mode diff only).

Line numbers are 1-based.

Returns
See also
GetOperation(), GetString(), GetOffset(), CDiff::DiffLines()

Definition at line 516 of file diff.hpp.

References CDiffOperation::m_Line.

◆ GetList() ◆ GetLongestCommonSubstring() CTempString CDiffList::GetLongestCommonSubstring ( void  ) const

Find the longest common substring for current difference list.

Returns
The algorithm just returns the first longest common substring it finds, which therefore may not be unique. Return empty string if compared strings where fully different and no common substrings where found.
Note
If current difference list is not optimal, the result can be shorter than it should be. Use CleanupAndMerge() first to get more optimized diff.
For not optimized line-based diffs it return a first longest common line.

Definition at line 101 of file diff.cpp.

References eEmpty, CDiffList::GetList(), ITERATE, len, and NCBI_THROW.

◆ GetOffset()

Get offset of the current difference in the original text.

Return structure with offsets in the first (original) and in the second (result) strings.

For performance reasons, Diff() does not operate with offsets of the substrings and it does not store them. Original strings can be easily reconstructed from the list of diffs, and offsets also can be calculated afterwards. See CDiffList::CalculateOffsets().

Returns
See also
GetOperation(), GetString(), GetLine(), CDiff::Diff(), CDiffList::CalculateOffsets()

Definition at line 510 of file diff.hpp.

References CDiffOperation::m_Offset.

◆ GetOperation() EType CDiffOperation::GetOperation ( void  ) const inline ◆ GetString() ◆ IsDelete() bool CDiffOperation::IsDelete ( void  ) const inline ◆ IsEqual() bool CDiffOperation::IsEqual ( void  ) const inline ◆ IsInsert() bool CDiffOperation::IsInsert ( void  ) const inline ◆ IsTimeoutExpired() bool CDiffBase::IsTimeoutExpired ( ) const inline ◆ NCBI_EXCEPTION_DEFAULT() ◆ operator!=() ◆ operator==() ◆ Prepend() [1/2] ◆ Prepend() [2/2] ◆ PrintUnifiedDiff()

Find the differences between two texts and print result into output stream in unified-like format.

Parameters
out The output stream. text1 Old text to be diffed. text2 New text to be diffed. num_common_lines The number of unchanged lines shown above and below a change hunk. Three lines is typically the default. Use zero, if you need to see a changes only, without any surrounding text.
See also
Diff()
Note
Using CTempStrings internally is faster and use less memory, but do not allow to perform some optimizations and cleanup, so result can looks different that 'diff' utility provide, and have more hunks. Also, the printed result have next differences from canonical unified format: 1) Unified format allow crossed hunks, when end of the first and start of the second hunk have the same unchanged lines of text. This version don't have crossed hunks. If some hunks crosses, the second will be started with less number of unchanged lines that specified by 'num_common_lines' parameter. 2) Unified format can have zero-based line numbers. like: @ -0,0 +1,1 @ +Added line. This version always use one-based line numbers: @ -1,0 +1,1 @ +Added line.
It is not fully compatible with result provided by 'diff -u' (or -U NNN), and sometimes it is impossible to use 'patch' utility with provided diff.

Definition at line 1048 of file diff.cpp.

References CDiffText::Diff(), DIFF_DELETE, DIFF_EQUAL, DIFF_INSERT, CDiffText::fRemoveEOL, CDiffList::GetList(), out(), and s_PrintUnifiedHunk().

◆ Reset() void CDiffBase::Reset ( void  ) inlineprotected ◆ SetLength() void CDiffOperation::SetLength ( size_type  length ) inlineprotected ◆ SetLine() void CDiffOperation::SetLine ( SPos  line ) inlineprotected ◆ SetOffset() void CDiffOperation::SetOffset ( SPos  offset ) inlineprotected ◆ SetOperation() void CDiffOperation::SetOperation ( EType  operation ) inlineprotected ◆ SetString() ◆ SetTimeout()

Set timeout.

Despite the large number of optimizations used in Diff(), it can take a while to compute. You can limit its execution time using this method. The default value for timeout if not specified is infinity, that lets diff run until completion. Should diff timeout, the return value will still be a valid difference, though probably non-optimal.

Definition at line 301 of file diff.hpp.

References CDiffBase::m_Timeout.

◆ SPos() ◆ x_CleanupAndMerge_Equities() void CDiffList::x_CleanupAndMerge_Equities ( void  ) private ◆ x_CleanupAndMerge_SingleEdits() bool CDiffList::x_CleanupAndMerge_SingleEdits ( void  ) private ◆ x_Diff()

Find the differences between two texts.

Assumes that the texts do not have any common prefix or suffix.

Parameters
s1 Old string to be diffed. s2 New string to be diffed. diffs Resulting list of the diff operations.
See also
Diff

Definition at line 705 of file diff.cpp.

References CDiffList::Append(), DIFF_DELETE, DIFF_EQUAL, DIFF_INSERT, CTempString::empty(), CTempString::find(), i, CTempString::length(), CDiffList::m_List, NPOS, CTempString::substr(), CDiff::x_DiffBisect(), and CDiff::x_DiffHalfMatch().

Referenced by CDiff::Diff(), and CDiff::x_DiffBisectSplit().

◆ x_DiffBisect()

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
s1 Old string to be diffed. s2 New string to be diffed. diffs Resulting list of the diff operations.
See also
Diff

Definition at line 551 of file diff.cpp.

References CDiffList::Append(), delta(), DIFF_DELETE, DIFF_INSERT, ctll::front(), int, CDiffBase::IsTimeoutExpired(), CTempString::length(), v2, and CDiff::x_DiffBisectSplit().

Referenced by CDiff::x_Diff().

◆ x_DiffBisectSplit() ◆ x_DiffHalfMatch() ◆ x_DiffHalfMatchI()

Does a substring of short string exist within long string such that the substring is at least half the length of long string?

Parameters
long_str Longer string. short_str Shorter string. i Start index of quarter length substring within long string. hm Five element Array, containing the prefix of 'long_str', the suffix of 'long_str', the prefix of 'short_str', the suffix of 'short_str' and the common middle.
Returns
FALSE if there was no match.
See also
Diff, x_DiffHalfMatch

Definition at line 505 of file diff.cpp.

References NStr::CommonPrefixSize(), NStr::CommonSuffixSize(), CTempString::find(), i, CTempString::length(), NPOS, seed, and CTempString::substr().

Referenced by CDiff::x_DiffHalfMatch().

◆ first

Position in first (original) string.

Definition at line 80 of file diff.hpp.

◆ m_Deadline ◆ m_Diffs ◆ m_Length ◆ m_Line SPos CDiffOperation::m_Line private ◆ m_List ◆ m_Offset SPos CDiffOperation::m_Offset private ◆ m_Operation EType CDiffOperation::m_Operation private ◆ m_String ◆ m_Timeout ◆ second

Position in second (result) string.

Definition at line 81 of file diff.hpp.

◆ CDiff [1/3] ◆ CDiff [2/3] ◆ CDiff [3/3] ◆ CDiffList ◆ CDiffText [1/3] ◆ CDiffText [2/3] ◆ CDiffText [3/3]

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4