Version: 8.3.0
linkParsers.hxx
Go to the documentation of this file.
1 // Copyright (C) 2006-2016 CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 
20 #ifndef _LINKPARSERS_HXX_
21 #define _LINKPARSERS_HXX_
22 
23 #include "parserBase.hxx"
24 #include "dataParsers.hxx"
25 #include "propertyParsers.hxx"
26 
27 #include "factory.hxx"
28 
29 namespace YACS
30 {
31 template <class T=mycontrol>
33 {
35 
36  virtual void onStart(const XML_Char* el, const XML_Char** attr)
37  {
38  std::string element(el);
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);
45  pp->init();
46  pp->pre();
47  pp->buildAttr(attr);
48  }
49  virtual void onEnd(const char *el,parser* child)
50  {
51  std::string element(el);
52  if(element == "fromnode")fromnode(((stringtypeParser*)child)->post());
53  else if(element == "tonode")tonode(((stringtypeParser*)child)->post());
54  }
55  virtual void pre ()
56  {
57  _link.clear();
58  }
59  virtual void fromnode (const std::string& name)
60  {
61  _link.fromnode(name);
62  }
63  virtual void tonode (const std::string& name)
64  {
65  _link.tonode(name);
66  }
67  virtual void property (const myprop& prop)
68  {
69  DEBTRACE( "property_set: " << prop._name << prop._value )
70  _link.setProperty(prop._name,prop._value);
71  }
72  virtual T& post()
73  {
74  mincount("fromnode",1);
75  mincount("tonode",1);
76  return _link;
77  }
78  T _link;
79 };
80 
81 template <class T=mylink>
83 {
85 
86  virtual void onStart(const XML_Char* el, const XML_Char** attr)
87  {
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);
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);
100  pp->init();
101  pp->pre();
102  pp->buildAttr(attr);
103  }
104  virtual void onEnd(const char *el,parser* child)
105  {
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());
112  }
113  virtual void buildAttr(const XML_Char** attr)
114  {
115  if (!attr)
116  return;
117  for (int i = 0; attr[i]; i += 2)
118  {
119  if((std::string(attr[i]) == "control")
120  && (std::string(attr[i+1]) == "false"))
121  this->_link._withControl=false;
122  }
123  }
124  virtual void fromport (const std::string& name)
125  {
126  this->_link.fromport(name);
127  }
128  virtual void toport (const std::string& name)
129  {
130  this->_link.toport(name);
131  }
132  virtual T& post()
133  {
134  this->mincount("fromnode",1);
135  this->mincount("tonode",1);
136  this->mincount("fromport",1);
137  this->mincount("toport",1);
138  return this->_link;
139  }
140 };
141 
142 template <class T=mystream>
144 {
146 };
147 
151 
152 }
153 
154 #endif