%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include "FGSwitch.h"
+#include <iostream>
+#include <cstdlib>
+
+using namespace std;
namespace JSBSim {
-static const char *IdSrc = "$Id$";
+static const char *IdSrc = "$Id: FGSwitch.cpp,v 1.19 2009/10/24 22:59:30 jberndt Exp $";
static const char *IdHdr = ID_SWITCH;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
cerr << "Unrecognized LOGIC token " << logic << " in switch component: " << Name << endl;
}
for (unsigned int i=0; i<test_element->GetNumDataLines(); i++) {
- current_test->conditions.push_back(new FGCondition(test_element->GetDataLine(i), PropertyManager));
+ string input_data = test_element->GetDataLine(i);
+ if (input_data.size() <= 1) {
+ // Make sure there are no bad data lines that consist solely of whitespace
+ cerr << fgred << " Bad data line in switch component: " << Name << reset << endl;
+ continue;
+ }
+ current_test->conditions.push_back(new FGCondition(input_data, PropertyManager));
}
condition_element = test_element->GetElement(); // retrieve condition groups
if (value.empty()) {
cerr << "No VALUE supplied for switch component: " << Name << endl;
} else {
- if (value.find_first_not_of("-.0123456789eE") == string::npos) {
- // if true (and execution falls into this block), "value" is a number.
+ if (is_number(value)) {
current_test->OutputVal = atof(value.c_str());
} else {
// "value" must be a property if execution passes to here.
}
cout << endl;
}
- if (IsOutput) cout << " OUTPUT: " << OutputNode->getName() << endl;
+ if (IsOutput) {
+ for (unsigned int i=0; i<OutputNodes.size(); i++)
+ cout << " OUTPUT: " << OutputNodes[i]->getName() << endl;
+ }
}
}
if (debug_lvl & 2 ) { // Instantiation/Destruction notification