SGL
privatediff.h
1 /*
2  * File: privatediff.h
3  * -------------------
4  * This file contains declarations of functions that perform a text 'diff'
5  * operation to compare two strings and output the differences.
6  * @version 2021/04/09
7  * - moved to private SGL namespace
8  *
9  * @author Marty Stepp
10  * @version 2021/04/09
11  * - moved to private SGL namespace
12  * @version 2016/10/30
13  * - fixed diff flags; added punctuation flag
14  * @version 2016/10/28
15  * - added DEFAULT_STRICT_FLAGS
16  * @version 2016/10/22
17  * - added diffPass (for autograder assertDiff)
18  * @version 2014/10/14
19  * - initial version
20  * @since 2014/10/14
21  */
22 
23 
24 #ifndef _private_diff_h
25 #define _private_diff_h
26 
27 #include <string>
28 
29 namespace sgl {
30 namespace priv {
31 namespace diff {
32 
33 const string NO_DIFFS_MESSAGE = "No differences found";
34 
35 enum DiffFlags {
36  IGNORE_NONE = 0x0,
37  IGNORE_LEADING = 0x1,
38  IGNORE_TRAILING = 0x2,
39  IGNORE_WHITESPACE = 0x4,
40  IGNORE_BLANKLINES = 0x8,
41  IGNORE_CASE = 0x10,
42  IGNORE_NUMBERS = 0x20,
43  IGNORE_NONNUMBERS = 0x40,
44  IGNORE_PUNCTUATION = 0x80,
45  IGNORE_AFTERDECIMAL = 0x100,
46  IGNORE_CHARORDER = 0x200,
47  IGNORE_LINEORDER = 0x400,
48  IGNORE_EVERYTHING = 0x100000
49 };
50 
51 const int DIFF_STRICT_FLAGS = IGNORE_TRAILING;
52 const int DIFF_DEFAULT_FLAGS = IGNORE_CASE | IGNORE_TRAILING | IGNORE_WHITESPACE | IGNORE_PUNCTUATION;
53 
54 string diff(string s1, string s2, int flags = DIFF_DEFAULT_FLAGS);
55 bool diffPass(const string& s1, const string& s2, int flags = DIFF_DEFAULT_FLAGS);
56 bool isDiffMatch(const string& diffs);
57 
58 } // namespace sgl
59 } // namespace priv
60 } // namespace diff
61 
62 #endif // _private_diff_h
Definition: console.h:45