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 inline 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) const;
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 an EOL?
97 inline bool IsEOL(const word & word1) const
99 return (word1.bBreak == dleol);
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, int M, int N, bool exchanged) const;
105 #ifdef STRINGDIFF_LOGGING
109 // Implementation data
111 const String & m_str1;
112 const String & m_str2;
115 bool m_case_sensitive;
116 bool m_eol_sensitive;
117 bool m_ignore_numbers = false;
119 std::vector<wdiff> * m_pDiffs;
120 std::vector<word> m_words1;
121 std::vector<word> m_words2;
122 std::vector<wdiff> m_wdiffs;