Salome HOME
mergefrom branch BR_V511_PR tag mergeto_trunk_03feb09
[modules/yacs.git] / src / yacsloader / xmlrpcParsers.hxx
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 #ifndef _XMLRPCPARSERS_HXX_
20 #define _XMLRPCPARSERS_HXX_
21
22 #include "parserBase.hxx"
23 #include "factory.hxx"
24 #include <vector>
25 #include <string>
26
27 namespace YACS
28 {
29 /*! \brief Class for XML-RPC value parser.
30  *
31  *  This class is used to parse XML data that describes a sequence in XML-RPC format
32  *
33  *  Its XML schema is:
34    \verbatim
35      <xsd:complexType name="ValueType">
36        <xsd:choice >
37          <xsd:element name="int" type="IntType"/>
38          <xsd:element name="boolean" type="BooleanType"/>
39          <xsd:element name="double" type="DoubleType"/>
40          <xsd:element name="string" type="StringType"/>
41          <xsd:element name="objref" type="ObjrefType"/>
42          <xsd:element name="array" type="ArrayType"/>
43          <xsd:element name="struct" type="StructType"/>
44        </xsd:choice>
45      </xsd:complexType>
46    \endverbatim
47  */
48 struct valuetypeParser: parser
49 {
50   static valuetypeParser valueParser;
51   virtual void onStart(const XML_Char* el, const XML_Char** attr);
52   virtual void onEnd(const char *el,parser* child);
53   virtual void pre ();
54   virtual void int_ (const int& d);
55   virtual void boolean (const bool& d);
56   virtual void double_ (const double& d);
57   virtual void string(const std::string& d);
58   virtual void objref(const std::string& d);
59   virtual void array (const std::string& d);
60   virtual void struct_ (const std::string& d);
61   virtual std::string post();
62   std::string _data;
63   std::vector<std::string> _v;
64 };
65
66 /*! \brief Class for XML-RPC data parser.
67  *
68  *  This class is used to parse XML data that describes a sequence in XML-RPC format
69  *
70  *  Its XML schema is:
71    \verbatim
72      <xsd:complexType name="DataType">
73        <xsd:element name="value" type="ValueType"/>
74      </xsd:complexType>
75    \endverbatim
76  */
77 struct datatypeParser: parser
78 {
79   static datatypeParser dataParser;
80   virtual void onStart(const XML_Char* el, const XML_Char** attr);
81   virtual void onEnd(const char *el,parser* child);
82   virtual void pre ();
83   virtual void value (const std::string& v);
84   virtual std::string post();
85   std::string _data;
86   std::vector<std::string> _datas;
87 };
88
89 /*! \brief Class for XML-RPC member parser.
90  *
91  *  This class is used to parse XML data that describes a sequence in XML-RPC format
92  *
93  *  Its XML schema is:
94    \verbatim
95      <xsd:complexType name="MemberDataType">
96        <xsd:element name="name" type="StringType"/>
97        <xsd:element name="value" type="ValueType"/>
98      </xsd:complexType>
99    \endverbatim
100  */
101 struct memberdatatypeParser: parser
102 {
103   static memberdatatypeParser memberdataParser;
104   virtual void onStart(const XML_Char* el, const XML_Char** attr);
105   virtual void onEnd(const char *el,parser* child);
106   virtual void pre ();
107   virtual void name (const std::string& v);
108   virtual void value (const std::string& v);
109   virtual std::string post();
110   std::string _data;
111   std::vector<std::string> _datas;
112 };
113
114 /*! \brief Class for XML-RPC struct parser.
115  *
116  *  This class is used to parse XML data that describes a sequence in XML-RPC format
117  *
118  *  Its XML schema is:
119    \verbatim
120      <xsd:complexType name="StructDataType">
121        <xsd:element name="member" type="MemberDataType" minOccurs="1"/>
122      </xsd:complexType>
123    \endverbatim
124  */
125 struct structdatatypeParser: parser
126 {
127   static structdatatypeParser structdataParser;
128   virtual void onStart(const XML_Char* el, const XML_Char** attr);
129   virtual void onEnd(const char *el,parser* child);
130   virtual void pre ();
131   virtual void member (const std::string& d);
132   virtual std::string post();
133   std::string _members;
134   std::vector<std::string> _membersStack;
135 };
136
137 /*! \brief Class for XML-RPC array parser.
138  *
139  *  This class is used to parse XML data that describes a sequence in XML-RPC format
140  *
141  *  Its XML schema is:
142    \verbatim
143      <xsd:complexType name="ArrayType">
144        <xsd:element name="data" type="DataType" minOccurs="1" maxOccurs="1"/>
145      </xsd:complexType>
146    \endverbatim
147  */
148 struct arraytypeParser: parser
149 {
150   static arraytypeParser arrayParser;
151   virtual void onStart(const XML_Char* el, const XML_Char** attr);
152   virtual void onEnd(const char *el,parser* child);
153   virtual void pre ();
154   virtual void data (const std::string& d);
155   virtual std::string post();
156   std::vector<std::string> _arrays;
157 };
158
159 struct parametertypeParser: parser
160 {
161   static parametertypeParser parameterParser;
162
163   virtual void onStart(const XML_Char* el, const XML_Char** attr);
164   virtual void onEnd(const char *el,parser* child);
165     virtual void pre ();
166     virtual void tonode (const std::string& name);
167     virtual void toport (const std::string& name);
168     virtual void value (const std::string& name);
169     virtual myparam& post();
170     myparam _param;
171 };
172
173 }
174
175 #endif