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