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 #include "componentinstanceParsers.hxx"
21 #include "containerParsers.hxx"
22 #include "dataParsers.hxx"
23 #include "propertyParsers.hxx"
26 #include "YacsTrace.hxx"
30 componentinstancetypeParser componentinstancetypeParser::componentinstanceParser;
32 void componentinstancetypeParser::buildAttr(const XML_Char** attr)
36 required("name",attr);
37 for (int i = 0; attr[i]; i += 2)
39 if(std::string(attr[i]) == "name")name(attr[i+1]);
40 if(std::string(attr[i]) == "kind")kind(attr[i+1]);
43 void componentinstancetypeParser::onStart(const XML_Char* el, const XML_Char** attr)
45 std::string element(el);
46 parser* pp=&parser::main_parser;
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;
52 SetUserDataAndPush(pp);
57 void componentinstancetypeParser::onEnd(const char *el,parser* child)
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());
65 void componentinstancetypeParser::pre ()
67 _componentinstance._props.clear();
70 void componentinstancetypeParser::name(const std::string& name)
71 { _componentinstance._name=name; }
73 void componentinstancetypeParser::kind(const std::string& kind)
74 { _componentinstance._kind=kind; }
76 void componentinstancetypeParser::property (const myprop& prop)
78 DEBTRACE("property_set: "<<prop._name<<" "<<prop._value);
79 _componentinstance._props[prop._name]=prop._value;
82 void componentinstancetypeParser::component (const std::string& name)
84 DEBTRACE( "component_set: " << name )
85 _componentinstance._component=name;
88 void componentinstancetypeParser::load (const loadon& l)
91 _componentinstance._container=l._container;
94 mycomponentinstance componentinstancetypeParser::post()
96 this->mincount("component",1);
97 return _componentinstance;