# XmlParser.hh

Go to the documentation of this file.

    00001 // -*- mode:C++ ; tab-width:4 ; c-basic-offset:4 ; indent-tabs-mode:nil -*-
    00002 // ----------------------------------------------------------------------------
    00003 // CERTI - HLA RunTime Infrastructure
    00004 // Copyright (C) 2003  ONERA
    00005 //
    00006 // This file is part of CERTI-libCERTI
    00007 //
    00008 // CERTI-libCERTI is free software ; you can redistribute it and/or
    00009 // modify it under the terms of the GNU Lesser General Public License
    00010 // as published by the Free Software Foundation ; either version 2 of
    00011 // the License, or (at your option) any later version.
    00012 //
    00013 // CERTI-libCERTI is distributed in the hope that it will be useful, but
    00014 // WITHOUT ANY WARRANTY ; without even the implied warranty of
    00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    00016 // Lesser General Public License for more details.
    00017 //
    00018 // You should have received a copy of the GNU Lesser General Public
    00019 // License along with this program ; if not, write to the Free Software
    00020 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
    00021 // USA
    00022 //
    00023 // $Id: XmlParser.hh,v 3.12 2007/08/31 13:43:20 erk Exp $
    00024 // ----------------------------------------------------------------------------
    00025
    00026 #ifndef _CERTI_XML_PARSER_HH
    00027 #define _CERTI_XML_PARSER_HH
    00028
    00029 // Project
    00030 #include "RootObject.hh"
    00031 #include "ObjectClass.hh"
    00032 #include "Interaction.hh"
    00033
    00034 // Libraries
    00035 #ifdef HAVE_XML
    00036 #include <libxml/xmlmemory.h>
    00037 #include <libxml/parser.h>
    00038 #endif
    00039
    00040 // Standard libraries
    00041 #include <string>
    00042
    00043 namespace certi {
    00044
    00048 class CERTI_EXPORT XmlParser
    00049 {
    00050 public:
    00051
    00056     XmlParser(RootObject* root);
    00057
    00063     RootObject* parse(std::string pathToXmlFile);
    00064
    00072     static bool exists(void);
    00073
    00074 #if HAVE_XML
    00075
    00079     class CleanXmlGetProp {
    00080     public:
    00087         CleanXmlGetProp(_xmlNode* node, const xmlChar* propName) {
    00088             prop = xmlGetProp(node,propName);
    00089         }
    00093         operator const char*() {
    00094             return reinterpret_cast<const char*>(prop);
    00095         }
    00096
    00097         ~CleanXmlGetProp(){
    00098             xmlFree(prop);
    00099         }
    00100     private:
    00101         xmlChar* prop;
    00102     };
    00103 #endif
    00104 private:
    00109     void parseClass(ObjectClass *parent);
    00110
    00115     void parseInteraction(Interaction *parent);
    00116
    00120     void parseRoutingSpace(void);
    00121
    00122     int freeObjectClassHandle ;
    00123     int freeInteractionClassHandle ;
    00124     int freeAttributeHandle ;
    00125     int freeParameterHandle ;
    00126     int freeSpaceHandle ;
    00127
    00128     std::string filename ;
    00129     RootObject* root ;
    00130
    00131 #ifdef HAVE_XML
    00132     xmlDocPtr  doc;
    00133     xmlNodePtr cur;
    00134 #endif
    00135 };
    00136
    00137 } // namespace certi
    00138
    00139 #endif // _CERTI_XML_PARSER_HH
    00140
    00141 // $Id: XmlParser.hh,v 3.12 2007/08/31 13:43:20 erk Exp $