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