wsdlpull
1.23
|
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 */ 00021 #ifndef _ELEMENTH 00022 #define _ELEMENTH 00023 00024 #include <string> 00025 #include "xmlpull/wsdlpull_export.h" 00026 #include "schemaparser/Constraint.h" 00027 00028 namespace Schema { 00029 #define UNBOUNDED INT_MAX 00030 class WSDLPULL_EXPORT Element 00031 { 00032 public: 00033 Element(const std::string & name, 00034 const std::string & elemNs, 00035 const std::string & typeNs, 00036 int type_id, 00037 int minimum = 1, 00038 int maximum = 1, 00039 bool qualified = false, 00040 std::string def = "", 00041 std::string fixed =""); 00042 00043 Element(void); 00044 void setType(int id); 00045 std::string getName() const; 00046 void setTypeNamespace(const std::string & ns); 00047 std::string getTypeNamespace() const; 00048 void setNamespace(const std::string &ns); 00049 std::string getNamespace()const; 00050 int getType() const; 00051 int getMax() const ; 00052 int getMin() const; 00053 std::string & defaultVal(); 00054 std::string & fixedVal(); 00055 bool isQualified() const; 00056 Element& operator = (const Element & e); 00057 void setMin(int m); 00058 void setMax(int m); 00059 //add a key/keyref/unique constraint 00060 void addConstraint(Constraint* c); 00061 Constraint* constraint(); 00062 const std::list<std::string> & getConstraints(); // Proposed modification: return a list of constraints, every constraint identified by its name. 00063 int nOccurrences; 00064 00065 private: 00066 std::string elemName; 00067 std::string dval, fval; 00068 int elemType; 00069 bool bQualified; 00070 int minOccurs, maxOccurs; 00071 std::string elemNamespace;//namespace where the element is defined 00072 std::string typeNamespace;//namespace where the type of this element is defined 00073 00074 Constraint* cstr; 00075 }; 00076 00077 #ifdef LOGGING 00078 std::ostream & operator << (std::ostream & stream, Element & e); 00079 #endif 00080 00081 inline 00082 Element::Element(const std::string & name, 00083 const std::string & elemNs, 00084 const std::string & typeNs, 00085 int type_id, 00086 int minimum, 00087 int maximum, 00088 bool qualified, 00089 std::string def , 00090 std::string fixed) 00091 : nOccurrences(0), 00092 elemName(name), 00093 dval(def), 00094 fval(fixed), 00095 elemType(type_id), 00096 bQualified(qualified), 00097 minOccurs(minimum), 00098 maxOccurs(maximum), 00099 elemNamespace(elemNs), 00100 typeNamespace(typeNs), 00101 cstr(0) 00102 { 00103 } 00104 00105 inline 00106 Element::Element(void) 00107 :nOccurrences(0), 00108 elemType(0), 00109 bQualified (false), 00110 minOccurs (1), 00111 maxOccurs (1), 00112 cstr(0) 00113 { 00114 } 00115 00116 inline 00117 void 00118 Element::setType(int id) 00119 { 00120 elemType = id; 00121 } 00122 00123 inline 00124 std::string 00125 Element::getName() const 00126 { 00127 return elemName; 00128 } 00129 00130 inline 00131 void 00132 Element::setTypeNamespace(const std::string& ns) 00133 { 00134 typeNamespace = ns; 00135 } 00136 00137 inline 00138 std::string 00139 Element::getTypeNamespace() const 00140 { 00141 return typeNamespace; 00142 } 00143 00144 00145 inline 00146 int 00147 Element::getType() const 00148 { 00149 return elemType; 00150 } 00151 00152 inline 00153 int 00154 Element::getMax() const 00155 { 00156 return maxOccurs; 00157 } 00158 inline 00159 int 00160 Element::getMin() const 00161 { 00162 return minOccurs; 00163 } 00164 00165 inline 00166 std::string & 00167 Element::defaultVal() 00168 { 00169 return dval; 00170 } 00171 00172 inline 00173 std::string & 00174 Element::fixedVal() 00175 { 00176 return fval; 00177 } 00178 00179 inline 00180 bool 00181 Element::isQualified() const 00182 { 00183 return bQualified; 00184 } 00185 00186 inline 00187 Element& 00188 Element::operator = (const Element & e) 00189 { 00190 elemName = e.elemName; 00191 elemType = e.elemType; 00192 bQualified = e.isQualified(); 00193 dval = e.dval; 00194 fval = e.fval; 00195 typeNamespace = e.typeNamespace; 00196 cstr = e.cstr; 00197 return *this; 00198 //minimum and maximum are not copied because they are specific to the 00199 //occurrence 00200 } 00201 inline 00202 void 00203 Element::setMin(int m) 00204 { 00205 minOccurs=m; 00206 } 00207 00208 inline 00209 void 00210 Element::setMax(int m) 00211 { 00212 maxOccurs=m; 00213 } 00214 00215 inline 00216 void 00217 Element::addConstraint(Constraint* c) 00218 { 00219 cstr=c; 00220 } 00221 00222 inline 00223 Constraint* 00224 Element::constraint() 00225 { 00226 return cstr; 00227 } 00228 00229 00230 inline 00231 void 00232 Element::setNamespace(const std::string& ns) 00233 { 00234 elemNamespace = ns; 00235 } 00236 00237 inline 00238 std::string 00239 Element::getNamespace() const 00240 { 00241 return elemNamespace; 00242 } 00243 00244 00245 00246 } 00247 #endif /* */