Salome HOME
435a3cd93f8614804d361b4e6c4c432d2c192ee1
[modules/yacs.git] / src / yacsloader / typeParsers.hxx
1 // Copyright (C) 2006-2022  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 _TYPEPARSERS_HXX_
21 #define _TYPEPARSERS_HXX_
22
23 #include "parserBase.hxx"
24 #include "TypeCode.hxx"
25 #include "factory.hxx"
26
27 namespace YACS
28 {
29
30 /*! \brief Class for type parser.
31  *
32  *  Class used to parse a type definition (class TypeCode in implementation)
33  *  with a name and a kind (reserved to atomic types)
34  
35    XML schema is 
36    \verbatim
37      <xsd:complexType name="TypeType">
38        <xsd:attribute name="name" type="xsd:string" use="required"/>
39        <xsd:attribute name="kind" type="xsd:string" use="required"/>
40      </xsd:complexType>
41    \endverbatim
42  */
43 struct typetypeParser: parser
44 {
45   static typetypeParser typeParser;
46   virtual void buildAttr(const XML_Char** attr);
47   virtual void pre ();
48   virtual void name(const std::string& name);
49   virtual void kind(const std::string& name);
50   virtual mytype post();
51   std::string _name;
52   std::string _kind;
53 };
54
55 /*! \brief Class for sequence parser.
56  *
57  *  Class used to parse a sequence (type) definition (class TypeCodeSeq in implementation)
58  *
59    XML schema is 
60  
61  \verbatim
62      <xsd:complexType name="SequenceType">
63        <xsd:attribute name="name" type="xsd:string" use="required"/>
64        <xsd:attribute name="content" type="xsd:string" use="required"/>
65      </xsd:complexType>
66  \endverbatim
67  
68  */
69 struct seqtypeParser:public parser
70 {
71   static seqtypeParser seqParser;
72   virtual void onStart(const XML_Char* el, const XML_Char** attr);
73   virtual void onEnd(const char *el,parser* child);
74   virtual void buildAttr(const XML_Char** attr);
75   void name(const std::string& name);
76   void content(const std::string& name);
77   YACS::ENGINE::TypeCode* post();
78   YACS::ENGINE::TypeCode* _contentType;
79   std::string _name;
80 };
81
82 /*! \brief Class for objref parser.
83  *
84  *  Class used to parse a objref (type) definition (class TypeCodeObjref in implementation)
85  
86    XML schema is 
87    \verbatim
88      <xsd:complexType name="ObjrefType">
89        <xsd:sequence>
90          <xsd:element name="base" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
91        </xsd:sequence>
92        <xsd:attribute name="name" type="xsd:string" use="required"/>
93        <xsd:attribute name="id" type="xsd:string" />
94      </xsd:complexType>
95    \endverbatim
96  
97  */
98 struct objtypeParser: parser
99 {
100   static objtypeParser objParser;
101   virtual void onStart(const XML_Char* el, const XML_Char** attr);
102   virtual void onEnd(const char *el,parser* child);
103   virtual void buildAttr(const XML_Char** attr);
104   virtual void pre ();
105   virtual void name(const std::string& name);
106   virtual void id(const std::string& name);
107   virtual void base(const std::string& name);
108   virtual YACS::ENGINE::TypeCode * post();
109   std::string _name;
110   std::string _id;
111   std::list<YACS::ENGINE::TypeCodeObjref *> _ltc;
112 };
113
114 /*! \brief Class for member parser.
115  *
116  *  Class used to parse a struct member
117  *  A struct member is a pair of name(string), type(string)
118  
119    XML schema is
120    \verbatim
121      <xsd:complexType name="MemberType">
122        <xsd:attribute name="name" type="xsd:string" use="required"/>
123        <xsd:attribute name="type" type="xsd:string" use="required"/>
124      </xsd:complexType>
125    \endverbatim
126  
127  */
128 struct membertypeParser: parser
129 {
130   static membertypeParser memberParser;
131   virtual void buildAttr(const XML_Char** attr);
132   virtual void name(const std::string& name);
133   virtual void type(const std::string& name);
134   myprop post();
135   myprop _prop;
136 };
137
138 /*! \brief Class for struct parser.
139  *
140  *  Class used to parse a struct (type) definition (class TypeCodeStruct in implementation)
141  *
142  *  XML schema is 
143    \verbatim
144      <xsd:complexType name="StructType">
145        <xsd:sequence>
146          <xsd:element name="member" type="MemberType" minOccurs="0" maxOccurs="unbounded"/>
147        </xsd:sequence>
148        <xsd:attribute name="name" type="xsd:string" use="required"/>
149        <xsd:attribute name="id" type="xsd:string" />
150      </xsd:complexType>
151    \endverbatim
152  *
153  */
154 struct structtypeParser: parser
155 {
156   static structtypeParser structParser;
157
158   virtual void onStart(const XML_Char* el, const XML_Char** attr);
159   virtual void onEnd(const char *el,parser* child);
160   virtual void buildAttr(const XML_Char** attr);
161   virtual void pre ();
162   virtual void name(const std::string& name);
163   virtual void id(const std::string& name);
164   virtual void member (const myprop& prop);
165   virtual YACS::ENGINE::TypeCode * post();
166   std::string _name;
167   std::string _id;
168   std::vector<myprop> _members;
169 };
170
171 }
172
173 #endif