From 92074f0d3c29ed5d064db0c943cf88760c930e23 Mon Sep 17 00:00:00 2001 From: Frederic Bouvier Date: Sun, 4 Mar 2012 21:24:54 +0100 Subject: [PATCH] Allow the not operator in expressions --- simgear/structure/SGExpression.cxx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/simgear/structure/SGExpression.cxx b/simgear/structure/SGExpression.cxx index 6f292e46..b14a5a50 100644 --- a/simgear/structure/SGExpression.cxx +++ b/simgear/structure/SGExpression.cxx @@ -866,6 +866,23 @@ Expression* logicopParser(const SGPropertyNode* exp, Parser* parser) ExpParserRegistrar andRegistrar("and", logicopParser); ExpParserRegistrar orRegistrar("or", logicopParser); +Expression* notLogicopParser(const SGPropertyNode* exp, Parser* parser) +{ + using namespace boost; + vector children; + parser->readChildren(exp, children); + vector::iterator notBool = + find_if(children.begin(), children.end(), + boost::bind(&Expression::getType, _1) != BOOL); + if (notBool != children.end() || children.size() != 1) + throw("non boolean operand to not expression"); + NotExpression *expr = new NotExpression; + expr->setOperand(static_cast< ::SGExpression*>(children[0])); + return expr; +} + +ExpParserRegistrar notRegistrar("not", notLogicopParser); + int BindingLayout::addBinding(const string& name, Type type) { //XXX error checkint -- 2.39.5