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