X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fprops%2Fcondition.cxx;h=7a382cd30ee44a66985ec9ab01742109bd39f81c;hb=c958d6389731cb80fc192e04391d8585f1ef729d;hp=a633cacd33e318f80b71df3081ffec0d0de4afe6;hpb=2e078aff7d3c926d8e7fa13ccc180fc5497dd0d5;p=simgear.git diff --git a/simgear/props/condition.cxx b/simgear/props/condition.cxx index a633cacd..7a382cd3 100644 --- a/simgear/props/condition.cxx +++ b/simgear/props/condition.cxx @@ -11,15 +11,15 @@ # include #endif -// #include STL_IOSTREAM +// #include #include #include "props.hxx" #include "condition.hxx" -SG_USING_STD(istream); -SG_USING_STD(ostream); +using std::istream; +using std::ostream; @@ -65,7 +65,6 @@ SGNotCondition::SGNotCondition (SGCondition * condition) SGNotCondition::~SGNotCondition () { - delete _condition; } bool @@ -86,8 +85,6 @@ SGAndCondition::SGAndCondition () SGAndCondition::~SGAndCondition () { - for (unsigned int i = 0; i < _conditions.size(); i++) - delete _conditions[i]; } bool @@ -119,8 +116,6 @@ SGOrCondition::SGOrCondition () SGOrCondition::~SGOrCondition () { - for (unsigned int i = 0; i < _conditions.size(); i++) - delete _conditions[i]; } bool @@ -218,8 +213,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; } @@ -304,7 +301,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; } @@ -346,8 +343,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; } @@ -398,13 +397,11 @@ SGConditional::SGConditional () SGConditional::~SGConditional () { - delete _condition; } void SGConditional::setCondition (SGCondition * condition) { - delete _condition; _condition = condition; }