Version: 9.15.0
componentinstanceParsers.cxx
Go to the documentation of this file.
1 // Copyright (C) 2006-2025 CEA, EDF
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 
21 #include "containerParsers.hxx"
22 #include "dataParsers.hxx"
23 #include "propertyParsers.hxx"
24 
25 //#define _DEVDEBUG_
26 #include "YacsTrace.hxx"
27 
28 namespace YACS
29 {
30  componentinstancetypeParser componentinstancetypeParser::componentinstanceParser;
31 
33  {
34  if (!attr)
35  return;
36  required("name",attr);
37  for (int i = 0; attr[i]; i += 2)
38  {
39  if(std::string(attr[i]) == "name")name(attr[i+1]);
40  if(std::string(attr[i]) == "kind")kind(attr[i+1]);
41  }
42  }
44  {
45  std::string element(el);
47  this->maxcount("component",1,element);
48  this->maxcount("load",1,element);
49  if(element == "property")pp=&propertytypeParser::propertyParser;
50  else if(element == "component")pp=&stringtypeParser::stringParser;
51  else if(element == "load")pp=&loadtypeParser::loadParser;
53  pp->init();
54  pp->pre();
55  pp->buildAttr(attr);
56  }
57  void componentinstancetypeParser::onEnd(const char *el,parser* child)
58  {
59  std::string element(el);
60  if(element == "property")property(((propertytypeParser*)child)->post());
61  else if(element == "component") component(((stringtypeParser*)child)->post());
62  else if(element == "load") load(((loadtypeParser*)child)->post());
63  }
64 
66  {
67  _componentinstance._props.clear();
68  }
69 
70  void componentinstancetypeParser::name(const std::string& name)
72 
73  void componentinstancetypeParser::kind(const std::string& kind)
75 
77  {
78  DEBTRACE("property_set: "<<prop._name<<" "<<prop._value);
80  }
81 
82  void componentinstancetypeParser::component (const std::string& name)
83  {
84  DEBTRACE( "component_set: " << name )
86  }
87 
89  {
90  DEBTRACE( "load: " )
91  _componentinstance._container=l._container;
92  }
93 
95  {
96  this->mincount("component",1);
97  return _componentinstance;
98  }
99 }
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31
char XML_Char
Definition: parserBase.hxx:37
virtual void kind(const std::string &kind)
virtual void onStart(const XML_Char *el, const XML_Char **attr)
static componentinstancetypeParser componentinstanceParser
virtual void name(const std::string &name)
virtual void component(const std::string &name)
virtual void onEnd(const char *el, parser *child)
virtual void property(const myprop &prop)
virtual void buildAttr(const XML_Char **attr)
Class for loading parser.
static loadtypeParser loadParser
virtual void maxcount(std::string name, int max, std::string &el)
Definition: parserBase.cxx:122
virtual void init()
Definition: parserBase.cxx:86
virtual void pre()
Definition: parserBase.hxx:61
virtual void SetUserDataAndPush(parser *pp)
Definition: parserBase.cxx:55
virtual void mincount(std::string name, int min)
Definition: parserBase.cxx:134
virtual void required(const std::string &name, const XML_Char **attr)
Definition: parserBase.cxx:186
virtual void buildAttr(const XML_Char **attr)
Definition: parserBase.cxx:195
static parser main_parser
Definition: parserBase.hxx:41
Class for property parser.
static propertytypeParser propertyParser
Class for string parser.
Definition: dataParsers.hxx:32
static stringtypeParser stringParser
Definition: dataParsers.hxx:33
std::string _kind
Definition: factory.hxx:128
std::map< std::string, std::string > _props
Definition: factory.hxx:131
std::string _name
Definition: factory.hxx:127
std::string _component
Definition: factory.hxx:129
std::string _container
Definition: factory.hxx:130
std::string _name
Definition: factory.hxx:96
std::string _value
Definition: factory.hxx:97