Purpose: Config file read-in class and XML parser
Called by: Various
- ------------- Copyright (C) 2001 Jon S. Berndt (jsb@hal-pc.org) -------------
+ ------------- Copyright (C) 2001 Jon S. Berndt (jon@jsbsim.org) -------------
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free Software
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
#include "FGXMLParse.h"
-#include <stdlib.h>
+#include "FGXMLElement.h"
+#include <string>
+#include <iostream>
+#include <cstdlib>
+#include "input_output/string_utilities.h"
+
+using namespace std;
namespace JSBSim {
-static const char *IdSrc = "$Id$";
+static const char *IdSrc = "$Id: FGXMLParse.cpp,v 1.11 2010/09/28 02:54:03 jberndt Exp $";
static const char *IdHdr = ID_XMLPARSE;
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void FGXMLParse::endElement (const char * name)
{
- string local_work_string;
-
- while (!working_string.empty()) {
- // clear leading newlines and spaces
- string::size_type pos = working_string.find_first_not_of( " \n");
- if (pos > 0)
- working_string.erase(0, pos);
-
- // remove spaces (only) from end of string
- pos = working_string.find_last_not_of( " ");
- if (pos != string::npos)
- working_string.erase( ++pos);
-
- if (!working_string.empty()) {
- pos = working_string.find("\n");
- if (pos != string::npos) local_work_string = working_string.substr(0,pos);
- else local_work_string = working_string;
- current_element->AddData(local_work_string);
- working_string.erase(0, pos);
- }
+ if (!working_string.empty()) {
+ vector <string> work_strings = split(working_string, '\n');
+ for (unsigned int i=0; i<work_strings.size(); i++) current_element->AddData(work_strings[i]);
}
current_element = current_element->GetParent();