ClientPattern Class Reference#include <ClientPattern.hh>
Inheritance diagram for ClientPattern:
List of all members.
|
Public Types |
| enum | WinProperty { TITLE,
CLASS,
NAME
} |
Public Member Functions |
| | ClientPattern (const char *str) |
|
std::string | toString () const |
| | a string representation of this pattern
|
|
bool | match (const WinClient &win) const |
| | Does this client match this pattern?
|
| bool | addTerm (const std::string &str, WinProperty prop) |
|
void | addMatch () |
|
void | delMatch () |
|
bool | operator== (const WinClient &win) const |
| int | error () const |
|
std::string | getProperty (WinProperty prop, const WinClient &winclient) const |
Detailed Description
This class represents a "pattern" that we can match against a Window based on various properties.
Definition at line 41 of file ClientPattern.hh.
Constructor & Destructor Documentation
| ClientPattern::ClientPattern |
( |
const char * |
str |
) |
[explicit] |
|
|
|
Create the pattern from the given string as it would appear in the apps file. the bool value returns the character at which there was a parse problem, or -1.
Definition at line 67 of file ClientPattern.cc.
References addTerm(), and match().
00067 :
00068 m_matchlimit(0),
00069 m_nummatches(0)
00070 {
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085 int had_error = 0;
00086
00087 int pos = 0;
00088 string match;
00089 int err = 1;
00090 while (had_error == 0 && err > 0) {
00091 err = FbTk::StringUtil::getStringBetween(match,
00092 str + pos,
00093 '(', ')', " \t\n", true);
00094 if (err > 0) {
00095 size_t eq = match.find_first_of('=');
00096 if (eq == match.npos) {
00097 if (!addTerm(match, NAME)) {
00098 had_error = pos + match.find_first_of('(') + 1;
00099 break;
00100 }
00101 } else {
00102
00103 string memstr, expr;
00104 WinProperty prop;
00105 memstr.assign(match, 0, eq);
00106 expr.assign(match, eq+1, match.length());
00107 if (strcasecmp(memstr.c_str(), "name") == 0) {
00108 prop = NAME;
00109 } else if (strcasecmp(memstr.c_str(), "class") == 0) {
00110 prop = CLASS;
00111 } else if (strcasecmp(memstr.c_str(), "title") == 0) {
00112 prop = TITLE;
00113 } else {
00114 had_error = pos + match.find_first_of('(') + 1;
00115 break;
00116 }
00117 if (!addTerm(expr, prop)) {
00118 had_error = pos + ((str+pos) - index(str+pos, '=')) + 1;
00119 break;
00120 }
00121 }
00122 pos += err;
00123 }
00124 }
00125 if (pos == 0 && had_error == 0) {
00126
00127 had_error = 1;
00128 }
00129
00130 if (had_error == 0) {
00131
00132 string number;
00133 err = FbTk::StringUtil::getStringBetween(number,
00134 str+pos,
00135 '{', '}');
00136 if (err > 0) {
00137 FB_istringstream iss(number.c_str());
00138 iss >> m_matchlimit;
00139 pos+=err;
00140 }
00141
00142
00143
00144 match = str + pos;
00145 err = match.find_first_not_of(" \t\n", pos);
00146 if ((unsigned) err != match.npos) {
00147
00148 had_error = err;
00149 }
00150 }
00151
00152 if (had_error > 0) {
00153 m_matchlimit = had_error;
00154
00155 while (!m_terms.empty()) {
00156 Term * term = m_terms.back();
00157 delete term;
00158 m_terms.pop_back();
00159 }
00160 }
00161 }
|
Member Function Documentation
| bool ClientPattern::addTerm |
( |
const std::string & |
str, |
|
|
WinProperty |
prop |
|
) |
|
|
|
|
Add an expression to match against - Parameters:
-
| str | is a regular expression |
| prop | is the member function that we wish to match against |
- Returns:
- false if the regexp wasn't valid
Definition at line 224 of file ClientPattern.cc.
Referenced by ClientPattern().
00224 {
00225
00226 Term *term = new Term(str, true);
00227 term->orig = str;
00228 term->prop = prop;
00229
00230 if (term->regexp.error()) {
00231 delete term;
00232 return false;
00233 }
00234 m_terms.push_back(term);
00235 return true;
00236 }
|
| int ClientPattern::error |
( |
|
) |
const [inline] |
|
|
|
If there are no terms, then there is assumed to be an error the column of the error is stored in m_matchlimit
Definition at line 80 of file ClientPattern.hh.
00080 { return m_terms.empty() ? m_matchlimit : 0; }
|
The documentation for this class was generated from the following files:
Fluxbox CVS-Jan-2003
|
|
|