Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

Message.h

Go to the documentation of this file.
00001 /* 
00002  * wsdlpull - A C++ parser  for WSDL  (Web services description language)
00003  * Copyright (C) 2005-2007 Vivek Krishna
00004  *
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Library General Public
00007  * License as published by the Free Software Foundation; either
00008  * version 2 of the License, or (at your option) any later version.
00009  *
00010  * This library is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Library General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Library General Public
00016  * License along with this library; if not, write to the Free
00017  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018  *
00019  */
00020 #ifndef _MESSAGEH
00021 #define  _MESSAGEH
00022 
00023 #include <string>
00024 #include <vector>
00025 #include "xmlpull/Qname.h"
00026 #include "schemaparser/Element.h"
00027 #include "wsdlparser/WsdlException.h"
00028 #include "wsdlparser/WsdlElement.h"
00029 
00030 namespace WsdlPull {
00031 //Message part
00032 class WSDLPULL_EXPORT Part{
00033  public:
00034   
00035     typedef enum 
00036     {
00037       None,
00038       Elem,
00039       Type
00040     }PartRefType;
00041     
00042   Part(const std::string& n);
00043   ~Part();
00044   PartRefType refType()const;
00045   std::string name()const;
00046   int type()const;
00047   const Element* element()const;
00048   int schemaId()const;
00049   void setPartType(int typeId,int schema);
00050   void setPartElement(const Element* e,int schema);
00051  private:
00052   std::string pname;
00053   PartRefType discriminator;
00054   union {
00055     int type_id;
00056     const Element * e;
00057   };
00058   int schema_id;
00059 };
00060 
00061 //Implementation of Wsdl message element
00062 class WSDLPULL_EXPORT Message:public WsdlElement
00063 {
00064  public:
00065   
00066   Message(WsdlParser& w);
00067   ~Message();
00070 
00075   int getNumParts(void) const;
00082   int getPartIndex(std::string & nam) const ;
00083   /* @name getPartType
00084    * @param the index  of the part       index:0..nParts-1
00085    * @return type id  of the part
00086    *         for ex if we have <part name="one" type="xsd:int">
00087    *         the id returned represents xsd:int,the schema type for integers
00088    */
00089   int getPartType(int index) const;
00090   int getPartType(const std::string & nam) const;
00091 
00092   /* @name getPartElement
00093    * @param the index  of the part  index:0..nParts-1
00094    * @return pointer to the Element which the part uses
00095    *         for ex if we have <part name="one" element="ns:elem">
00096    *         a pointer to the Element representing ns:elem is returned
00097    *        I the part's reftype is Type ,0 is returned
00098    */
00099   const Element * getPartElement(int index)const;
00100 
00101   /* @name getMessagePart
00102    * @param the index  of the part,or the name
00103    * @return pointer to the Part
00104    */
00105   const Part* getMessagePart(size_t index)const;
00106   const Part* getMessagePart(const std::string & nam)const;
00107 
00108   /* @name getPartContentSchemaId
00109    * @param the index  of the part,or the name
00110    * @return schema id to which the part's type or element belongs to
00111    */
00112   int getPartContentSchemaId(int index) const;
00113   int getPartContentSchemaId(const std::string & nam) const;
00114 
00115   std::string getPartName(int index) const;
00116   Part::PartRefType getPartRefType(const std::string & nam) const;
00117   Part::PartRefType getPartRefType(int index) const;
00118 
00119 
00120 
00122 
00125   void addPart(std::string pname, 
00126                Part::PartRefType reftype, 
00127                void* d,
00128                int schema_id);
00129 
00131 
00132   //  void print(ostream & out);
00133  private:
00134   std::vector<Part> parts;
00135 };
00136 
00137 inline
00138 Message::Message(WsdlParser & w)
00139   :WsdlElement(w)
00140 {
00141   parts.clear();
00142 }
00143 
00144 inline
00145 Message::~Message()
00146 {
00147 };
00148 
00149 
00150 inline
00151 int 
00152 Message::getNumParts(void) const                   
00153 {
00154   return parts.size();
00155 }
00156 
00157 inline
00158 std::string
00159 Message::getPartName(int index) const
00160 {
00161   return parts[index].name();
00162 }
00163 
00164 inline
00165 int
00166 Message::getPartContentSchemaId(int index) const
00167 {
00168   return parts[index].schemaId();
00169 }
00170 
00171 inline
00172 int
00173 Message::getPartType(int index) const
00174 {
00175   return parts[index].type();
00176 }
00177 
00178 inline
00179 const Element *
00180 Message::getPartElement(int index)const
00181 {
00182   return parts[index].element();
00183 }
00184 
00185 inline
00186 Part::Part(const std::string& n)
00187   :pname(n),
00188      discriminator(Part::None),
00189      e(0)
00190 {
00191 }
00192 
00193 inline
00194 Part::~Part(){}
00195 
00196 inline
00197 Part::PartRefType
00198 Part::refType()const
00199 {
00200   return discriminator;
00201 }
00202 inline
00203 std::string
00204 Part::name()const
00205 {
00206   return pname;
00207 }
00208 
00209 inline
00210 int 
00211 Part::schemaId()const
00212 {
00213   return schema_id;
00214 }
00215 }
00216 #endif                                            /*  */

Generated on Mon Feb 6 23:02:42 2006 for wsdlpull by  doxygen 1.3.9.1