LCOV - code coverage report
Current view: top level - input_output - FGXMLFileRead.h (source / functions) Hit Total Coverage
Test: JSBSim-Coverage-Statistics Lines: 12 17 70.6 %
Date: 2010-08-24 Functions: 0 1 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 4 6 66.7 %

           Branch data     Line data    Source code
       1                 :            : /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
       2                 :            : 
       3                 :            :  Module:       FGXMLFileRead.h
       4                 :            :  Author:       Jon S. Berndt
       5                 :            :  Date started: 02/04/07
       6                 :            :  Purpose:      Shared base class that wraps the XML file reading logic
       7                 :            : 
       8                 :            :  ------------- Copyright (C) 2007  Jon S. Berndt (jon@jsbsim.org) -------------
       9                 :            : 
      10                 :            :  This program is free software; you can redistribute it and/or modify it under
      11                 :            :  the terms of the GNU Lesser General Public License as published by the Free Software
      12                 :            :  Foundation; either version 2 of the License, or (at your option) any later
      13                 :            :  version.
      14                 :            : 
      15                 :            :  This program is distributed in the hope that it will be useful, but WITHOUT
      16                 :            :  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
      17                 :            :  FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
      18                 :            :  details.
      19                 :            : 
      20                 :            :  You should have received a copy of the GNU Lesser General Public License along with
      21                 :            :  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
      22                 :            :  Place - Suite 330, Boston, MA  02111-1307, USA.
      23                 :            : 
      24                 :            :  Further information about the GNU Lesser General Public License can also be found on
      25                 :            :  the world wide web at http://www.gnu.org.
      26                 :            : 
      27                 :            : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      28                 :            : SENTRY
      29                 :            : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
      30                 :            : 
      31                 :            : #ifndef FGXMLFILEREAD_HEADER_H
      32                 :            : #define FGXMLFILEREAD_HEADER_H
      33                 :            : 
      34                 :            : /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      35                 :            : INCLUDES
      36                 :            : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
      37                 :            : 
      38                 :            : #include "input_output/FGXMLParse.h"
      39                 :            : #include <iostream>
      40                 :            : #include <fstream>
      41                 :            : 
      42                 :            : /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      43                 :            : DEFINITIONS
      44                 :            : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
      45                 :            : 
      46                 :            : #define ID_XMLFILEREAD "$Id: FGXMLFileRead.h,v 1.5 2009/11/28 20:12:47 andgi Exp $"
      47                 :            : 
      48                 :            : /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
      49                 :            : FORWARD DECLARATIONS
      50                 :            : %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
      51                 :            : 
      52                 :            : namespace JSBSim {
      53                 :            : 
      54                 :            : class FGXMLFileRead {
      55                 :            : public:
      56                 :         20 :   FGXMLFileRead(void) {}
      57                 :         20 :   ~FGXMLFileRead(void) {}
      58                 :            : 
      59                 :            : protected:
      60                 :            :   Element* document;
      61                 :          0 :   Element* LoadXMLDocument(std::string XML_filename)
      62                 :            :   {
      63                 :         31 :     std::ifstream infile;
      64                 :            : 
      65         [ +  - ]:         31 :     if ( !XML_filename.empty() ) {
      66         [ +  + ]:         31 :       if (XML_filename.find(".xml") == std::string::npos) XML_filename += ".xml";
      67                 :         31 :       infile.open(XML_filename.c_str());
      68         [ -  + ]:         31 :       if ( !infile.is_open()) {
      69                 :          0 :         std::cerr << "Could not open file: " << XML_filename << std::endl;
      70                 :          0 :         return 0L;
      71                 :            :       }
      72                 :            :     } else {
      73                 :          0 :       std::cerr << "No filename given." << std::endl;
      74                 :          0 :       return 0L;
      75                 :            :     }
      76                 :            : 
      77                 :         31 :     readXML(infile, file_parser, XML_filename);
      78                 :         62 :     document = file_parser.GetDocument();
      79                 :         31 :     infile.close();
      80                 :            :     
      81                 :         31 :     return document;
      82                 :            :   }
      83                 :            :   
      84                 :         16 :   void ResetParser(void) {file_parser.reset();}
      85                 :            : 
      86                 :            : private:
      87                 :            :   FGXMLParse file_parser;
      88                 :            : };
      89                 :            : }
      90                 :            : #endif

Generated by: LCOV version 1.9