]> SALOME platform Git repositories - modules/yacs.git/blob - src/yacsloader/containerParsers.cxx
Salome HOME
d3aae264e0be30da0344c347ff64437b6e2adf3a
[modules/yacs.git] / src / yacsloader / containerParsers.cxx
1 //  Copyright (C) 2006-2008  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.
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 #include "containerParsers.hxx"
20 #include "propertyParsers.hxx"
21
22 namespace YACS
23 {
24   containertypeParser containertypeParser::containerParser;
25   machinetypeParser machinetypeParser::machineParser;
26   loadtypeParser loadtypeParser::loadParser;
27
28   void machinetypeParser::buildAttr(const XML_Char** attr)
29     {
30       required("name",attr);
31       for (int i = 0; attr[i]; i += 2)
32       {
33         if(std::string(attr[i]) == "name")name(attr[i+1]);
34       }
35     }
36   void machinetypeParser::pre (){_mach._name="";}
37   void machinetypeParser::name(const std::string& name){ _mach._name=name; }
38   machine machinetypeParser::post()
39     {
40       return _mach;
41     }
42
43   void containertypeParser::buildAttr(const XML_Char** attr)
44     {
45       required("name",attr);
46       for (int i = 0; attr[i]; i += 2)
47       {
48         if(std::string(attr[i]) == "name")name(attr[i+1]);
49       }
50     }
51   void containertypeParser::onStart(const XML_Char* el, const XML_Char** attr)
52     {
53       std::string element(el);
54       parser* pp=&parser::main_parser;
55       if(element == "machine")pp=&machinetypeParser::machineParser;
56       if(element == "property")pp=&propertytypeParser::propertyParser;
57       SetUserDataAndPush(pp);
58       pp->init();
59       pp->pre();
60       pp->buildAttr(attr);
61     }
62   void containertypeParser::onEnd(const char *el,parser* child)
63     {
64       std::string element(el);
65       if(element == "machine")machine_(((machinetypeParser*)child)->post());
66       if(element == "property")property(((propertytypeParser*)child)->post());
67     }
68   void containertypeParser::pre ()
69     {
70       _container._machs.clear();
71       _container._props.clear();
72     }
73   void containertypeParser::name(const std::string& name){ _container._name=name; }
74   void containertypeParser::machine_(const machine& m)
75     {
76       DEBTRACE( "machine: " << m._name )             
77       _container._machs.push_back(m);
78     }
79   void containertypeParser::property (const myprop& prop)
80     {
81       DEBTRACE( "property_set: " << prop._name << " " << prop._value );
82       _container._props[prop._name]=prop._value;
83     }
84   mycontainer containertypeParser::post()
85     {
86       //mincount("machine",1);
87       return _container;
88     }
89
90   void loadtypeParser::buildAttr(const XML_Char** attr)
91     {
92       required("container",attr);
93       for (int i = 0; attr[i]; i += 2)
94       {
95         if(std::string(attr[i]) == "container")container(attr[i+1]);
96       }
97     }
98   void loadtypeParser::pre (){_loadon._container="";}
99   void loadtypeParser::container(const std::string& name){ _loadon._container=name; }
100   loadon loadtypeParser::post()
101     {
102       return _loadon;
103     }
104
105 }