Debian Codegraph @

CodeLite/clAnagram.h

raw
1 #ifndef CLANAGRAM_H
2 #define CLANAGRAM_H
3
4 #include "codelite_exports.h"
5 #include "wxStringHash.h"
6 #include <wx/string.h>
7
8 enum class eAnagramFlag {
9 kNone = 0,
10 kIgnoreWhitespace = (1 << 0),
11 };
12
13 class WXDLLIMPEXP_CL clAnagram
14 {
15 std::unordered_map<wxChar, int> m_charCounts;
16 wxString m_needle;
17 size_t m_flags;
18
19 protected:
20 bool HasFlag(eAnagramFlag flag) const { return (m_flags & (size_t)flag); }
21
22 public:
23 clAnagram()
24 : m_flags(0)
25 {
26 }
27 clAnagram(const wxString& needle, size_t flags = 0);
28 virtual ~clAnagram();
29
30 /**
31 * @brief reset the anagram with a new pattern
32 * See eAnagramFlag for possible flags
33 */
34 void Reset(const wxString& needle, size_t flags = 0);
35
36 /**
37 * @brief check haystack contains this anagram
38 */
39 bool Matches(const wxString& haystack) const;
40
41 /**
42 * @brief search for needle in haystack in order
43 */
44 bool MatchesInOrder(const wxString& haystack) const;
45
46 /**
47 * @brief return true if the needle is an empty string
48 */
49 bool IsEmpty() const;
50 };
51
52 #endif // CLANAGRAM_H