FF4 - Mod object to handle attribute modifiers

- New Mod object responsible for evaluating a chain of attribute
  modifiers.
This commit is contained in:
Paul Beckingham 2009-05-23 09:30:52 -04:00
parent 78e9b00a63
commit 1ad23c7bdc
2 changed files with 57 additions and 3 deletions

View file

@ -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;
}
////////////////////////////////////////////////////////////////////////////////

View file

@ -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