OSDN Git Service

Fix issue #940: Replace slow (2)
[winmerge-jp/winmerge-jp.git] / Src / stringdiffs.h
1 /** 
2  * @file  stringdiffs.h
3  *
4  * @brief Interface file declaring ComputeWordDiffs (q.v.)
5  *
6  */
7 #pragma once
8
9 #include "UnicodeString.h"
10 #include <vector>
11
12 namespace strdiff
13 {
14
15 /** @brief One difference between two strings */
16 struct wdiff {
17         std::array<int, 3> begin; // 0-based, eg, begin[0] is from str1
18         std::array<int, 3> end; // 0-based, eg, end[1] is from str2
19         int op;
20         wdiff(int s1=0, int e1=0, int s2=0, int e2=0, int s3=0, int e3=0)
21                 : begin{s1, s2, s3}
22                 , op(-1)
23         {
24                 if (s1>e1) e1=s1-1;
25                 if (s2>e2) e2=s2-1;
26                 if (s3>e3) e3=s3-1;
27                 end[0] = e1;
28                 end[1] = e2;
29                 end[2] = e3;
30         }
31         wdiff(const wdiff & src)
32                 : begin{src.begin}
33                 , end{src.end}
34                 , op(src.op)
35         {
36         }
37 };
38
39 void Init();
40 void Close();
41
42 void SetBreakChars(const TCHAR *breakChars);
43
44 std::vector<wdiff> ComputeWordDiffs(const String& str1, const String& str2,
45         bool case_sensitive, bool eol_sensitive, int whitespace, int breakType, bool byte_level);
46 std::vector<wdiff> ComputeWordDiffs(int nStrings, const String *str, 
47                    bool case_sensitive, bool eol_sensitive, int whitespace, int breakType, bool byte_level);
48
49 }