- SGExpression<T>* r = SGReadIExpression<T>(inputRoot, expression);
- if (r)
- return r;
-
- if (!expression)
- return 0;
-
- std::string name = expression->getName();
- if (name == "acos") {
- if (expression->nChildren() != 1) {
- SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
- return 0;
- }
- SGSharedPtr<SGExpression<T> > inputExpression;
- inputExpression = SGReadFExpression<T>(inputRoot, expression->getChild(0));
- if (!inputExpression) {
- SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
- return 0;
- }
- return new SGACosExpression<T>(inputExpression);
- }
-
- if (name == "asin") {
- if (expression->nChildren() != 1) {
- SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
- return 0;
- }
- SGSharedPtr<SGExpression<T> > inputExpression;
- inputExpression = SGReadFExpression<T>(inputRoot, expression->getChild(0));
- if (!inputExpression) {
- SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
- return 0;
- }
- return new SGASinExpression<T>(inputExpression);
- }
-
- if (name == "atan") {
- if (expression->nChildren() != 1) {
- SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
- return 0;
- }
- SGSharedPtr<SGExpression<T> > inputExpression;
- inputExpression = SGReadFExpression<T>(inputRoot, expression->getChild(0));
- if (!inputExpression) {
- SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
- return 0;
- }
- return new SGATanExpression<T>(inputExpression);
- }
-
- if (name == "ceil") {
- if (expression->nChildren() != 1) {
- SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
- return 0;
- }
- SGSharedPtr<SGExpression<T> > inputExpression;
- inputExpression = SGReadFExpression<T>(inputRoot, expression->getChild(0));
- if (!inputExpression) {
- SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
- return 0;
- }
- return new SGCeilExpression<T>(inputExpression);
- }
-
- if (name == "cos") {
- if (expression->nChildren() != 1) {
- SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
- return 0;
- }
- SGSharedPtr<SGExpression<T> > inputExpression;
- inputExpression = SGReadFExpression<T>(inputRoot, expression->getChild(0));
- if (!inputExpression) {
- SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
- return 0;
- }
- return new SGCosExpression<T>(inputExpression);
- }
-
- if (name == "cosh") {
- if (expression->nChildren() != 1) {
- SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
- return 0;
- }
- SGSharedPtr<SGExpression<T> > inputExpression;
- inputExpression = SGReadFExpression<T>(inputRoot, expression->getChild(0));
- if (!inputExpression) {
- SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
- return 0;
- }
- return new SGCoshExpression<T>(inputExpression);
- }
-
- if (name == "deg2rad") {
- if (expression->nChildren() != 1) {
- SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
- return 0;
- }
- SGSharedPtr<SGExpression<T> > inputExpression;
- inputExpression = SGReadFExpression<T>(inputRoot, expression->getChild(0));
- if (!inputExpression) {
- SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
- return 0;
- }
- return new SGScaleExpression<T>(inputExpression, SGMisc<T>::pi()/180);
- }
-
- if (name == "exp") {
- if (expression->nChildren() != 1) {
- SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
- return 0;
- }
- SGSharedPtr<SGExpression<T> > inputExpression;
- inputExpression = SGReadFExpression<T>(inputRoot, expression->getChild(0));
- if (!inputExpression) {
- SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
- return 0;
- }
- return new SGExpExpression<T>(inputExpression);
- }
-
- if (name == "floor") {
- if (expression->nChildren() != 1) {
- SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
- return 0;
- }
- SGSharedPtr<SGExpression<T> > inputExpression;
- inputExpression = SGReadFExpression<T>(inputRoot, expression->getChild(0));
- if (!inputExpression) {
- SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
- return 0;
- }
- return new SGFloorExpression<T>(inputExpression);
- }
-
- if (name == "log") {
- if (expression->nChildren() != 1) {
- SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
- return 0;
- }
- SGSharedPtr<SGExpression<T> > inputExpression;
- inputExpression = SGReadFExpression<T>(inputRoot, expression->getChild(0));
- if (!inputExpression) {
- SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
- return 0;
- }
- return new SGLogExpression<T>(inputExpression);
- }
-
- if (name == "log10") {
- if (expression->nChildren() != 1) {
- SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
- return 0;
- }
- SGSharedPtr<SGExpression<T> > inputExpression;
- inputExpression = SGReadFExpression<T>(inputRoot, expression->getChild(0));
- if (!inputExpression) {
- SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
- return 0;
- }
- return new SGLog10Expression<T>(inputExpression);
- }
-
- if (name == "rad2deg") {
- if (expression->nChildren() != 1) {
- SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
- return 0;
- }
- SGSharedPtr<SGExpression<T> > inputExpression;
- inputExpression = SGReadFExpression<T>(inputRoot, expression->getChild(0));
- if (!inputExpression) {
- SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
- return 0;
- }
- return new SGScaleExpression<T>(inputExpression, 180/SGMisc<T>::pi());
- }
-
- if (name == "sin") {
- if (expression->nChildren() != 1) {
- SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
- return 0;
- }
- SGSharedPtr<SGExpression<T> > inputExpression;
- inputExpression = SGReadFExpression<T>(inputRoot, expression->getChild(0));
- if (!inputExpression) {
- SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
- return 0;
- }
- return new SGSinExpression<T>(inputExpression);
- }
-
- if (name == "sinh") {
- if (expression->nChildren() != 1) {
- SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
- return 0;
- }
- SGSharedPtr<SGExpression<T> > inputExpression;
- inputExpression = SGReadFExpression<T>(inputRoot, expression->getChild(0));
- if (!inputExpression) {
- SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
- return 0;
- }
- return new SGSinhExpression<T>(inputExpression);
- }
-
- if (name == "sqrt") {
- if (expression->nChildren() != 1) {
- SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
- return 0;
- }
- SGSharedPtr<SGExpression<T> > inputExpression;
- inputExpression = SGReadFExpression<T>(inputRoot, expression->getChild(0));
- if (!inputExpression) {
- SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
- return 0;
- }
- return new SGSqrtExpression<T>(inputExpression);
- }
-
- if (name == "tan") {
- if (expression->nChildren() != 1) {
- SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
- return 0;
- }
- SGSharedPtr<SGExpression<T> > inputExpression;
- inputExpression = SGReadFExpression<T>(inputRoot, expression->getChild(0));
- if (!inputExpression) {
- SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
- return 0;
- }
- return new SGTanExpression<T>(inputExpression);
- }
-
- if (name == "tanh") {
- if (expression->nChildren() != 1) {
- SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
- return 0;
- }
- SGSharedPtr<SGExpression<T> > inputExpression;
- inputExpression = SGReadFExpression<T>(inputRoot, expression->getChild(0));
- if (!inputExpression) {
- SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
- return 0;
- }
- return new SGTanhExpression<T>(inputExpression);
- }
-
-// if (name == "table") {
-// }
+ SGExpression<T>* r = SGReadIExpression<T>(inputRoot, expression);
+ if (r)
+ return r;
+
+ if (!expression)
+ return 0;
+
+ std::string name = expression->getName();
+ if (name == "acos") {
+ if (expression->nChildren() != 1) {
+ SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
+ return 0;
+ }
+ SGSharedPtr<SGExpression<T> > inputExpression;
+ inputExpression = SGReadFExpression<T>(inputRoot, expression->getChild(0));
+ if (!inputExpression) {
+ SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
+ return 0;
+ }
+ return new SGACosExpression<T>(inputExpression);
+ }
+
+ if (name == "asin") {
+ if (expression->nChildren() != 1) {
+ SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
+ return 0;
+ }
+ SGSharedPtr<SGExpression<T> > inputExpression;
+ inputExpression = SGReadFExpression<T>(inputRoot, expression->getChild(0));
+ if (!inputExpression) {
+ SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
+ return 0;
+ }
+ return new SGASinExpression<T>(inputExpression);
+ }
+
+ if (name == "atan") {
+ if (expression->nChildren() != 1) {
+ SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
+ return 0;
+ }
+ SGSharedPtr<SGExpression<T> > inputExpression;
+ inputExpression = SGReadFExpression<T>(inputRoot, expression->getChild(0));
+ if (!inputExpression) {
+ SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
+ return 0;
+ }
+ return new SGATanExpression<T>(inputExpression);
+ }
+
+ if (name == "ceil") {
+ if (expression->nChildren() != 1) {
+ SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
+ return 0;
+ }
+ SGSharedPtr<SGExpression<T> > inputExpression;
+ inputExpression = SGReadFExpression<T>(inputRoot, expression->getChild(0));
+ if (!inputExpression) {
+ SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
+ return 0;
+ }
+ return new SGCeilExpression<T>(inputExpression);
+ }
+
+ if (name == "cos") {
+ if (expression->nChildren() != 1) {
+ SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
+ return 0;
+ }
+ SGSharedPtr<SGExpression<T> > inputExpression;
+ inputExpression = SGReadFExpression<T>(inputRoot, expression->getChild(0));
+ if (!inputExpression) {
+ SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
+ return 0;
+ }
+ return new SGCosExpression<T>(inputExpression);
+ }
+
+ if (name == "cosh") {
+ if (expression->nChildren() != 1) {
+ SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
+ return 0;
+ }
+ SGSharedPtr<SGExpression<T> > inputExpression;
+ inputExpression = SGReadFExpression<T>(inputRoot, expression->getChild(0));
+ if (!inputExpression) {
+ SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
+ return 0;
+ }
+ return new SGCoshExpression<T>(inputExpression);
+ }
+
+ if (name == "deg2rad") {
+ if (expression->nChildren() != 1) {
+ SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
+ return 0;
+ }
+ SGSharedPtr<SGExpression<T> > inputExpression;
+ inputExpression = SGReadFExpression<T>(inputRoot, expression->getChild(0));
+ if (!inputExpression) {
+ SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
+ return 0;
+ }
+ return new SGScaleExpression<T>(inputExpression, SGMisc<T>::pi()/180);
+ }
+
+ if (name == "exp") {
+ if (expression->nChildren() != 1) {
+ SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
+ return 0;
+ }
+ SGSharedPtr<SGExpression<T> > inputExpression;
+ inputExpression = SGReadFExpression<T>(inputRoot, expression->getChild(0));
+ if (!inputExpression) {
+ SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
+ return 0;
+ }
+ return new SGExpExpression<T>(inputExpression);
+ }
+
+ if (name == "floor") {
+ if (expression->nChildren() != 1) {
+ SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
+ return 0;
+ }
+ SGSharedPtr<SGExpression<T> > inputExpression;
+ inputExpression = SGReadFExpression<T>(inputRoot, expression->getChild(0));
+ if (!inputExpression) {
+ SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
+ return 0;
+ }
+ return new SGFloorExpression<T>(inputExpression);
+ }
+
+ if (name == "log") {
+ if (expression->nChildren() != 1) {
+ SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
+ return 0;
+ }
+ SGSharedPtr<SGExpression<T> > inputExpression;
+ inputExpression = SGReadFExpression<T>(inputRoot, expression->getChild(0));
+ if (!inputExpression) {
+ SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
+ return 0;
+ }
+ return new SGLogExpression<T>(inputExpression);
+ }
+
+ if (name == "log10") {
+ if (expression->nChildren() != 1) {
+ SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
+ return 0;
+ }
+ SGSharedPtr<SGExpression<T> > inputExpression;
+ inputExpression = SGReadFExpression<T>(inputRoot, expression->getChild(0));
+ if (!inputExpression) {
+ SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
+ return 0;
+ }
+ return new SGLog10Expression<T>(inputExpression);
+ }
+
+ if (name == "rad2deg") {
+ if (expression->nChildren() != 1) {
+ SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
+ return 0;
+ }
+ SGSharedPtr<SGExpression<T> > inputExpression;
+ inputExpression = SGReadFExpression<T>(inputRoot, expression->getChild(0));
+ if (!inputExpression) {
+ SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
+ return 0;
+ }
+ return new SGScaleExpression<T>(inputExpression, 180/SGMisc<T>::pi());
+ }
+
+ if (name == "sin") {
+ if (expression->nChildren() != 1) {
+ SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
+ return 0;
+ }
+ SGSharedPtr<SGExpression<T> > inputExpression;
+ inputExpression = SGReadFExpression<T>(inputRoot, expression->getChild(0));
+ if (!inputExpression) {
+ SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
+ return 0;
+ }
+ return new SGSinExpression<T>(inputExpression);
+ }
+
+ if (name == "sinh") {
+ if (expression->nChildren() != 1) {
+ SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
+ return 0;
+ }
+ SGSharedPtr<SGExpression<T> > inputExpression;
+ inputExpression = SGReadFExpression<T>(inputRoot, expression->getChild(0));
+ if (!inputExpression) {
+ SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
+ return 0;
+ }
+ return new SGSinhExpression<T>(inputExpression);
+ }
+
+ if (name == "sqrt") {
+ if (expression->nChildren() != 1) {
+ SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
+ return 0;
+ }
+ SGSharedPtr<SGExpression<T> > inputExpression;
+ inputExpression = SGReadFExpression<T>(inputRoot, expression->getChild(0));
+ if (!inputExpression) {
+ SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
+ return 0;
+ }
+ return new SGSqrtExpression<T>(inputExpression);
+ }
+
+ if (name == "tan") {
+ if (expression->nChildren() != 1) {
+ SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
+ return 0;
+ }
+ SGSharedPtr<SGExpression<T> > inputExpression;
+ inputExpression = SGReadFExpression<T>(inputRoot, expression->getChild(0));
+ if (!inputExpression) {
+ SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
+ return 0;
+ }
+ return new SGTanExpression<T>(inputExpression);
+ }
+
+ if (name == "tanh") {
+ if (expression->nChildren() != 1) {
+ SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
+ return 0;
+ }
+ SGSharedPtr<SGExpression<T> > inputExpression;
+ inputExpression = SGReadFExpression<T>(inputRoot, expression->getChild(0));
+ if (!inputExpression) {
+ SG_LOG(SG_IO, SG_ALERT, "Cannot read \"" << name << "\" expression.");
+ return 0;
+ }
+ return new SGTanhExpression<T>(inputExpression);
+ }
+