OSDN Git Service

1be6af05e9c7def03be0dcd42faf1952acbe69fc
[winmerge-jp/winmerge-jp.git] / Src / IgnoredSubstitutionsList.h
1 /** 
2  * @file IgnoredSubstitutionsList.h
3  *
4  * @brief Declaration file for IgnoredSubstitutionsList class
5  */
6 #pragma once
7
8 #include <vector>
9 #include <memory>
10 #include "UnicodeString.h"
11 #include "SubstitutionList.h"
12
13 class COptionsMgr;
14
15 /**
16  @brief Structure for filter.
17  */
18 struct IgnoredSubstitution
19 {
20         bool enabled;
21         bool useRegExp;
22         bool caseSensitive;
23         bool matchWholeWordOnly;
24         String pattern;
25         String replacement;
26 };
27
28 /**
29  @brief List of raw Ignored Substitution pairs.
30  */
31 class IgnoredSubstitutionsList
32 {
33 public:
34         IgnoredSubstitutionsList();
35         ~IgnoredSubstitutionsList();
36
37         void Add(const String& pattern, const String& replacement, bool useRegExp, bool caseSensitive, bool matchWholeWordOnly, bool enabled);
38         size_t GetCount() const;
39         void Empty();
40         const IgnoredSubstitution &GetAt(size_t ind) const;
41         void CloneFrom(const IgnoredSubstitutionsList *list);
42         bool Compare(const IgnoredSubstitutionsList *list) const;
43
44         void Initialize(COptionsMgr *pOptionsMgr);
45         void SaveFilters();
46
47         std::shared_ptr<SubstitutionList> MakeSubstitutionList(bool throwIfInvalid = false);
48
49 private:
50         std::vector<IgnoredSubstitution> m_items; /**< List for linefilter items */
51         COptionsMgr * m_pOptionsMgr; /**< Options-manager for storage */
52 };
53
54 /**
55  * @brief Returns count of items in the list.
56  * @return Count of filters in the list.
57  */
58 inline size_t IgnoredSubstitutionsList::GetCount() const
59 {
60         return m_items.size();
61 }
62
63 /**
64  * @brief Empties the list.
65  */
66 inline void IgnoredSubstitutionsList::Empty()
67 {
68         m_items.clear();
69 }