00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef CLIENTPATTERN_HH
00027 #define CLIENTPATTERN_HH
00028
00029 #include "RegExp.hh"
00030 #include "NotCopyable.hh"
00031
00032 #include <string>
00033 #include <list>
00034
00035 class WinClient;
00036
00041 class ClientPattern:private FbTk::NotCopyable {
00042 public:
00043 ClientPattern();
00049 explicit ClientPattern(const char * str);
00050
00051 ~ClientPattern();
00052
00054 std::string toString() const;
00055
00056 enum WinProperty { TITLE, CLASS, NAME };
00057
00059 bool match(const WinClient &win) const;
00060
00067 bool addTerm(const std::string &str, WinProperty prop);
00068
00069 inline void addMatch() { ++m_nummatches; }
00070 inline void delMatch() { --m_nummatches; }
00071
00072 inline bool operator == (const WinClient &win) const {
00073 return match(win);
00074 }
00075
00080 inline int error() const { return m_terms.empty() ? m_matchlimit : 0; }
00081
00082 std::string getProperty(WinProperty prop, const WinClient &winclient) const;
00083
00084 private:
00091 struct Term {
00092 Term(const std::string ®str, bool full_match) :regexp(regstr, full_match){};
00093 std::string orig;
00094 RegExp regexp;
00095 WinProperty prop;
00096 };
00097
00098
00099 typedef std::list<Term *> Terms;
00100
00101 Terms m_terms;
00102
00103 int m_matchlimit, m_nummatches;
00104 };
00105
00106 #endif // CLIENTPATTERN_HH