4 * @brief Declaration file for class stringdiffs
10 #include "utils/icu.hpp"
12 // Uncomment this to see stringdiff log messages
13 // We don't use _DEBUG since stringdiff logging is verbose and slows down WinMerge
14 //#define STRINGDIFF_LOGGING
20 * @brief kind of diff blocks.
30 * @brief kind of synchronaction
43 * @brief Class to hold together data needed to implement strdiff::ComputeWordDiffs
48 stringdiffs(const String & str1, const String & str2,
49 bool case_sensitive, bool eol_sensitive, int whitespace, int breakType,
50 std::vector<wdiff> * pDiffs);
54 void BuildWordDiffList();
55 void wordLevelToByteLevel();
58 // Implementation types
61 int start; // index of first character of word in original string
62 int end; // index of last character of word in original string
64 int bBreak; // Is it a isWordBreak 0 = word -1= whitespace -2 = empty 1 = breakWord
65 word(int s = 0, int e = 0, int b = 0, int h = 0) : start(s), end(e), bBreak(b),hash(h) { }
66 int length() const { return end+1-start; }
69 // Implementation methods
72 void ComputeByteDiff(const String& str1, const String& str2,
73 bool casitive, int xwhite,
74 int begin[2], int end[2], bool equal);
75 std::vector<word> BuildWordsArray(const String & str);
76 unsigned Hash(const String & str, int begin, int end, unsigned h ) const;
77 bool AreWordsSame(const word & word1, const word & word2) const;
78 bool IsWord(const word & word1) const;
80 * @brief Is this block an space or whitespace one?
82 inline bool IsSpace(const word & word1) const
84 return (word1.bBreak == dlspace);
87 * @brief Is this block a break?
89 inline bool IsBreak(const word & word1) const
91 return (word1.bBreak == dlbreak || word1.bBreak == dlspace);
94 * @brief Is this block an empty (insert) one?
96 inline bool IsInsert(const word & word1) const
98 return (word1.bBreak == dlinsert);
100 bool caseMatch(TCHAR ch1, TCHAR ch2) const;
101 bool BuildWordDiffList_DP();
102 int dp(std::vector<char> & edscript);
103 int onp(std::vector<char> & edscript);
104 int snake(int k, int y, bool exchanged);
105 #ifdef STRINGDIFF_LOGGING
109 // Implementation data
111 const String & m_str1;
112 const String & m_str2;
113 bool m_case_sensitive;
114 bool m_eol_sensitive;
118 std::vector<wdiff> * m_pDiffs;
119 std::vector<word> m_words1;
120 std::vector<word> m_words2;
121 std::vector<wdiff> m_wdiffs;