1 // Copyright (C) 2006-2014 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)
34 required("name",attr);
35 for (int i = 0; attr[i]; i += 2)
37 if(std::string(attr[i]) == "name")name(attr[i+1]);
38 if(std::string(attr[i]) == "kind")kind(attr[i+1]);
41 void componentinstancetypeParser::onStart(const XML_Char* el, const XML_Char** attr)
43 std::string element(el);
44 parser* pp=&parser::main_parser;
45 this->maxcount("component",1,element);
46 this->maxcount("load",1,element);
47 if(element == "property")pp=&propertytypeParser::propertyParser;
48 else if(element == "component")pp=&stringtypeParser::stringParser;
49 else if(element == "load")pp=&loadtypeParser::loadParser;
50 SetUserDataAndPush(pp);
55 void componentinstancetypeParser::onEnd(const char *el,parser* child)
57 std::string element(el);
58 if(element == "property")property(((propertytypeParser*)child)->post());
59 else if(element == "component") component(((stringtypeParser*)child)->post());
60 else if(element == "load") load(((loadtypeParser*)child)->post());
63 void componentinstancetypeParser::pre ()
65 _componentinstance._props.clear();
68 void componentinstancetypeParser::name(const std::string& name)
69 { _componentinstance._name=name; }
71 void componentinstancetypeParser::kind(const std::string& kind)
72 { _componentinstance._kind=kind; }
74 void componentinstancetypeParser::property (const myprop& prop)
76 DEBTRACE("property_set: "<<prop._name<<" "<<prop._value);
77 _componentinstance._props[prop._name]=prop._value;
80 void componentinstancetypeParser::component (const std::string& name)
82 DEBTRACE( "component_set: " << name )
83 _componentinstance._component=name;
86 void componentinstancetypeParser::load (const loadon& l)
89 _componentinstance._container=l._container;
92 mycomponentinstance componentinstancetypeParser::post()
94 this->mincount("component",1);
95 return _componentinstance;