diff options
Diffstat (limited to 'src/ClientPattern.hh')
-rw-r--r-- | src/ClientPattern.hh | 30 |
1 files changed, 9 insertions, 21 deletions
diff --git a/src/ClientPattern.hh b/src/ClientPattern.hh index 9eb7653..6aa2e11 100644 --- a/src/ClientPattern.hh +++ b/src/ClientPattern.hh | |||
@@ -26,6 +26,7 @@ | |||
26 | 26 | ||
27 | #include "FbTk/RegExp.hh" | 27 | #include "FbTk/RegExp.hh" |
28 | #include "FbTk/NotCopyable.hh" | 28 | #include "FbTk/NotCopyable.hh" |
29 | #include "FbTk/FbString.hh" | ||
29 | 30 | ||
30 | #include <list> | 31 | #include <list> |
31 | 32 | ||
@@ -48,7 +49,7 @@ public: | |||
48 | ~ClientPattern(); | 49 | ~ClientPattern(); |
49 | 50 | ||
50 | /// @return a string representation of this pattern | 51 | /// @return a string representation of this pattern |
51 | std::string toString() const; | 52 | FbTk::FbString toString() const; |
52 | 53 | ||
53 | enum WinProperty { | 54 | enum WinProperty { |
54 | TITLE = 0, CLASS, NAME, ROLE, TRANSIENT, | 55 | TITLE = 0, CLASS, NAME, ROLE, TRANSIENT, |
@@ -71,7 +72,7 @@ public: | |||
71 | * @param prop is the member function that we wish to match against | 72 | * @param prop is the member function that we wish to match against |
72 | * @return false if the regexp wasn't valid | 73 | * @return false if the regexp wasn't valid |
73 | */ | 74 | */ |
74 | bool addTerm(const std::string &str, WinProperty prop, bool negate = false); | 75 | bool addTerm(const FbTk::FbString &str, WinProperty prop, bool negate = false); |
75 | 76 | ||
76 | void addMatch() { ++m_nummatches; } | 77 | void addMatch() { ++m_nummatches; } |
77 | void removeMatch() { --m_nummatches; } | 78 | void removeMatch() { --m_nummatches; } |
@@ -86,29 +87,16 @@ public: | |||
86 | */ | 87 | */ |
87 | int error() const { return m_terms.empty() ? 1 : 0; } | 88 | int error() const { return m_terms.empty() ? 1 : 0; } |
88 | 89 | ||
89 | static std::string getProperty(WinProperty prop, const Focusable &client); | 90 | static FbTk::FbString getProperty(WinProperty prop, const Focusable &client); |
90 | 91 | ||
91 | private: | 92 | private: |
92 | /** | 93 | struct Term; |
93 | * This is the type of the actual pattern we want to match against | 94 | friend struct Term; |
94 | * We have a "term" in the whole expression which is the full pattern | ||
95 | * we also need to keep track of the uncompiled regular expression | ||
96 | * for final output | ||
97 | */ | ||
98 | struct Term { | ||
99 | Term(const std::string ®str, bool full_match) :regexp(regstr, full_match){}; | ||
100 | std::string orig; | ||
101 | FbTk::RegExp regexp; | ||
102 | WinProperty prop; | ||
103 | bool negate; | ||
104 | }; | ||
105 | |||
106 | |||
107 | typedef std::list<Term *> Terms; | 95 | typedef std::list<Term *> Terms; |
108 | 96 | ||
109 | Terms m_terms; ///< our pattern is made up of a sequence of terms currently we "and" them all | 97 | Terms m_terms; ///< our pattern is made up of a sequence of terms, currently we "and" them all |
110 | 98 | int m_matchlimit; | |
111 | int m_matchlimit, m_nummatches; | 99 | int m_nummatches; |
112 | }; | 100 | }; |
113 | 101 | ||
114 | #endif // CLIENTPATTERN_HH | 102 | #endif // CLIENTPATTERN_HH |