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.
31 * @brief kind of synchronaction
44 * @brief Class to hold together data needed to implement strdiff::ComputeWordDiffs
49 stringdiffs(const String & str1, const String & str2,
50 bool case_sensitive, bool eol_sensitive, int whitespace, bool ignore_numbers, int breakType,
51 std::vector<wdiff> * pDiffs);
55 void BuildWordDiffList();
56 void wordLevelToByteLevel();
59 // Implementation types
62 int start; // index of first character of word in original string
63 int end; // index of last character of word in original string
65 int bBreak; // Is it a isWordBreak 0 = word -1= whitespace -2 = empty 1 = breakWord
66 word(int s = 0, int e = 0, int b = 0, int h = 0) : start(s), end(e), bBreak(b),hash(h) { }
67 int length() const { return end+1-start; }
70 // Implementation methods
73 void ComputeByteDiff(const String& str1, const String& str2,
74 bool casitive, int xwhite,
75 int begin[2], int end[2], bool equal);
76 std::vector<word> BuildWordsArray(const String & str);
77 unsigned Hash(const String & str, int begin, int end, unsigned h ) const;
78 bool AreWordsSame(const word & word1, const word & word2) const;
79 bool IsWord(const word & word1) const;
81 * @brief Is this block an space or whitespace one?
83 inline bool IsSpace(const word & word1) const
85 return (word1.bBreak == dlspace);
88 * @brief Is this block a number one?
90 inline bool IsNumber(const word& word1) const
92 return (word1.bBreak == dlnumber);
95 * @brief Is this block a break?
97 inline bool IsBreak(const word & word1) const
99 return (word1.bBreak == dlbreak || word1.bBreak == dlspace);
102 * @brief Is this block an empty (insert) one?
104 inline bool IsInsert(const word & word1) const
106 return (word1.bBreak == dlinsert);
108 bool caseMatch(TCHAR ch1, TCHAR ch2) const;
109 bool BuildWordDiffList_DP();
110 int dp(std::vector<char> & edscript);
111 int onp(std::vector<char> & edscript);
112 int snake(int k, int y, bool exchanged);
113 #ifdef STRINGDIFF_LOGGING
117 // Implementation data
119 const String & m_str1;
120 const String & m_str2;
121 bool m_case_sensitive;
122 bool m_eol_sensitive;
124 bool m_ignore_numbers = false;
127 std::vector<wdiff> * m_pDiffs;
128 std::vector<word> m_words1;
129 std::vector<word> m_words2;
130 std::vector<wdiff> m_wdiffs;