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/Wsdl.h> 00029 #include <wsdlparser/WsdlElement.h> 00030 00031 00032 //Message part 00033 class Part{ 00034 public: 00035 00036 typedef enum 00037 { 00038 None, 00039 Elem, 00040 Type 00041 }PartRefType; 00042 00043 Part(const std::string n); 00044 ~Part(); 00045 PartRefType refType()const; 00046 std::string name()const; 00047 int type()const; 00048 const Element* element()const; 00049 int schemaId()const; 00050 void setPartType(int typeId,int schema); 00051 void setPartElement(const Element* e,int schema); 00052 private: 00053 std::string pname; 00054 PartRefType discriminator; 00055 union { 00056 int type_id; 00057 const Element * e; 00058 }; 00059 int schema_id; 00060 }; 00061 00062 //Implementation of Wsdl message element 00063 class Message:public WsdlElement 00064 { 00065 public: 00066 00067 Message(WsdlParser& w); 00068 ~Message(); 00071 00076 int getNumParts(void) const; 00083 int getPartIndex(std::string & nam) const ; 00084 /* @name getPartType 00085 * @param the index of the part index:0..nParts-1 00086 * @return type id of the part 00087 * for ex if we have <part name="one" type="xsd:int"> 00088 * the id returned represents xsd:int,the schema type for integers 00089 */ 00090 int getPartType(int index) const; 00091 int getPartType(const std::string & nam) const; 00092 00093 /* @name getPartElement 00094 * @param the index of the part index:0..nParts-1 00095 * @return pointer to the Element which the part uses 00096 * for ex if we have <part name="one" element="ns:elem"> 00097 * a pointer to the Element representing ns:elem is returned 00098 * I the part's reftype is Type ,0 is returned 00099 */ 00100 const Element * getPartElement(int index)const; 00101 00102 /* @name getMessagePart 00103 * @param the index of the part,or the name 00104 * @return pointer to the Part 00105 */ 00106 const Part* getMessagePart(size_t index)const; 00107 const Part* getMessagePart(const std::string & nam)const; 00108 00109 /* @name getPartContentSchemaId 00110 * @param the index of the part,or the name 00111 * @return schema id to which the part's type or element belongs to 00112 */ 00113 int getPartContentSchemaId(int index) const; 00114 int getPartContentSchemaId(const std::string & nam) const; 00115 00116 std::string getPartName(int index) const; 00117 Part::PartRefType getPartRefType(const std::string & nam) const; 00118 Part::PartRefType getPartRefType(int index) const; 00119 00120 00121 00123 00126 void addPart(std::string pname, 00127 Part::PartRefType reftype, 00128 void* d, 00129 int schema_id); 00130 00132 00133 // void print(ostream & out); 00134 private: 00135 std::vector<Part> parts; 00136 }; 00137 00138 inline 00139 Message::Message(WsdlParser & w) 00140 :WsdlElement(w) 00141 { 00142 parts.clear(); 00143 } 00144 00145 inline 00146 Message::~Message() 00147 { 00148 }; 00149 00150 00151 inline 00152 int 00153 Message::getNumParts(void) const 00154 { 00155 return parts.size(); 00156 } 00157 00158 inline 00159 std::string 00160 Message::getPartName(int index) const 00161 { 00162 return parts[index].name(); 00163 } 00164 00165 inline 00166 int 00167 Message::getPartContentSchemaId(int index) const 00168 { 00169 return parts[index].schemaId(); 00170 } 00171 00172 inline 00173 int 00174 Message::getPartType(int index) const 00175 { 00176 return parts[index].type(); 00177 } 00178 00179 inline 00180 const Element * 00181 Message::getPartElement(int index)const 00182 { 00183 return parts[index].element(); 00184 } 00185 00186 inline 00187 Part::Part(const std::string n) 00188 :pname(n), 00189 discriminator(Part::None), 00190 e(0) 00191 { 00192 } 00193 00194 inline 00195 Part::~Part(){} 00196 00197 inline 00198 Part::PartRefType 00199 Part::refType()const 00200 { 00201 return discriminator; 00202 } 00203 inline 00204 std::string 00205 Part::name()const 00206 { 00207 return pname; 00208 } 00209 00210 inline 00211 int 00212 Part::schemaId()const 00213 { 00214 return schema_id; 00215 } 00216 00217 #endif /* */