]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/JSBSim/input_output/FGXMLParse.cpp
remove unused files
[flightgear.git] / src / FDM / JSBSim / input_output / FGXMLParse.cpp
old mode 100755 (executable)
new mode 100644 (file)
index 6be5bf9..22d30a2
@@ -1,21 +1,46 @@
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
- Header:       FGXMLParse.h
+ Header:       FGXMLParse.cpp
  Author:       Jon Berndt
  Date started: 08/20/2004
  Purpose:      Config file read-in class and XML parser
  Called by:    Various
 
+ ------------- 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
+ Foundation; either version 2 of the License, or (at your option) any later
+ version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
+ details.
+
+ You should have received a copy of the GNU Lesser General Public License along with
+ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ Place - Suite 330, Boston, MA  02111-1307, USA.
+
+ Further information about the GNU Lesser General Public License can also be found on
+ the world wide web at http://www.gnu.org.
+
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 INCLUDES
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
 
 #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;
 
 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -36,7 +61,7 @@ FGXMLParse::FGXMLParse(void)
 
 FGXMLParse::~FGXMLParse(void)
 {
-  if (document) delete document;
+  delete document;
 }
 
 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -49,7 +74,7 @@ void FGXMLParse::startXML(void)
 
 void FGXMLParse::reset(void)
 {
-  if (document) delete document;
+  delete document;
   first_element_read = false;
   current_element = document = 0L;
 }
@@ -95,29 +120,9 @@ void FGXMLParse::startElement (const char * name, const XMLAttributes &atts)
 
 void FGXMLParse::endElement (const char * name)
 {
-  int size, pos;
-  string local_work_string;
-
-  while (!working_string.empty()) {
-     // clear leading newlines and spaces
-    while (working_string[0] == '\n' || working_string[0] == ' ')
-      working_string.erase(0,1);
-
-    // remove spaces (only) from end of string
-    size = working_string.size();
-    while (working_string[size-1] == ' ')
-    {
-      working_string.erase(size-1,1);
-      size = working_string.size();
-    }
-
-    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();