1 // Copyright (C) 2006-2012 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef _PARSERBASE_HXX_
21 #define _PARSERBASE_HXX_
23 #include "YACSloaderExport.hxx"
34 struct YACSLOADER_EXPORT parser
36 static parser main_parser;
38 parser():_level(0),_defaultParsersMap(0)
40 _counts=new std::map<std::string,int>;
44 virtual void SetUserDataAndPush(parser* pp);
45 virtual void onStart(const XML_Char *el, const XML_Char** attr);
46 static void XMLCALL start(void *data, const XML_Char* el, const XML_Char** attr);
48 virtual void onEnd(const XML_Char *el,parser* child);
50 static void XMLCALL end(void *data, const char *el);
52 virtual void charData(const XML_Char *s, int len);
54 static void XMLCALL charac(void *data, const XML_Char *s, int len);
56 virtual void endParser();
60 virtual void incrCount(const XML_Char *el);
62 virtual void checkOrder(std::string& el);
64 virtual void maxcount(std::string name, int max, std::string& el);
66 virtual void mincount(std::string name,int min );
68 virtual void maxchoice(std::string *names, int max, std::string& el);
70 virtual void minchoice(std::string *names, int min);
72 virtual void pre(){_content="";};
73 virtual void required(const std::string& name, const XML_Char** attr);
75 virtual void buildAttr(const XML_Char** attr);
77 std::stack<parser*>& getStack();
82 void logError(const std::string& reason);
86 std::map<std::string,int> *_counts;
87 std::map<std::string,int> _orders;
90 std::stack<std::map<std::string,int>*> _stackCount;
91 std::stack<int> _stackOrder;
92 // OCC: san -- Allow external parsers for handling of unknown elements
93 // and attributes. This capability is used by YACS GUI to read
94 // graph presentation data
95 std::map<std::string,parser*> *_defaultParsersMap;