OSDN Git Service

Fix build errors
[winmerge-jp/winmerge-jp.git] / Src / CompareOptions.h
1 /** 
2  * @file  CompareOptions.h
3  *
4  * @brief Compare options classes and types.
5  */
6 #pragma once
7
8 #include "diff.h"
9
10 /**
11  * @brief Whether to ignore whitespace (or to ignore changes in whitespace)
12  *
13  * Examples:
14  * "abc def" is only equivalent to "abcdef" under WHITESPACE_IGNORE_ALL
15  *
16  * but "abc def" is equivalent to "abc    def" under both 
17  *   WHITESPACE_IGNORE_CHANGE and WHITESPACE_IGNORE_ALL
18  *
19  * Also, trailing and leading whitespace is ignored for both
20  *   WHITESPACE_IGNORE_CHANGE and WHITESPACE_IGNORE_ALL
21  */
22 enum WhitespaceIgnoreChoices
23 {
24         WHITESPACE_COMPARE_ALL = 0,    /**< no special handling of whitespace */
25         WHITESPACE_IGNORE_CHANGE,      /**< ignore changes in whitespace */
26         WHITESPACE_IGNORE_ALL,         /**< ignore whitespace altogether */
27 };
28
29 enum DiffAlgorithm
30 {
31         DIFF_ALGORITHM_DEFAULT = 0,
32         DIFF_ALGORITHM_MINIMAL = 1,
33         DIFF_ALGORITHM_PATIENCE = 2,
34         DIFF_ALGORITHM_HISTOGRAM = 3,
35 };
36
37 /**
38  * @brief Patch styles.
39  *
40  * Diffutils can output patch in these formats. Normal format has original
41  * and altered lines listed in separate blocks, prefixed with \< and \>
42  * characters. Context format has context lines around difference blocks,
43  * which are prefixed with - and + characters. Unified format combines
44  * difference blocks and prefixes lines with + and - characters.
45  * @note We really use only first three types (normal + context formats).
46  * Those three types are the ones mostly used and preferred.
47  */
48 enum DiffOutputType
49 {
50         // NOTE: these values are stored in the user's Registry - don't change their value !!
51         /**< Default output style.  */
52         DIFF_OUTPUT_NORMAL = OUTPUT_NORMAL,
53         /**< Output the differences with lines of context before and after (-c).  */
54         DIFF_OUTPUT_CONTEXT = OUTPUT_CONTEXT,
55         /**< Output the differences in a unified context diff format (-u). */
56         DIFF_OUTPUT_UNIFIED = OUTPUT_UNIFIED,
57 // These are not used, see the comment above enum.
58 #if 0
59         /**< Output the differences as commands suitable for `ed' (-e).  */
60         DIFF_OUTPUT_ED = OUTPUT_ED,
61         /**< Output the diff as a forward ed script (-f).  */
62         DIFF_OUTPUT_FORWARD_ED = OUTPUT_FORWARD_ED,
63         /**< Like -f, but output a count of changed lines in each "command" (-n). */
64         DIFF_OUTPUT_RCS = OUTPUT_RCS,
65         /**< Output merged #ifdef'd file (-D).  */
66         DIFF_OUTPUT_IFDEF = OUTPUT_IFDEF,
67         /**< Output sdiff style (-y).  */
68         DIFF_OUTPUT_SDIFF = OUTPUT_SDIFF,
69 #endif
70 //  ... end of unused
71         /** Output html style.  */
72         DIFF_OUTPUT_HTML = OUTPUT_HTML,
73 };
74
75 /**
76  * @brief Diffutils options.
77  */
78 struct DIFFOPTIONS
79 {
80         int nIgnoreWhitespace; /**< Ignore whitespace -option. */
81         bool bIgnoreCase; /**< Ignore case -option. */
82         bool bIgnoreBlankLines; /**< Ignore blank lines -option. */
83         bool bIgnoreEol; /**< Ignore EOL differences -option. */
84         bool bFilterCommentsLines; /**< Ignore Multiline comments differences -option. */
85         int nDiffAlgorithm; /**< Diff algorithm -option. */
86         bool bIndentHeuristic; /**< Ident heuristic -option */
87         bool bCompletelyBlankOutIgnoredChanges;
88 };
89
90 /**
91  * @brief General compare options.
92  * This class has general compare options we expect every compare engine and
93  * routine to implement.
94  */
95 class CompareOptions
96 {
97 public:
98         CompareOptions();
99         CompareOptions(const CompareOptions & options);
100         virtual void SetFromDiffOptions(const DIFFOPTIONS & options);
101
102         enum WhitespaceIgnoreChoices m_ignoreWhitespace; /**< Ignore whitespace characters */
103         bool m_bIgnoreBlankLines; /**< Ignore blank lines (both sides) */
104         bool m_bIgnoreCase; /**< Ignore case differences? */
105         bool m_bIgnoreEOLDifference; /**< Ignore EOL style differences? */
106 };
107
108 /**
109  * @brief Compare options used with diffutils.
110  * This class adds some diffutils-specific compare options to general compare
111  * options class. And also methods for easy setting options and forwarding
112  * options to diffutils.
113  */
114 class DiffutilsOptions : public CompareOptions
115 {
116 public:
117         DiffutilsOptions();
118         explicit DiffutilsOptions(const CompareOptions& options);
119         DiffutilsOptions(const DiffutilsOptions& options);
120         void SetToDiffUtils();
121         void GetAsDiffOptions(DIFFOPTIONS &options) const;
122         virtual void SetFromDiffOptions(const DIFFOPTIONS & options) override;
123
124         enum DiffOutputType m_outputStyle; /**< Output style (for patch files) */
125         int m_contextLines; /**< Number of context lines (for patch files) */
126         bool m_filterCommentsLines;/**< Ignore Multiline comments differences.*/
127         enum DiffAlgorithm m_diffAlgorithm; /** Diff algorithm */
128         bool m_bIndentHeuristic; /**< Indent heuristic */
129         bool m_bCompletelyBlankOutIgnoredDiffereneces; /**< Completely blank out ignored differences */
130 };
131
132 /**
133  * @brief Compare options used with Quick compare -method.
134  * This class has some Quick Compare specifics in addition to general compare
135  * options.
136  */
137 class QuickCompareOptions : public CompareOptions
138 {
139 public:
140         QuickCompareOptions();
141         explicit QuickCompareOptions(const CompareOptions& options);
142
143         bool m_bStopAfterFirstDiff; /**< Optimize compare by stopping after first difference? */
144 };