]> git.mxchange.org Git - simgear.git/blobdiff - simgear/props/condition.cxx
Cleanup of properties
[simgear.git] / simgear / props / condition.cxx
index 7dbc27cc539891a8f2526108c31ccf5ac104f78f..db06d8dbbfe93d7da20a7792af0e64af02d0d7d0 100644 (file)
 #  include <simgear/compiler.h>
 #endif
 
-// #include STL_IOSTREAM
+// #include <iostream>
 
 #include <simgear/structure/exception.hxx>
 
 #include "props.hxx"
 #include "condition.hxx"
 
-SG_USING_STD(istream);
-SG_USING_STD(ostream);
+using std::istream;
+using std::ostream;
 
 
 
@@ -144,8 +144,9 @@ SGOrCondition::addCondition (SGCondition * condition)
 static int
 doComparison (const SGPropertyNode * left, const SGPropertyNode *right)
 {
+  using namespace simgear::props;
   switch (left->getType()) {
-  case SGPropertyNode::BOOL: {
+  case BOOL: {
     bool v1 = left->getBoolValue();
     bool v2 = right->getBoolValue();
     if (v1 < v2)
@@ -156,7 +157,7 @@ doComparison (const SGPropertyNode * left, const SGPropertyNode *right)
       return SGComparisonCondition::EQUALS;
     break;
   }
-  case SGPropertyNode::INT: {
+  case INT: {
     int v1 = left->getIntValue();
     int v2 = right->getIntValue();
     if (v1 < v2)
@@ -167,7 +168,7 @@ doComparison (const SGPropertyNode * left, const SGPropertyNode *right)
       return SGComparisonCondition::EQUALS;
     break;
   }
-  case SGPropertyNode::LONG: {
+  case LONG: {
     long v1 = left->getLongValue();
     long v2 = right->getLongValue();
     if (v1 < v2)
@@ -178,7 +179,7 @@ doComparison (const SGPropertyNode * left, const SGPropertyNode *right)
       return SGComparisonCondition::EQUALS;
     break;
   }
-  case SGPropertyNode::FLOAT: {
+  case FLOAT: {
     float v1 = left->getFloatValue();
     float v2 = right->getFloatValue();
     if (v1 < v2)
@@ -189,7 +190,7 @@ doComparison (const SGPropertyNode * left, const SGPropertyNode *right)
       return SGComparisonCondition::EQUALS;
     break;
   }
-  case SGPropertyNode::DOUBLE: {
+  case DOUBLE: {
     double v1 = left->getDoubleValue();
     double v2 = right->getDoubleValue();
     if (v1 < v2)
@@ -200,9 +201,9 @@ doComparison (const SGPropertyNode * left, const SGPropertyNode *right)
       return SGComparisonCondition::EQUALS;
     break;
   }
-  case SGPropertyNode::STRING: 
-  case SGPropertyNode::NONE:
-  case SGPropertyNode::UNSPECIFIED: {
+  case STRING:
+  case NONE:
+  case UNSPECIFIED: {
     string v1 = left->getStringValue();
     string v2 = right->getStringValue();
     if (v1 < v2)
@@ -213,8 +214,10 @@ doComparison (const SGPropertyNode * left, const SGPropertyNode *right)
       return SGComparisonCondition::EQUALS;
     break;
   }
+  default:
+    throw sg_exception("condition: unrecognized node type in comparison");
   }
-  throw sg_exception("Unrecognized node type");
+  
   return 0;
 }
 
@@ -299,7 +302,7 @@ readNotCondition( SGPropertyNode *prop_root, const SGPropertyNode *node )
     if (condition != 0)
       return new SGNotCondition(condition);
   }
-  SG_LOG(SG_COCKPIT, SG_ALERT, "Panel: empty 'not' condition");
+  SG_LOG(SG_COCKPIT, SG_ALERT, "empty 'not' condition");
   return 0;
 }
 
@@ -341,8 +344,10 @@ readComparison( SGPropertyNode *prop_root,
   condition->setLeftProperty(prop_root, node->getStringValue("property[0]"));
   if (node->hasValue("property[1]"))
     condition->setRightProperty(prop_root, node->getStringValue("property[1]"));
-  else
+  else if (node->hasValue("value"))
     condition->setRightValue(node->getChild("value", 0));
+  else
+    throw sg_exception("condition: comparison without property[1] or value");
 
   return condition;
 }