X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fstructure%2FSGExpression.cxx;h=78d6daf0f7355072900695826dbc8f9fb7d75313;hb=b9a34b1b05ce9cab1b4b67816d7d24bd2bc364b7;hp=162414876eb39d5a7b6229bcd7ee5bb65cfc08e9;hpb=9cbbe5559844317f44744788ddb308101a1e75e9;p=simgear.git diff --git a/simgear/structure/SGExpression.cxx b/simgear/structure/SGExpression.cxx index 16241487..78d6daf0 100644 --- a/simgear/structure/SGExpression.cxx +++ b/simgear/structure/SGExpression.cxx @@ -33,6 +33,7 @@ #include #include #include +#include // for strcmp #include @@ -292,6 +293,21 @@ SGReadIExpression(SGPropertyNode *inputRoot, const SGPropertyNode *expression) } return output; } + + if (name == "difference" || name == "dif" ) { + if (expression->nChildren() < 1) { + SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression."); + return 0; + } + SGDifferenceExpression* output = new SGDifferenceExpression; + if (!SGReadNaryOperands(output, inputRoot, expression)) { + delete output; + SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression."); + return 0; + } + return output; + } + if (name == "prod" || name == "product") { if (expression->nChildren() < 1) { SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression."); @@ -332,6 +348,38 @@ SGReadIExpression(SGPropertyNode *inputRoot, const SGPropertyNode *expression) return output; } + if (name == "table") { + SGInterpTable* tab = new SGInterpTable(expression); + if (!tab) { + SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression: malformed table"); + return 0; + } + + // find input expression - i.e a child not named 'entry' + const SGPropertyNode* inputNode = NULL; + for (int i=0; (inChildren()) && !inputNode; ++i) { + if (strcmp(expression->getChild(i)->getName(), "entry") == 0) { + continue; + } + + inputNode = expression->getChild(i); + } + + if (!inputNode) { + SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression: no input found"); + return 0; + } + + SGSharedPtr > inputExpression; + inputExpression = SGReadIExpression(inputRoot, inputNode); + if (!inputExpression) { + SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression."); + return 0; + } + + return new SGInterpTableExpression(inputExpression, tab); + } + return 0; } @@ -585,9 +633,7 @@ SGReadFExpression(SGPropertyNode *inputRoot, const SGPropertyNode *expression) } return new SGTanhExpression(inputExpression); } - -// if (name == "table") { -// } + // if (name == "step") { // } // if (name == "condition") { @@ -824,7 +870,7 @@ Expression* logicopParser(const SGPropertyNode* exp, Parser* parser) parser->readChildren(exp, children); vector::iterator notBool = find_if(children.begin(), children.end(), - bind(&Expression::getType, _1) != BOOL); + boost::bind(&Expression::getType, _1) != BOOL); if (notBool != children.end()) throw("non boolean operand to logical expression"); Logicop *expr = new Logicop; @@ -840,7 +886,7 @@ int BindingLayout::addBinding(const string& name, Type type) //XXX error checkint vector::iterator itr = find_if(bindings.begin(), bindings.end(), - bind(&VariableBinding::name, _1) == name); + boost::bind(&VariableBinding::name, _1) == name); if (itr != bindings.end()) return itr->location; int result = bindings.size(); @@ -855,7 +901,7 @@ bool BindingLayout::findBinding(const std::string& name, using namespace boost; vector::const_iterator itr = find_if(bindings.begin(), bindings.end(), - bind(&VariableBinding::name, _1) == name); + boost::bind(&VariableBinding::name, _1) == name); if (itr != bindings.end()) { result = *itr; return true;