00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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 & typeNs,
00035 int type_id,
00036 int minimum = 1,
00037 int maximum = 1,
00038 bool qualified = false,
00039 std::string def = "",
00040 std::string fixed ="");
00041
00042 Element(void);
00043 void setType(int id);
00044 std::string getName() const;
00045 void setTypeNamespace(std::string ns);
00046 std::string getTypeNamespace() const;
00047 int getType() const;
00048 int getMax() const ;
00049 int getMin() const;
00050 std::string & defaultVal();
00051 std::string & fixedVal();
00052 bool isQualified() const;
00053 Element& operator = (const Element & e);
00054 void setMin(int m);
00055 void setMax(int m);
00056
00057 void addConstraint(Constraint* c);
00058 Constraint* constraint();
00059 const std::list<std::string> & getConstraints();
00060 int nOccurrences;
00061
00062 private:
00063 std::string elemName;
00064 std::string dval, fval;
00065 int elemType;
00066 bool bQualified;
00067 int minOccurs, maxOccurs;
00068 std::string elemTypeNamespace;
00069 Constraint* cstr;
00070 };
00071
00072 #ifdef LOGGING
00073 std::ostream & operator << (std::ostream & stream, Element & e);
00074 #endif
00075
00076 inline
00077 Element::Element(const std::string & name,
00078 const std::string & typeNs,
00079 int type_id,
00080 int minimum,
00081 int maximum,
00082 bool qualified,
00083 std::string def ,
00084 std::string fixed)
00085 : nOccurrences(0),
00086 elemName(name),
00087 dval(def),
00088 fval(fixed),
00089 elemType(type_id),
00090 bQualified(qualified),
00091 minOccurs(minimum),
00092 maxOccurs(maximum),
00093 elemTypeNamespace(typeNs),
00094 cstr(0)
00095 {
00096 }
00097
00098 inline
00099 Element::Element(void)
00100 :nOccurrences(0),
00101 elemType(0),
00102 bQualified (false),
00103 minOccurs (1),
00104 maxOccurs (1),
00105 cstr(0)
00106 {
00107 }
00108 inline
00109 void
00110 Element::setType(int id)
00111 {
00112 elemType = id;
00113 }
00114
00115 inline
00116 std::string
00117 Element::getName() const
00118 {
00119 return elemName;
00120 }
00121
00122 inline
00123 void
00124 Element::setTypeNamespace(std::string ns)
00125 {
00126 elemTypeNamespace = ns;
00127 }
00128
00129 inline
00130 std::string
00131 Element::getTypeNamespace() const
00132 {
00133 return elemTypeNamespace;
00134 }
00135
00136 inline
00137 int
00138 Element::getType() const
00139 {
00140 return elemType;
00141 }
00142
00143 inline
00144 int
00145 Element::getMax() const
00146 {
00147 return maxOccurs;
00148 }
00149 inline
00150 int
00151 Element::getMin() const
00152 {
00153 return minOccurs;
00154 }
00155
00156 inline
00157 std::string &
00158 Element::defaultVal()
00159 {
00160 return dval;
00161 }
00162
00163 inline
00164 std::string &
00165 Element::fixedVal()
00166 {
00167 return fval;
00168 }
00169
00170 inline
00171 bool
00172 Element::isQualified() const
00173 {
00174 return bQualified;
00175 }
00176
00177 inline
00178 Element&
00179 Element::operator = (const Element & e)
00180 {
00181 elemName = e.elemName;
00182 elemType = e.elemType;
00183 bQualified = e.isQualified();
00184 dval = e.dval;
00185 fval = e.fval;
00186 elemTypeNamespace = e.elemTypeNamespace;
00187 cstr = e.cstr;
00188 return *this;
00189
00190
00191 }
00192 inline
00193 void
00194 Element::setMin(int m)
00195 {
00196 minOccurs=m;
00197 }
00198
00199 inline
00200 void
00201 Element::setMax(int m)
00202 {
00203 maxOccurs=m;
00204 }
00205
00206 inline
00207 void
00208 Element::addConstraint(Constraint* c)
00209 {
00210 cstr=c;
00211 }
00212
00213 inline
00214 Constraint*
00215 Element::constraint()
00216 {
00217 return cstr;
00218 }
00219 }
00220 #endif