From: Jon S. B. <jb...@us...> - 2009-06-13 02:42:03
|
Update of /cvsroot/jsbsim/JSBSim/src/math In directory fdv4jf1.ch3.sourceforge.com:/tmp/cvs-serv1514/src/math Modified Files: FGCondition.cpp Log Message: Added a string utilities header file that adds string handling conveniences such as trim, is_number, split, etc.; these new capabilities have been incorporated into the source code where the string::find() functions were formerly used.; The socket /FGInput features have also been slightly refined. Index: FGCondition.cpp =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/src/math/FGCondition.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -r1.6 -r1.7 *** FGCondition.cpp 17 Feb 2008 18:24:32 -0000 1.6 --- FGCondition.cpp 13 Jun 2009 02:41:58 -0000 1.7 *************** *** 36,39 **** --- 36,40 ---- #include "FGCondition.h" + #include <vector> namespace JSBSim { *************** *** 88,92 **** //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! //This constructor is called when there are no nested test groups inside the // condition --- 89,93 ---- //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! // This constructor is called when there are no nested test groups inside the // condition *************** *** 95,98 **** --- 96,100 ---- { string property1, property2, compare_string; + vector <string> test_strings; InitializeConditionals(); *************** *** 104,121 **** conditions.clear(); ! unsigned int start = 0, end = 0; ! start = test.find_first_not_of(" "); ! end = test.find_first_of(" ", start+1); ! property1 = test.substr(start,end-start); ! start = test.find_first_not_of(" ",end); ! end = test.find_first_of(" ",start+1); ! conditional = test.substr(start,end-start); ! start = test.find_first_not_of(" ",end); ! end = test.find_first_of(" ",start+1); ! property2 = test.substr(start,end-start); TestParam1 = PropertyManager->GetNode(property1, true); Comparison = mComparison[conditional]; ! if (property2.find_first_not_of("-.0123456789eE") == string::npos) { TestValue = atof(property2.c_str()); } else { --- 106,124 ---- conditions.clear(); ! test_strings = split(test, ' '); ! if (test_strings.size() == 3) { ! property1 = test_strings[0]; ! conditional = test_strings[1]; ! property2 = test_strings[2]; ! } else { ! cerr << endl << " Conditional test is invalid: \"" << test ! << "\" has " << test_strings.size() << " elements in the " ! << "test condition." << endl; ! exit(-1); ! } TestParam1 = PropertyManager->GetNode(property1, true); Comparison = mComparison[conditional]; ! if (is_number(property2)) { TestValue = atof(property2.c_str()); } else { |