diff options
author | fluxgen <fluxgen> | 2003-06-13 12:02:00 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2003-06-13 12:02:00 (GMT) |
commit | b05f27d33a91a1739bb1af5923f064364298fea3 (patch) | |
tree | ccdfdb10f794f519a696a50228453042588876b8 /src/ClientPattern.hh | |
parent | cb14466431e2e1ce56d47fcd3c3ec98d0fa1fa29 (diff) | |
download | fluxbox_pavel-b05f27d33a91a1739bb1af5923f064364298fea3.zip fluxbox_pavel-b05f27d33a91a1739bb1af5923f064364298fea3.tar.bz2 |
minor cleaning
Diffstat (limited to 'src/ClientPattern.hh')
-rw-r--r-- | src/ClientPattern.hh | 51 |
1 files changed, 29 insertions, 22 deletions
diff --git a/src/ClientPattern.hh b/src/ClientPattern.hh index 00a3127..7e89511 100644 --- a/src/ClientPattern.hh +++ b/src/ClientPattern.hh | |||
@@ -21,12 +21,13 @@ | |||
21 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | 21 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
22 | // DEALINGS IN THE SOFTWARE. | 22 | // DEALINGS IN THE SOFTWARE. |
23 | 23 | ||
24 | // $Id: ClientPattern.hh,v 1.1 2003/06/12 15:12:19 rathnor Exp $ | 24 | // $Id: ClientPattern.hh,v 1.2 2003/06/13 12:02:00 fluxgen Exp $ |
25 | 25 | ||
26 | #ifndef CLIENTPATTERN_HH | 26 | #ifndef CLIENTPATTERN_HH |
27 | #define CLIENTPATTERN_HH | 27 | #define CLIENTPATTERN_HH |
28 | 28 | ||
29 | #include "RegExp.hh" | 29 | #include "RegExp.hh" |
30 | #include "NotCopyable.hh" | ||
30 | 31 | ||
31 | #include <string> | 32 | #include <string> |
32 | #include <list> | 33 | #include <list> |
@@ -37,28 +38,32 @@ class WinClient; | |||
37 | * This class represents a "pattern" that we can match against a | 38 | * This class represents a "pattern" that we can match against a |
38 | * Window based on various properties. | 39 | * Window based on various properties. |
39 | */ | 40 | */ |
40 | class ClientPattern { | 41 | class ClientPattern:private FbTk::NotCopyable { |
41 | public: | 42 | public: |
42 | ClientPattern(); | 43 | ClientPattern(); |
43 | // create the pattern from the given string as it would appear in the | 44 | /** |
44 | // apps file. the bool value returns the character at which | 45 | * Create the pattern from the given string as it would appear in the |
45 | // there was a parse problem, or -1. | 46 | * apps file. the bool value returns the character at which |
47 | * there was a parse problem, or -1. | ||
48 | */ | ||
46 | explicit ClientPattern(const char * str); | 49 | explicit ClientPattern(const char * str); |
47 | 50 | ||
48 | ~ClientPattern(); | 51 | ~ClientPattern(); |
49 | 52 | ||
50 | // return a string representation of this pattern | 53 | /// @return a string representation of this pattern |
51 | std::string toString() const; | 54 | std::string toString() const; |
52 | 55 | ||
53 | enum WinProperty { TITLE, CLASS, NAME }; | 56 | enum WinProperty { TITLE, CLASS, NAME }; |
54 | 57 | ||
55 | // does this client match this pattern? | 58 | /// Does this client match this pattern? |
56 | bool match(const WinClient &win) const; | 59 | bool match(const WinClient &win) const; |
57 | 60 | ||
58 | // add an expression to match against | 61 | /** |
59 | // The first argument is a regular expression, the second is the member | 62 | * Add an expression to match against |
60 | // function that we wish to match against. | 63 | * @param str is a regular expression |
61 | // returns false if the regexp wasn't valid | 64 | * @param prop is the member function that we wish to match against |
65 | * @return false if the regexp wasn't valid | ||
66 | */ | ||
62 | bool addTerm(const std::string &str, WinProperty prop); | 67 | bool addTerm(const std::string &str, WinProperty prop); |
63 | 68 | ||
64 | inline void addMatch() { ++m_nummatches; } | 69 | inline void addMatch() { ++m_nummatches; } |
@@ -68,18 +73,21 @@ public: | |||
68 | return match(win); | 73 | return match(win); |
69 | } | 74 | } |
70 | 75 | ||
71 | // if there are no terms, then there is assumed to be an error | 76 | /** |
72 | // the column of the error is stored in m_matchlimit | 77 | * If there are no terms, then there is assumed to be an error |
73 | inline int error() { return (m_terms.empty())?m_matchlimit:0; } | 78 | * the column of the error is stored in m_matchlimit |
79 | */ | ||
80 | inline int error() const { return m_terms.empty() ? m_matchlimit : 0; } | ||
74 | 81 | ||
75 | std::string getProperty(WinProperty prop, const WinClient &winclient) const; | 82 | std::string getProperty(WinProperty prop, const WinClient &winclient) const; |
76 | 83 | ||
77 | private: | 84 | private: |
78 | // This is the type of the actual pattern we want to match against | 85 | /** |
79 | // We have a "term" in the whole expression which is the full pattern | 86 | * This is the type of the actual pattern we want to match against |
80 | // we also need to keep track of the uncompiled regular expression | 87 | * We have a "term" in the whole expression which is the full pattern |
81 | // for final output | 88 | * we also need to keep track of the uncompiled regular expression |
82 | 89 | * for final output | |
90 | */ | ||
83 | struct Term { | 91 | struct Term { |
84 | Term(const std::string ®str, bool full_match) :regexp(regstr, full_match){}; | 92 | Term(const std::string ®str, bool full_match) :regexp(regstr, full_match){}; |
85 | std::string orig; | 93 | std::string orig; |
@@ -87,11 +95,10 @@ private: | |||
87 | WinProperty prop; | 95 | WinProperty prop; |
88 | }; | 96 | }; |
89 | 97 | ||
90 | // our pattern is made up of a sequence of terms | 98 | |
91 | // currently we "and" them all | ||
92 | typedef std::list<Term *> Terms; | 99 | typedef std::list<Term *> Terms; |
93 | 100 | ||
94 | Terms m_terms; | 101 | Terms m_terms; ///< our pattern is made up of a sequence of terms currently we "and" them all |
95 | 102 | ||
96 | int m_matchlimit, m_nummatches; | 103 | int m_matchlimit, m_nummatches; |
97 | }; | 104 | }; |