1 // Copyright (C) 2006-2016 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, or (at your option) any later version.
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 _LINKPARSERS_HXX_
21 #define _LINKPARSERS_HXX_
23 #include "parserBase.hxx"
24 #include "dataParsers.hxx"
25 #include "propertyParsers.hxx"
27 #include "factory.hxx"
31 template <class T=mycontrol>
32 struct controltypeParser: parser
34 static controltypeParser<T> controlParser;
36 virtual void onStart(const XML_Char* el, const XML_Char** attr)
38 std::string element(el);
39 parser* pp=&parser::main_parser;
40 this->maxcount("fromnode",1,element);
41 this->maxcount("tonode",1,element);
42 if(element == "fromnode")pp=&stringtypeParser::stringParser;
43 else if(element == "tonode")pp=&stringtypeParser::stringParser;
44 this->SetUserDataAndPush(pp);
49 virtual void onEnd(const char *el,parser* child)
51 std::string element(el);
52 if(element == "fromnode")fromnode(((stringtypeParser*)child)->post());
53 else if(element == "tonode")tonode(((stringtypeParser*)child)->post());
59 virtual void fromnode (const std::string& name)
63 virtual void tonode (const std::string& name)
67 virtual void property (const myprop& prop)
69 DEBTRACE( "property_set: " << prop._name << prop._value )
70 _link.setProperty(prop._name,prop._value);
74 mincount("fromnode",1);
81 template <class T=mylink>
82 struct linktypeParser: controltypeParser<T>
84 static linktypeParser<T> linkParser;
86 virtual void onStart(const XML_Char* el, const XML_Char** attr)
88 std::string element(el);
89 this->maxcount("fromnode",1,element);
90 this->maxcount("tonode",1,element);
91 this->maxcount("fromport",1,element);
92 this->maxcount("toport",1,element);
93 parser* pp=&parser::main_parser;
94 if(element == "fromnode")pp=&stringtypeParser::stringParser;
95 else if(element == "tonode")pp=&stringtypeParser::stringParser;
96 else if(element == "toport")pp=&stringtypeParser::stringParser;
97 else if(element == "fromport")pp=&stringtypeParser::stringParser;
98 else if(element == "property")pp=&propertytypeParser::propertyParser;
99 this->SetUserDataAndPush(pp);
104 virtual void onEnd(const char *el,parser* child)
106 std::string element(el);
107 if(element == "fromnode")this->fromnode(((stringtypeParser*)child)->post());
108 else if(element == "tonode")this->tonode(((stringtypeParser*)child)->post());
109 else if(element == "toport")toport(((stringtypeParser*)child)->post());
110 else if(element == "fromport")fromport(((stringtypeParser*)child)->post());
111 else if(element == "property")this->property(((propertytypeParser*)child)->post());
113 virtual void buildAttr(const XML_Char** attr)
117 for (int i = 0; attr[i]; i += 2)
119 if((std::string(attr[i]) == "control")
120 && (std::string(attr[i+1]) == "false"))
121 this->_link._withControl=false;
124 virtual void fromport (const std::string& name)
126 this->_link.fromport(name);
128 virtual void toport (const std::string& name)
130 this->_link.toport(name);
134 this->mincount("fromnode",1);
135 this->mincount("tonode",1);
136 this->mincount("fromport",1);
137 this->mincount("toport",1);
142 template <class T=mystream>
143 struct streamtypeParser: linktypeParser<T>
145 static streamtypeParser<T> streamParser;
148 template <class T> streamtypeParser<T> streamtypeParser<T>::streamParser;
149 template <class T> controltypeParser<T> controltypeParser<T>::controlParser;
150 template <class T> linktypeParser<T> linktypeParser<T>::linkParser;