X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fstructure%2FSGExpression.cxx;h=d534aad07274fa698a28e4d4c6f248c905a19ab7;hb=4e46bb667179cd45cfb2f9934734ceddd1ea01b4;hp=fa6650300fce9a0bf55f395b91b805ae4f6eb01b;hpb=efec9070e178c9aef98332cb03d967868179ae4a;p=simgear.git diff --git a/simgear/structure/SGExpression.cxx b/simgear/structure/SGExpression.cxx index fa665030..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") { @@ -690,11 +720,10 @@ bool Parser::readChildren(const SGPropertyNode* exp, return true; } -Parser::ParserMap ExpressionParser::_parserTable; - void ExpressionParser::addExpParser(const string& token, exp_parser parsefn) { - _parserTable.insert(std::make_pair(token, parsefn)); + ParserMapSingleton::instance() + ->_parserTable.insert(std::make_pair(token, parsefn)); } Expression* valueParser(const SGPropertyNode* exp, Parser* parser)