ymlsaxparser.h

Go to the documentation of this file.
00001 /*******************************************************************\
00002 
00003                    SESAME project software license
00004 
00005               Copyright (C) 2002 University of Amsterdam
00006 
00007     This program is free software; you can redistribute it and/or
00008      modify it under the terms of the GNU General Public License
00009     as published by the Free Software Foundation; either version 2
00010         of the License, or (at your option) any later version.
00011 
00012    This program is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015              GNU General Public License for more details.
00016 
00017   You should have received a copy of the GNU General Public License
00018      along with this program; if not, write to the Free Software
00019       Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00020                            02111-1307, USA.
00021 
00022       For information regarding the SESAME software project see
00023               http://sesamesim.sourceforge.net or email
00024                     jcofflan@users.sourceforge.net
00025 
00026 \*******************************************************************/
00040 #ifndef YMLSAXPARSER_H
00041 #define YMLSAXPARSER_H
00042 
00043 #include "interpreter.h"
00044 #include "parsecall.h"
00045 #include <list>
00046 
00047 #include <xercesc/util/XercesDefs.hpp>
00048 #include <xercesc/sax2/DefaultHandler.hpp>
00049 
00050 #include <BasicUtils/BasicSmartPointer.h>
00051 
00052 class YMLSAXParser : public XERCES_CPP_NAMESPACE::DefaultHandler {
00053  public:
00054 
00056   Interpreter *interpreter;
00057 
00059   BasicSmartPointer<XMLCh, SP_ARRAY> text;
00060 
00062   int setDepth;
00063 
00064   typedef std::list<ParseCall *> parseCalls_t;
00066   parseCalls_t parseCalls;
00067 
00068 
00069  public:
00070   YMLSAXParser();
00071   virtual ~YMLSAXParser();
00072 
00080   void setInterpreter(Interpreter *interpreter)
00081   {this->interpreter = interpreter;}
00082 
00083   // YMLSAXParser Interface
00084   virtual void startNetwork(const char *name, const char *className) {}
00085   virtual void endNetwork() {}
00086   virtual void startNode(const char *name, const char *className) {}
00087   virtual void endNode() {}
00088   virtual void startLink(const char *object1, const char *port1,
00089                          const char *object2, const char *port2) {}
00090   virtual void endLink() {}
00091   virtual void startPort(const char *name, const char *dir) {}
00092   virtual void endPort() {}
00093   virtual void startProperty(const char *name, const char *value) {}
00094   virtual void endProperty() {}
00095   virtual void doc(const char *data) {}
00096   virtual void parseCall(call_t type, int argc, const char *const *args);
00097 
00098   // YMLSAXParser pre-processing functions
00099   void executeSet(parseCalls_t::iterator start);
00100   void startSet(const char *loop, const char *init, const char *cond);
00101   void endSet();
00102   void script(const char *data);
00103   const char *lookup(const char *);
00104   void lookupArgs(int argc, const char * const *args, const char **pargs);
00105   void localParseCall(call_t type, int argc, const char * const *args);
00106   void dispatch(call_t type, int argc, char **args);
00107   void clearText() {text = 0;}
00108 
00109   // Begin SAX2 interface
00110   void startDocument();
00111   void endDocument();
00112   void startElement(const XMLCh *const uri, const XMLCh *const localname,
00113                     const XMLCh *const qname,
00114                     const XERCES_CPP_NAMESPACE::Attributes &attributes);
00115   void endElement(const XMLCh *const uri, const XMLCh *const localname,
00116                   const XMLCh *const qname);
00117   void characters(const XMLCh *const chars, const unsigned int length);
00118 
00119 protected:
00120   void clearParseCalls();
00121 };
00122 #endif
00123 

Generated on Wed Apr 5 20:57:46 2006 for Sesame by  doxygen 1.4.6