OSDN Git Service

compiler-calculated maximum value for `m_SourceDefs` (#966)
[winmerge-jp/winmerge-jp.git] / Src / ProjectFile.h
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /** 
3  * @file  ProjectFile.h
4  *
5  * @brief Declaration file ProjectFile class
6  */
7 #pragma once
8
9 #include "UnicodeString.h"
10 #include "PathContext.h"
11
12 class ProjectFileItem
13 {
14         friend class ProjectFile;
15         friend class ProjectFileHandler;
16 public:
17         ProjectFileItem();
18         bool HasLeft() const;
19         bool HasMiddle() const;
20         bool HasRight() const;
21         bool HasFilter() const;
22         bool HasSubfolders() const;
23         bool HasUnpacker() const;
24         bool HasPrediffer() const;
25         bool HasIgnoreWhite() const;
26         bool HasIgnoreBlankLines() const;
27         bool HasIgnoreCase() const;
28         bool HasIgnoreEol() const;
29         bool HasIgnoreCodepage() const;
30         bool HasFilterCommentsLines() const;
31         bool HasCompareMethod() const;
32
33         String GetLeft(bool * pReadOnly = nullptr) const;
34         bool GetLeftReadOnly() const;
35         String GetMiddle(bool * pReadOnly = nullptr) const;
36         bool GetMiddleReadOnly() const;
37         String GetRight(bool * pReadOnly = nullptr) const;
38         bool GetRightReadOnly() const;
39         String GetFilter() const;
40         int GetSubfolders() const;
41         String GetUnpacker() const;
42         String GetPrediffer() const;
43         int GetIgnoreWhite() const;
44         bool GetIgnoreBlankLines() const;
45         bool GetIgnoreCase() const;
46         bool GetIgnoreEol() const;
47         bool GetIgnoreCodepage() const;
48         bool GetFilterCommentsLines() const;
49         int GetCompareMethod() const;
50
51         void SetLeft(const String& sLeft, const bool * pReadOnly = nullptr);
52         void SetMiddle(const String& sMiddle, const bool * pReadOnly = nullptr);
53         void SetRight(const String& sRight, const bool * pReadOnly = nullptr);
54         void SetFilter(const String& sFilter);
55         void SetSubfolders(bool bSubfolder);
56         void SetUnpacker(const String& sUnpacker);
57         void SetPrediffer(const String& sPrediffer);
58         void SetIgnoreWhite(int nIgnoreWhite);
59         void SetIgnoreBlankLines(bool bIgnoreBlankLines);
60         void SetIgnoreCase(bool bIgnoreCase);
61         void SetIgnoreEol(bool bIgnoreEol);
62         void SetIgnoreCodepage(bool bIgnoreCodepage);
63         void SetFilterCommentsLines(bool bFilterCommentsLines);
64         void SetCompareMethod(int nCompareMethod);
65
66         void GetPaths(PathContext& files, bool & bSubFolders) const;
67         void SetPaths(const PathContext& files, bool bSubFolders = false);
68
69         void SetSaveFilter(bool bSaveFilter);
70         void SetSaveSubfolders(bool bSaveSubfolders);
71         void SetSaveUnpacker(bool bSaveUnpacker);
72         void SetSaveIgnoreWhite(bool bSaveIgnoreWhite);
73         void SetSaveIgnoreBlankLines(bool bSaveIgnoreBlankLines);
74         void SetSaveIgnoreCase(bool bSaveIgnoreCase);
75         void SetSaveIgnoreEol(bool bSaveIgnoreEol);
76         void SetSaveIgnoreCodepage(bool bSaveIgnoreCodepage);
77         void SetSaveFilterCommentsLines(bool bSaveFilterCommentsLines);
78         void SetSaveCompareMethod(bool bSaveCompareMethod);
79
80 private:
81         PathContext m_paths;
82         bool m_bHasLeft; /**< Has left path? */
83         bool m_bHasMiddle; /**< Has middle path? */
84         bool m_bHasRight; /**< Has right path? */
85         bool m_bHasFilter; /**< Has filter? */
86         String m_filter; /**< Filter name or mask */
87         bool m_bHasSubfolders; /**< Has subfolders? */
88         int m_subfolders; /**< Are subfolders included (recursive scan) */
89         bool m_bLeftReadOnly; /**< Is left path opened as read-only */
90         bool m_bMiddleReadOnly; /**< Is middle path opened as read-only */
91         bool m_bRightReadOnly; /**< Is right path opened as read-only */
92         bool m_bHasUnpacker; /**< Has unpacker? */
93         String m_unpacker; /**< Unpacker name or pipeline */
94         bool m_bHasPrediffer; /**< Has prediffer? */
95         String m_prediffer; /**< Prediffer name or pipeline */
96         bool m_bHasIgnoreWhite; /**< Has "Whitespaces" setting? */
97         int m_nIgnoreWhite; /**< The value of the "Whitespaces" setting */
98         bool m_bHasIgnoreBlankLines; /**< Has "Ignore blank lines" setting? */
99         bool m_bIgnoreBlankLines; /**< The value of the "Ignore blank lines" setting */
100         bool m_bHasIgnoreCase; /**< Has "Ignore case" setting? */
101         bool m_bIgnoreCase; /**< The value of the "Ignore case" setting */
102         bool m_bHasIgnoreEol; /**< Has "Ignore carriage return differences" setting? */
103         bool m_bIgnoreEol; /**< The value of the "Ignore carriage return differences" setting */
104         bool m_bHasIgnoreCodepage; /**< Has "Ignore codepage differences" setting? */
105         bool m_bIgnoreCodepage; /**< The value of the "Ignore codepage differences" setting */
106         bool m_bHasFilterCommentsLines; /**< Has "Ignore comment differences" setting? */
107         bool m_bFilterCommentsLines; /**< The value of the "Ignore comment differences" setting */
108         bool m_bHasCompareMethod; /**< Has "Compare method" setting? */
109         int m_nCompareMethod; /**< The value of the "Compare method" setting */
110         bool m_bSaveFilter; /**< Save filter? */
111         bool m_bSaveSubfolders; /**< Save subfolders? */
112         bool m_bSaveUnpacker; /**< Save unpacker? */
113         bool m_bSaveIgnoreWhite; /**< Save "Whitespaces" setting? */
114         bool m_bSaveIgnoreBlankLines; /**< Save "Ignore blank lines" setting? */
115         bool m_bSaveIgnoreCase; /**< Save "Ignore case" setting? */
116         bool m_bSaveIgnoreEol; /**< Save "Ignore carriage return differences" setting? */
117         bool m_bSaveIgnoreCodepage; /**< Save "Ignore codepage differences" setting? */
118         bool m_bSaveFilterCommentsLines; /**< Save "Ignore comment differences" setting? */
119         bool m_bSaveCompareMethod; /**< Save "Compare method" setting? */
120 };
121
122 /**
123  * @brief Class for handling project files.
124  *
125  * This class loads and saves project files. Expat parser and SCEW wrapper for
126  * expat are used for XML parsing. We use UTF-8 encoding so Unicode paths are
127  * supported.
128  */
129 class ProjectFile
130 {
131 public:
132         bool Read(const String& path);
133         bool Save(const String& path) const;
134         const std::list<ProjectFileItem>& Items() const { return m_items; };
135         std::list<ProjectFileItem>& Items() { return m_items; }
136         static const String PROJECTFILE_EXT;
137 private:
138         std::list<ProjectFileItem> m_items;
139 };
140
141 /** 
142  * @brief Returns if left path is defined in project file.
143  * @return true if project file has left path.
144  */
145 inline bool ProjectFileItem::HasLeft() const
146 {
147         return m_bHasLeft;
148 }
149
150 /** 
151  * @brief Returns if middle path is defined.
152  */
153 inline bool ProjectFileItem::HasMiddle() const
154 {
155         return m_bHasMiddle;
156 }
157
158 /** 
159  * @brief Returns if right path is defined in project file.
160  * @return true if project file has right path.
161  */
162 inline bool ProjectFileItem::HasRight() const
163 {
164         return m_bHasRight;
165 }
166
167 /** 
168  * @brief Returns if filter is defined in project file.
169  * @return true if project file has filter.
170  */
171 inline bool ProjectFileItem::HasFilter() const
172 {
173         return m_bHasFilter;
174 }
175
176 /** 
177  * @brief Returns if subfolder is defined in projectfile.
178  * @return true if project file has subfolder definition.
179  */
180 inline bool ProjectFileItem::HasSubfolders() const
181 {
182         return m_bHasSubfolders;
183 }
184
185 /** 
186  * @brief Returns if unpacker is defined in projectfile.
187  * @return true if project file has unpacker definition.
188  */
189 inline bool ProjectFileItem::HasUnpacker() const
190 {
191         return m_bHasUnpacker;
192 }
193
194 /** 
195  * @brief Returns if prediffer is defined in projectfile.
196  * @return true if project file has prediffer definition.
197  */
198 inline bool ProjectFileItem::HasPrediffer() const
199 {
200         return m_bHasPrediffer;
201 }
202
203 /** 
204  * @brief Returns if "Whitespaces" setting is defined in projectfile.
205  * @return true if project file has "Whitespaces" setting definition.
206  */
207 inline bool ProjectFileItem::HasIgnoreWhite() const
208 {
209         return m_bHasIgnoreWhite;
210 }
211
212 /** 
213  * @brief Returns if "Ignore blank lines" setting is defined in projectfile.
214  * @return true if project file has "Ignore blank lines" setting definition.
215  */
216 inline bool ProjectFileItem::HasIgnoreBlankLines() const
217 {
218         return m_bHasIgnoreBlankLines;
219 }
220
221 /** 
222  * @brief Returns if "Ignore case" setting is defined in projectfile.
223  * @return true if project file has "Ignore case" setting definition.
224  */
225 inline bool ProjectFileItem::HasIgnoreCase() const
226 {
227         return m_bHasIgnoreCase;
228 }
229
230 /** 
231  * @brief Returns if "Ignore carriage return differences" setting is defined in projectfile.
232  * @return true if project file has "Ignore carriage return differences" setting definition.
233  */
234 inline bool ProjectFileItem::HasIgnoreEol() const
235 {
236         return m_bHasIgnoreEol;
237 }
238
239 /** 
240  * @brief Returns if "Ignore codepage differences" setting is defined in projectfile.
241  * @return true if project file has "Ignore codepage differences" setting definition.
242  */
243 inline bool ProjectFileItem::HasIgnoreCodepage() const
244 {
245         return m_bHasIgnoreCodepage;
246 }
247
248 /** 
249  * @brief Returns if "Ignore comment differences" is defined in projectfile.
250  * @return true if project file has "Ignore comment differences" definition.
251  */
252 inline bool ProjectFileItem::HasFilterCommentsLines() const
253 {
254         return m_bHasFilterCommentsLines;
255 }
256
257 /** 
258  * @brief Returns if "Compare method" setting is defined in projectfile.
259  * @return true if project file has "Compare method" setting definition.
260  */
261 inline bool ProjectFileItem::HasCompareMethod() const
262 {
263         return m_bHasCompareMethod;
264 }
265
266 /** 
267  * @brief Returns if left path is specified read-only.
268  * @return true if left path is read-only, false otherwise.
269  */
270 inline bool ProjectFileItem::GetLeftReadOnly() const
271 {
272         return m_bLeftReadOnly;
273 }
274
275 /** 
276  * @brief Returns if middle path is specified read-only.
277  */
278 inline bool ProjectFileItem::GetMiddleReadOnly() const
279 {
280         return m_bMiddleReadOnly;
281 }
282
283 /** 
284  * @brief Returns if right path is specified read-only.
285  * @return true if right path is read-only, false otherwise.
286  */
287 inline bool ProjectFileItem::GetRightReadOnly() const
288 {
289         return m_bRightReadOnly;
290 }
291
292 /** 
293  * @brief Returns filter.
294  * @return Filter string.
295  */
296 inline String ProjectFileItem::GetFilter() const
297 {
298         return m_filter;
299 }
300
301 /** 
302  * @brief Set filter.
303  * @param [in] sFilter New filter string to set.
304  */
305 inline void ProjectFileItem::SetFilter(const String& sFilter)
306 {
307         m_filter = sFilter;
308 }
309
310 /** 
311  * @brief Returns subfolder included -setting.
312  * @return != 0 if subfolders are included.
313  */
314 inline int ProjectFileItem::GetSubfolders() const
315 {
316         return m_subfolders;
317 }
318
319 /** 
320  * @brief set subfolder.
321  * @param [in] iSubfolder New value for subfolder inclusion.
322  */
323 inline void ProjectFileItem::SetSubfolders(bool bSubfolder)
324 {
325         m_subfolders = bSubfolder ? 1 : 0;
326 }
327
328 /** 
329  * @brief Returns unpacker name or pipeline
330  * @return Unpacker name or pipeline
331  */
332 inline String ProjectFileItem::GetUnpacker() const
333 {
334         return m_unpacker;
335 }
336
337 /** 
338  * @brief Set unpacker name or pipeline.
339  * @param [in] sUnpacker New unpacker name or pipeline to set.
340  */
341 inline void ProjectFileItem::SetUnpacker(const String& sUnpacker)
342 {
343         m_unpacker = sUnpacker;
344 }
345
346 /** 
347  * @brief Returns prediffer name or pipeline
348  * @return Prediffer name or pipeline
349  */
350 inline String ProjectFileItem::GetPrediffer() const
351 {
352         return m_prediffer;
353 }
354
355 /** 
356  * @brief Set prediffer name or pipeline.
357  * @param [in] sPrediffer New prediffer name or pipeline to set.
358  */
359 inline void ProjectFileItem::SetPrediffer(const String& sPrediffer)
360 {
361         m_prediffer = sPrediffer;
362 }
363
364 /** 
365  * @brief Returns the value of the "Whitespaces" setting.
366  * @return The value of the "Whitespaces" setting
367  */
368 inline int ProjectFileItem::GetIgnoreWhite() const
369 {
370         return m_nIgnoreWhite;
371 }
372
373 /** 
374  * @brief Set the value of the "Whitespaces" setting.
375  * @param [in] nIgnoreWhite New value of the "Whitespaces" setting to set.
376  */
377 inline void ProjectFileItem::SetIgnoreWhite(int nIgnoreWhite)
378 {
379         m_nIgnoreWhite = nIgnoreWhite;
380 }
381
382 /** 
383  * @brief Returns the value of the "Ignore blank lines" setting.
384  * @return The value of the "Ignore blank lines" setting
385  */
386 inline bool ProjectFileItem::GetIgnoreBlankLines() const
387 {
388         return m_bIgnoreBlankLines;
389 }
390
391 /** 
392  * @brief Set the value of the "Ignore blank lines" setting.
393  * @param [in] bIgnoreBlankLines New value of the "Ignore blank lines" setting to set.
394  */
395 inline void ProjectFileItem::SetIgnoreBlankLines(bool bIgnoreBlankLines)
396 {
397         m_bIgnoreBlankLines = bIgnoreBlankLines;
398 }
399
400 /** 
401  * @brief Returns the value of the "Ignore case" setting.
402  * @return Unpacker name or pipelineThe value of the "Ignore case" setting
403  */
404 inline bool ProjectFileItem::GetIgnoreCase() const
405 {
406         return m_bIgnoreCase;
407 }
408
409 /** 
410  * @brief Set the value of the "Ignore case" setting.
411  * @param [in] bIgnoreCase New value of the "Ignore case" setting to set.
412  */
413 inline void ProjectFileItem::SetIgnoreCase(bool bIgnoreCase)
414 {
415         m_bIgnoreCase = bIgnoreCase;
416 }
417
418 /** 
419  * @brief Returns the value of the "Ignore carriage return differences" setting.
420  * @return The value of the "Ignore carriage return differences" setting
421  */
422 inline bool ProjectFileItem::GetIgnoreEol() const
423 {
424         return m_bIgnoreEol;
425 }
426
427 /** 
428  * @brief Set the value of the "Ignore carriage return differences" setting.
429  * @param [in] bIgnoreEol New value of the "Ignore carriage return differences" setting to set.
430  */
431 inline void ProjectFileItem::SetIgnoreEol(bool bIgnoreEol)
432 {
433         m_bIgnoreEol = bIgnoreEol;
434 }
435
436 /** 
437  * @brief Returns the value of the "Ignore codepage differences" setting.
438  * @return The value of the "Ignore codepage differences" setting
439  */
440 inline bool ProjectFileItem::GetIgnoreCodepage() const
441 {
442         return m_bIgnoreCodepage;
443 }
444
445 /** 
446  * @brief Set the value of the "Ignore codepage differences" setting.
447  * @param [in] bIgnoreCodepage New value of the "Ignore codepage differences" setting to set.
448  */
449 inline void ProjectFileItem::SetIgnoreCodepage(bool bIgnoreCodepage)
450 {
451         m_bIgnoreCodepage = bIgnoreCodepage;
452 }
453
454 /** 
455  * @brief Returns the value of the "Ignore comment differences" setting.
456  * @return The value of the "Ignore comment differences" setting
457  */
458 inline bool ProjectFileItem::GetFilterCommentsLines() const
459 {
460         return m_bFilterCommentsLines;
461 }
462
463 /** 
464  * @brief Set the value of the "Ignore comment differences" setting.
465  * @param [in] bFilterCommentsLines New value of the "Ignore comment differences" setting to set.
466  */
467 inline void ProjectFileItem::SetFilterCommentsLines(bool bFilterCommentsLines)
468 {
469         m_bFilterCommentsLines = bFilterCommentsLines;
470 }
471
472 /** 
473  * @brief Returns the value of the "Compare method" setting.
474  * @return The value of the "Compare method" setting
475  */
476 inline int ProjectFileItem::GetCompareMethod() const
477 {
478         return m_nCompareMethod;
479 }
480
481 /** 
482  * @brief Set the value of the "Compare method" setting.
483  * @param [in] nCompareMethod New value of the "Compare method" setting to set.
484  */
485 inline void ProjectFileItem::SetCompareMethod(int nCompareMethod)
486 {
487         m_nCompareMethod = nCompareMethod;
488 }
489
490 /** 
491  * @brief 
492  *
493  * @param [in] paths Files in project
494  * @param [in] bSubFolders If true subfolders included (recursive compare)
495  */
496 inline void ProjectFileItem::SetPaths(const PathContext& paths, bool bSubfolders)
497 {
498         m_paths = paths;
499         m_subfolders = bSubfolders;
500 }
501
502 /** 
503  * @brief Set whether to save filter.
504  * @param [in] bSaveFilter Whether to save filter.
505  */
506 inline void ProjectFileItem::SetSaveFilter(bool bSaveFilter)
507 {
508         m_bSaveFilter = bSaveFilter;
509 }
510
511 /** 
512  * @brief Set whether to save subfolders.
513  * @param [in] bSaveSubfolders Whether to save subfolders.
514  */
515 inline void ProjectFileItem::SetSaveSubfolders(bool bSaveSubfolders)
516 {
517         m_bSaveSubfolders = bSaveSubfolders;
518 }
519
520 /** 
521  * @brief Set whether to save unpacker.
522  * @param [in] bSaveUnpacker Whether to save unpacker.
523  */
524 inline void ProjectFileItem::SetSaveUnpacker(bool bSaveUnpacker)
525 {
526         m_bSaveUnpacker = bSaveUnpacker;
527 }
528
529 /** 
530  * @brief Set whether to save "Whitespaces" setting.
531  * @param [in] bSaveIgnoreWhite Whether to save "Whitespaces" setting.
532  */
533 inline void ProjectFileItem::SetSaveIgnoreWhite(bool bSaveIgnoreWhite)
534 {
535         m_bSaveIgnoreWhite = bSaveIgnoreWhite;
536 }
537
538 /** 
539  * @brief Set whether to save "Ignore blank lines" setting.
540  * @param [in] bSaveIgnoreBlankLines Whether to save "Ignore blank lines" setting.
541  */
542 inline void ProjectFileItem::SetSaveIgnoreBlankLines(bool bSaveIgnoreBlankLines)
543 {
544         m_bSaveIgnoreBlankLines = bSaveIgnoreBlankLines;
545 }
546
547 /** 
548  * @brief Set whether to save "Ignore case" setting.
549  * @param [in] bSaveIgnoreCase Whether to save "Ignore case" setting.
550  */
551 inline void ProjectFileItem::SetSaveIgnoreCase(bool bSaveIgnoreCase)
552 {
553         m_bSaveIgnoreCase = bSaveIgnoreCase;
554 }
555
556 /** 
557  * @brief Set whether to save "Ignore carriage return differences" setting.
558  * @param [in] bSaveIgnoreEol Whether to save "Ignore carriage return differences" setting.
559  */
560 inline void ProjectFileItem::SetSaveIgnoreEol(bool bSaveIgnoreEol)
561 {
562         m_bSaveIgnoreEol = bSaveIgnoreEol;
563 }
564
565 /** 
566  * @brief Set whether to save "Ignore codepage differences" setting.
567  * @param [in] bSaveIgnoreCodepage Whether to save "Ignore codepage differences" setting.
568  */
569 inline void ProjectFileItem::SetSaveIgnoreCodepage(bool bSaveIgnoreCodepage)
570 {
571         m_bSaveIgnoreCodepage = bSaveIgnoreCodepage;
572 }
573
574 /** 
575  * @brief Set whether to save "Ignore comment differences" setting.
576  * @param [in] bSaveFilterCommentsLines Whether to save "Ignore comment differences" setting.
577  */
578 inline void ProjectFileItem::SetSaveFilterCommentsLines(bool bSaveFilterCommentsLines)
579 {
580         m_bSaveFilterCommentsLines = bSaveFilterCommentsLines;
581 }
582
583 /** 
584  * @brief Set whether to save "Compare method" setting.
585  * @param [in] bSaveCompareMethod Whether to save "Compare method" setting.
586  */
587 inline void ProjectFileItem::SetSaveCompareMethod(bool bSaveCompareMethod)
588 {
589         m_bSaveCompareMethod = bSaveCompareMethod;
590 }