diff options
author | Danny Baumann <dannybaumann@web.de> | 2009-02-22 17:30:58 +0100 |
---|---|---|
committer | Danny Baumann <dannybaumann@web.de> | 2009-02-22 17:30:58 +0100 |
commit | 91fcc47d14c249168d514f74fe27e8e9b212ff9b (patch) | |
tree | 15395a63fc8c5787819b5b481d09eaecff46caba | |
parent | 36edd5272fcd331bdc1330aa6763cb404a7ca156 (diff) | |
download | zcomp-91fcc47d14c249168d514f74fe27e8e9b212ff9b.tar.gz zcomp-91fcc47d14c249168d514f74fe27e8e9b212ff9b.tar.bz2 |
Match API improvements:
- Provide != operator and emptiness check method
- Provide empty match
- Improve const correctness
-rw-r--r-- | include/core/match.h | 8 | ||||
-rw-r--r-- | src/match.cpp | 20 |
2 files changed, 23 insertions, 5 deletions
diff --git a/include/core/match.h b/include/core/match.h index dcf10ae..4afbec7 100644 --- a/include/core/match.h +++ b/include/core/match.h @@ -49,10 +49,13 @@ class CompMatch { CompMatch (const CompMatch &); ~CompMatch (); + static const CompMatch emptyMatch; + void update (); bool evaluate (CompWindow *window); - CompString toString (); + CompString toString () const; + bool isEmpty () const; CompMatch & operator= (const CompMatch &); CompMatch & operator&= (const CompMatch &); @@ -69,7 +72,8 @@ class CompMatch { const CompMatch & operator& (const CompString &); const CompMatch & operator| (const CompString &); - bool operator== (const CompMatch &); + bool operator== (const CompMatch &) const; + bool operator!= (const CompMatch &) const; private: PrivateMatch *priv; diff --git a/src/match.cpp b/src/match.cpp index a16c44a..072083e 100644 --- a/src/match.cpp +++ b/src/match.cpp @@ -39,6 +39,8 @@ #include "privatescreen.h" #include "privatewindow.h" +const CompMatch CompMatch::emptyMatch; + class CoreExp : public CompMatch::Expression { public: virtual ~CoreExp () {}; @@ -609,7 +611,7 @@ CompMatch::update () matchResetOps (priv->op.op); matchUpdateOps (priv->op.op); } - + bool CompMatch::evaluate (CompWindow *window) { @@ -617,11 +619,17 @@ CompMatch::evaluate (CompWindow *window) } CompString -CompMatch::toString () +CompMatch::toString () const { return matchOpsToString (priv->op.op); } +bool +CompMatch::isEmpty () const +{ + return (*this == emptyMatch); +} + CompMatch & CompMatch::operator= (const CompMatch &match) { @@ -712,7 +720,13 @@ CompMatch::operator| (const CompString &str) } bool -CompMatch::operator== (const CompMatch &match) +CompMatch::operator== (const CompMatch &match) const { return matchOpsEqual (priv->op.op, match.priv->op.op); } + +bool +CompMatch::operator!= (const CompMatch &match) const +{ + return !(*this == match); +} |