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.
◆ TListStorage class type for the list of diff operations.
Definition at line 190 of file diff.hpp.
◆ EErrCode Enumerator eEmpty eBadFlagsDefinition at line 475 of file diff.hpp.
◆ EFlags [1/2]Processing flags.
Enumerator fNoCleanupBy 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.
fCalculateOffsetsAutomatically call CalculateOffests() for the generated list of differences.
Definition at line 336 of file diff.hpp.
◆ EFlags [2/2]Processing flags.
Enumerator fCleanupAutomatically 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.
fCalculateOffsetsAutomatically call CalculateOffests() for the generated list of differences.
fIgnoreEOLIgnore differences in end-of-line types on string comparison.
fRemoveEOLRemove 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.
◆ ETypeType of the current diff operation.
Enumerator eDeleteString that exists in old text, and deleted in new one.
eEqualString exists in both texts.
eInsertString 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.
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.
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).
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.
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.
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 inlineGet 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.
Definition at line 516 of file diff.hpp.
References CDiffOperation::m_Line.
◆ GetList() ◆ GetLongestCommonSubstring() CTempString CDiffList::GetLongestCommonSubstring ( void ) constFind the longest common substring for current difference list.
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().
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.
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.
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.
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?
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().
◆ firstPosition 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 ◆ secondPosition 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