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