LCOV - code coverage report
Current view: top level - input_output - FGXMLParse.cpp (source / functions) Hit Total Coverage
Test: JSBSim-Coverage-Statistics Lines: 42 49 85.7 %
Date: 2010-08-24 Functions: 11 16 68.8 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 16 28 57.1 %

           Branch data     Line data    Source code
       1                 :            : /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       2                 :            : 
       3                 :            :  Header:       FGXMLParse.cpp
       4                 :            :  Author:       Jon Berndt
       5                 :            :  Date started: 08/20/2004
       6                 :            :  Purpose:      Config file read-in class and XML parser
       7                 :            :  Called by:    Various
       8                 :            : 
       9                 :            :  ------------- Copyright (C) 2001  Jon S. Berndt (jon@jsbsim.org) -------------
      10                 :            : 
      11                 :            :  This program is free software; you can redistribute it and/or modify it under
      12                 :            :  the terms of the GNU Lesser General Public License as published by the Free Software
      13                 :            :  Foundation; either version 2 of the License, or (at your option) any later
      14                 :            :  version.
      15                 :            : 
      16                 :            :  This program is distributed in the hope that it will be useful, but WITHOUT
      17                 :            :  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
      18                 :            :  FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
      19                 :            :  details.
      20                 :            : 
      21                 :            :  You should have received a copy of the GNU Lesser General Public License along with
      22                 :            :  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
      23                 :            :  Place - Suite 330, Boston, MA  02111-1307, USA.
      24                 :            : 
      25                 :            :  Further information about the GNU Lesser General Public License can also be found on
      26                 :            :  the world wide web at http://www.gnu.org.
      27                 :            : 
      28                 :            : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      29                 :            : INCLUDES
      30                 :            : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
      31                 :            : 
      32                 :            : #include "FGXMLParse.h"
      33                 :            : #include "FGXMLElement.h"
      34                 :            : #include <string>
      35                 :            : #include <iostream>
      36                 :            : #include <cstdlib>
      37                 :            : #include "input_output/string_utilities.h"
      38                 :            : 
      39                 :            : using namespace std;
      40                 :            : 
      41                 :            : namespace JSBSim {
      42                 :            : 
      43                 :            : static const char *IdSrc = "$Id: FGXMLParse.cpp,v 1.10 2009/10/24 22:59:30 jberndt Exp $";
      44                 :            : static const char *IdHdr = ID_XMLPARSE;
      45                 :            : 
      46                 :            : /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      47                 :            : CLASS IMPLEMENTATION
      48                 :            : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
      49                 :            : 
      50                 :            : #include "FGXMLParse.h"
      51                 :            : 
      52                 :            : using namespace std;
      53                 :            : 
      54                 :         20 : FGXMLParse::FGXMLParse(void)
      55                 :            : {
      56                 :         20 :   first_element_read = false;
      57                 :         20 :   current_element = document = 0L;
      58                 :         20 : }
      59                 :            : 
      60                 :            : //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      61                 :            : 
      62                 :         20 : FGXMLParse::~FGXMLParse(void)
      63                 :            : {
      64 [ #  # ][ +  + ]:         20 :   delete document;
                 [ #  # ]
      65 [ #  # ][ -  + ]:         20 : }
                 [ #  # ]
      66                 :            : 
      67                 :            : //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      68                 :            : 
      69                 :         31 : void FGXMLParse::startXML(void)
      70                 :            : {
      71                 :         31 : }
      72                 :            : 
      73                 :            : //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      74                 :            : 
      75                 :         16 : void FGXMLParse::reset(void)
      76                 :            : {
      77         [ +  - ]:         16 :   delete document;
      78                 :         16 :   first_element_read = false;
      79                 :         16 :   current_element = document = 0L;
      80                 :         16 : }
      81                 :            : 
      82                 :            : //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      83                 :            : 
      84                 :          0 : void FGXMLParse::endXML(void)
      85                 :            : {
      86                 :            :   // At this point, document should equal current_element ?
      87                 :          0 : }
      88                 :            : 
      89                 :            : //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      90                 :            : 
      91                 :        930 : void FGXMLParse::startElement (const char * name, const XMLAttributes &atts)
      92                 :            : {
      93                 :        930 :   string Name(name);
      94                 :            :   Element *temp_element;
      95                 :            : 
      96                 :        930 :   working_string.erase();
      97                 :            : 
      98         [ +  + ]:        930 :   if (!first_element_read) {
      99                 :         31 :     document = new Element(Name);
     100                 :         31 :     current_element = document;
     101                 :         31 :     first_element_read = true;
     102                 :            :   } else {
     103                 :        899 :     temp_element = new Element(Name);
     104                 :        899 :     temp_element->SetParent(current_element);
     105                 :        899 :     current_element->AddChildElement(temp_element);
     106                 :        899 :     current_element = temp_element;
     107                 :            :   }
     108                 :            : 
     109         [ -  + ]:        930 :   if (current_element == 0L) {
     110                 :          0 :     cerr << "No current element read (no top-level element in XML file?)" << endl;
     111                 :          0 :     exit (-1);
     112                 :            :   }
     113                 :            : 
     114         [ +  + ]:       1443 :   for (int i=0; i<atts.size();i++) {
     115                 :        513 :     current_element->AddAttribute(atts.getName(i), atts.getValue(i));
     116                 :        930 :   }
     117                 :        930 : }
     118                 :            : 
     119                 :            : //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     120                 :            : 
     121                 :        930 : void FGXMLParse::endElement (const char * name)
     122                 :            : {
     123         [ +  + ]:        930 :   if (!working_string.empty()) {
     124                 :        880 :     vector <string> work_strings = split(working_string, '\n');
     125         [ +  + ]:       2566 :     for (int i=0; i<work_strings.size(); i++) current_element->AddData(work_strings[i]);
     126                 :            :   }
     127                 :            : 
     128                 :       1860 :   current_element = current_element->GetParent();
     129                 :        930 : }
     130                 :            : 
     131                 :            : //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     132                 :            : 
     133                 :       4001 : void FGXMLParse::data (const char * s, int length)
     134                 :            : {
     135                 :       8002 :   working_string += string(s, length);
     136                 :       4001 : }
     137                 :            : 
     138                 :            : //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     139                 :            : 
     140                 :          2 : void FGXMLParse::pi (const char * target, const char * data)
     141                 :            : {
     142                 :          2 : }
     143                 :            : 
     144                 :            : //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     145                 :            : 
     146                 :          0 : void FGXMLParse::warning (const char * message, int line, int column)
     147                 :            : {
     148                 :          0 :   cerr << "Warning: " << message << " line: " << line << " column: " << column << endl;
     149                 :          0 : }
     150                 :            : 
     151 [ +  + ][ +  - ]:         12 : } // end namespace JSBSim

Generated by: LCOV version 1.9