1
0
Fork 0

Fix Traffic Manager XML parser

This commit is contained in:
fredb 2008-06-01 11:56:32 +00:00
parent 61dc8df110
commit af879b8310
2 changed files with 7 additions and 6 deletions

View file

@ -231,12 +231,16 @@ void FGTrafficManager::startElement (const char * name, const XMLAttributes &at
path.append(attval); path.append(attval);
readXML(path.str(), *this); readXML(path.str(), *this);
} }
elementValueStack.push_back( "" );
// cout << " " << atts.getName(i) << '=' << atts.getValue(i) << endl; // cout << " " << atts.getName(i) << '=' << atts.getValue(i) << endl;
} }
void FGTrafficManager::endElement (const char * name) { void FGTrafficManager::endElement (const char * name) {
//cout << "End element " << name << endl; //cout << "End element " << name << endl;
string element(name); string element(name);
string value = elementValueStack.back();
elementValueStack.pop_back();
if (element == string("model")) if (element == string("model"))
mdl = value; mdl = value;
else if (element == string("livery")) else if (element == string("livery"))
@ -342,10 +346,7 @@ void FGTrafficManager::endElement (const char * name) {
void FGTrafficManager::data (const char * s, int len) { void FGTrafficManager::data (const char * s, int len) {
string token = string(s,len); string token = string(s,len);
//cout << "Character data " << string(s,len) << endl; //cout << "Character data " << string(s,len) << endl;
if ((token.find(" ") == string::npos && (token.find('\n')) == string::npos)) elementValueStack.back() += token;
value += token;
else
value = string("");
} }
void FGTrafficManager::pi (const char * target, const char * data) { void FGTrafficManager::pi (const char * target, const char * data) {

View file

@ -43,7 +43,7 @@ class FGTrafficManager : public SGSubsystem, public XMLVisitor
private: private:
ScheduleVector scheduledAircraft; ScheduleVector scheduledAircraft;
ScheduleVectorIterator currAircraft, currAircraftClosest; ScheduleVectorIterator currAircraft, currAircraftClosest;
string value; vector<string> elementValueStack;
string mdl, livery, registration, callsign, fltrules, string mdl, livery, registration, callsign, fltrules,
port, timeString, departurePort, departureTime, arrivalPort, arrivalTime, port, timeString, departurePort, departureTime, arrivalPort, arrivalTime,