mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
FF4 - Mod object to handle attribute modifiers
- New Mod object responsible for evaluating a chain of attribute modifiers.
This commit is contained in:
parent
78e9b00a63
commit
1ad23c7bdc
2 changed files with 57 additions and 3 deletions
|
@ -38,12 +38,63 @@ Mod::~Mod ()
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Mod::isRecognized ()
|
||||
// before after
|
||||
// not
|
||||
// none any
|
||||
// over under
|
||||
// synth
|
||||
// first last
|
||||
// this
|
||||
// next
|
||||
// is isnt
|
||||
// has hasnt
|
||||
// startswith endswith
|
||||
bool Mod::isValid ()
|
||||
{
|
||||
if (*this == ".is")
|
||||
if (*this == "before" || *this == "after" ||
|
||||
*this == "not" ||
|
||||
*this == "none" || *this == "any" ||
|
||||
*this == "synth" ||
|
||||
*this == "under" || *this == "over" ||
|
||||
*this == "first" || *this == "last" ||
|
||||
*this == "this" ||
|
||||
*this == "next" ||
|
||||
*this == "is" || *this == "isnt" ||
|
||||
*this == "has" || *this == "hasnt" ||
|
||||
*this == "startswith" || *this == "endswith")
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Mod::eval (const Mod& other)
|
||||
{
|
||||
// before
|
||||
// after
|
||||
// non
|
||||
// none
|
||||
// any
|
||||
// synth
|
||||
// under
|
||||
// over
|
||||
// first
|
||||
// last
|
||||
// this
|
||||
// next
|
||||
|
||||
if (*this == ".is")
|
||||
return *this == other ? true : false;
|
||||
|
||||
if (*this == ".isnt")
|
||||
return *this != other ? true : false;
|
||||
|
||||
// has
|
||||
// hasnt
|
||||
// startswith
|
||||
// endswith
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -29,13 +29,16 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
class Mod;
|
||||
|
||||
class Mod : public std::string
|
||||
{
|
||||
public:
|
||||
Mod (); // Default constructor
|
||||
~Mod (); // Destructor
|
||||
|
||||
bool isRecognized ();
|
||||
bool isValid ();
|
||||
bool eval (const Mod&);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue