From 9e77d06c7262eafdf77b03d2b101e090cb2ec91d Mon Sep 17 00:00:00 2001 From: James Turner Date: Wed, 26 May 2010 19:28:42 +0100 Subject: [PATCH] Support s in expression XML. --- simgear/structure/SGExpression.cxx | 36 +++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/simgear/structure/SGExpression.cxx b/simgear/structure/SGExpression.cxx index 16241487..d534aad0 100644 --- a/simgear/structure/SGExpression.cxx +++ b/simgear/structure/SGExpression.cxx @@ -332,6 +332,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 +617,7 @@ SGReadFExpression(SGPropertyNode *inputRoot, const SGPropertyNode *expression) } return new SGTanhExpression(inputExpression); } - -// if (name == "table") { -// } + // if (name == "step") { // } // if (name == "condition") { -- 2.39.5