aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2003-06-13 12:02:00 (GMT)
committerfluxgen <fluxgen>2003-06-13 12:02:00 (GMT)
commitb05f27d33a91a1739bb1af5923f064364298fea3 (patch)
treeccdfdb10f794f519a696a50228453042588876b8 /src
parentcb14466431e2e1ce56d47fcd3c3ec98d0fa1fa29 (diff)
downloadfluxbox_paul-b05f27d33a91a1739bb1af5923f064364298fea3.zip
fluxbox_paul-b05f27d33a91a1739bb1af5923f064364298fea3.tar.bz2
minor cleaning
Diffstat (limited to 'src')
-rw-r--r--src/ClientPattern.cc30
-rw-r--r--src/ClientPattern.hh51
2 files changed, 43 insertions, 38 deletions
diff --git a/src/ClientPattern.cc b/src/ClientPattern.cc
index 7ad3a54..76151aa 100644
--- a/src/ClientPattern.cc
+++ b/src/ClientPattern.cc
@@ -20,16 +20,16 @@
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21// DEALINGS IN THE SOFTWARE. 21// DEALINGS IN THE SOFTWARE.
22 22
23// $Id: ClientPattern.cc,v 1.1 2003/06/12 15:12:19 rathnor Exp $ 23// $Id: ClientPattern.cc,v 1.2 2003/06/13 12:01:06 fluxgen Exp $
24 24
25#include "ClientPattern.hh" 25#include "ClientPattern.hh"
26#include "RegExp.hh" 26#include "RegExp.hh"
27#include "StringUtil.hh" 27#include "StringUtil.hh"
28#include "WinClient.hh" 28#include "WinClient.hh"
29 29
30//use GNU extensions 30// use GNU extensions
31#ifndef _GNU_SOURCE 31#ifndef _GNU_SOURCE
32#define _GNU_SOURCE 32#define _GNU_SOURCE
33#endif // _GNU_SOURCE 33#endif // _GNU_SOURCE
34 34
35 35
@@ -41,10 +41,6 @@
41 41
42using namespace std; 42using namespace std;
43 43
44/********************************************************
45 * ClientPattern *
46 ***********/
47
48ClientPattern::ClientPattern(): 44ClientPattern::ClientPattern():
49 m_matchlimit(0), 45 m_matchlimit(0),
50 m_nummatches(0) {} 46 m_nummatches(0) {}
@@ -161,17 +157,19 @@ std::string ClientPattern::toString() const {
161 Terms::const_iterator it_end = m_terms.end(); 157 Terms::const_iterator it_end = m_terms.end();
162 for (; it != it_end; ++it) { 158 for (; it != it_end; ++it) {
163 pat.append(" ("); 159 pat.append(" (");
164 if ((*it)->prop == NAME) { 160
161 switch ((*it)->prop) {
162 case NAME:
165 // do nothing -> this is the default 163 // do nothing -> this is the default
166 } else if ((*it)->prop == CLASS) { 164 break;
165 case CLASS:
167 pat.append("class="); 166 pat.append("class=");
168 } else if ((*it)->prop == TITLE) { 167 break;
168 case TITLE:
169 pat.append("title="); 169 pat.append("title=");
170 } else { 170 break;
171#ifdef DEBUG
172 cerr<<"WARNING: unknown window property, can't save properly"<<endl;
173#endif //DEBUG
174 } 171 }
172
175 pat.append((*it)->orig); 173 pat.append((*it)->orig);
176 pat.append(")"); 174 pat.append(")");
177 } 175 }
@@ -228,8 +226,8 @@ std::string ClientPattern::getProperty(WinProperty prop, const WinClient &client
228 return client.getWMClassClass(); 226 return client.getWMClassClass();
229 break; 227 break;
230 case NAME: 228 case NAME:
231 default:
232 return client.getWMClassName(); 229 return client.getWMClassName();
233 break; 230 break;
234 } 231 }
232 return client.getWMClassName();
235} 233}
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 */
40class ClientPattern { 41class ClientPattern:private FbTk::NotCopyable {
41public: 42public:
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
77private: 84private:
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 &regstr, bool full_match) :regexp(regstr, full_match){}; 92 Term(const std::string &regstr, 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};