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 _COMPLEXTYPEH 00021 #define _COMPLEXTYPEH 00022 00023 #include <list> 00024 #include "xmlpull/wsdlpull_export.h" 00025 #include "xmlpull/Qname.h" 00026 #include "xmlpull/XmlUtils.h" 00027 #include "schemaparser/XSDType.h" 00028 #include "schemaparser/ContentModel.h" 00029 #include "schemaparser/Attribute.h" 00030 #include "schemaparser/SchemaParserException.h" 00031 00032 namespace Schema { 00033 00034 class WSDLPULL_EXPORT ComplexType:public XSDType 00035 { 00036 public: 00037 00038 ComplexType(const std::string& ); 00039 ~ComplexType(); 00040 00041 /* 00042 * Various getter methods 00043 */ 00044 00045 //virtual function ,always return false for complex types 00046 bool isSimple() const; 00047 00048 //returns the content type for complex types whose content model is SIMPLE 00049 int getContentType() const; 00050 00051 //returns the number of attributes ,indices start from 0 to n-1 00052 int getNumAttributes() const; 00053 00054 //gets the id of the attribute at the position "index" 00055 int getAttributeType(int index); 00056 00057 //gets the NCName of the attribute 00058 std::string getAttributeName(int index)const; 00059 00060 //returns the content model structure 00061 ContentModel* getContents()const; 00062 00063 //returns a pointer to the attribute 00064 const Attribute *getAttribute(const std::string & name)const; 00065 00066 const Attribute *getAttribute(int index)const; 00067 //returns the list of attributes 00068 std::list < Attribute > & pAttributeList() ; 00069 00070 /* 00071 * Various setter methods 00072 */ 00073 00074 void setSimpleContentType(int id); 00075 00076 void setContents(ContentModel* ct); 00077 00078 void addAttribute(const Attribute &a, 00079 bool fwdRef=false); 00080 //forward reference to attributeGroup 00081 void addAttributeGroupName(const Qname & qn); 00082 00083 void matchAttributeRef(const std::string & name, Attribute & a); 00084 void matchElementRef(const std::string & name, Element & e); 00085 bool checkOccurrences(void); 00086 void resetCounters(void); 00087 00088 00089 #ifdef LOGGING 00090 void print(std::ostream & out); 00091 #endif 00092 00093 private: 00094 std::list < Attribute > attList_; 00095 int simpleContentTypeId_; //for simple content 00096 ContentModel* cm_; 00097 void error(std::string msg) const; 00098 bool fwdElemRef_, fwdAttrRef_; 00099 }; 00100 00101 00102 inline 00103 int 00104 ComplexType::getContentType() const 00105 { 00106 return simpleContentTypeId_; 00107 } 00108 00109 inline 00110 bool 00111 ComplexType::isSimple() const 00112 { 00113 return false; 00114 } 00115 00116 inline 00117 int 00118 ComplexType::getNumAttributes() const 00119 { 00120 return attList_.size(); 00121 } 00122 00123 inline 00124 int 00125 ComplexType::getAttributeType(int index) 00126 { 00127 return getAttribute(index)->getType(); 00128 } 00129 00130 inline 00131 std::string 00132 ComplexType::getAttributeName(int index)const 00133 { 00134 return getAttribute(index)->getName(); 00135 } 00136 00137 inline 00138 std::list < Attribute > & 00139 ComplexType::pAttributeList() 00140 { 00141 return attList_; 00142 } 00143 00144 00145 inline 00146 void 00147 ComplexType::setSimpleContentType(int id) 00148 { 00149 simpleContentTypeId_ = id; 00150 } 00151 00152 00153 inline 00154 ContentModel* 00155 ComplexType::getContents()const 00156 { 00157 return cm_; 00158 00159 } 00160 00161 inline 00162 void 00163 ComplexType::setContents(ContentModel* ct) 00164 { 00165 cm_=ct; 00166 } 00167 00168 00169 inline 00170 ComplexType::~ComplexType() 00171 { 00172 if(cm_) 00173 delete cm_; 00174 } 00175 } 00176 #endif /* */