OSDN Git Service

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