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 <schemaparser/Constraint.h>
00026
00027 #define UNBOUNDED 1000
00028 class Element
00029 {
00030 public:
00031 Element(const std::string & name,
00032 int type_id,
00033 int min = 1,
00034 int max = 1,
00035 bool qualified = false,
00036 std::string def = "",
00037 std::string fixed ="");
00038
00039 Element(void);
00040
00041 void setType(int id);
00042 std::string getName() const;
00043 int getType() const;
00044 int max() const ;
00045 int min() const;
00046 std::string & defaultVal();
00047 std::string & fixedVal();
00048 bool isQualified() const;
00049 Element& operator = (const Element & e);
00050 void min(int m);
00051 void max(int m);
00052
00053 void addConstraint(Constraint* c);
00054 Constraint* constraint();
00055 int nOccurrences;
00056
00057 private:
00058 std::string elemName;
00059 std::string dval, fval;
00060 int elemType;
00061 bool bQualified;
00062 int minOccurs, maxOccurs;
00063 Constraint* cstr;
00064 };
00065
00066 #ifdef LOGGING
00067 ostream & operator << (ostream & stream, Element & e);
00068 #endif
00069
00070 inline
00071 Element::Element(const std::string & name,
00072 int type_id,
00073 int min ,
00074 int max ,
00075 bool qualified,
00076 std::string def ,
00077 std::string fixed)
00078 : nOccurrences(0),
00079 elemName(name),
00080 dval(def),
00081 fval(fixed),
00082 elemType(type_id),
00083 bQualified(qualified),
00084 minOccurs(min),
00085 maxOccurs(max),
00086 cstr(0)
00087 {
00088 }
00089
00090 inline
00091 Element::Element(void)
00092 :nOccurrences(0),
00093 elemType(0),
00094 bQualified (false),
00095 minOccurs (1),
00096 maxOccurs (1),
00097 cstr(0)
00098 {
00099 }
00100
00101 inline
00102 void
00103 Element::setType(int id)
00104 {
00105 elemType = id;
00106 }
00107
00108 inline
00109 std::string
00110 Element::getName() const
00111 {
00112 return elemName;
00113 }
00114
00115 inline
00116 int
00117 Element::getType() const
00118 {
00119 return elemType;
00120 }
00121
00122 inline
00123 int
00124 Element::max() const
00125 {
00126 return maxOccurs;
00127 }
00128 inline
00129 int
00130 Element::min() const
00131 {
00132 return minOccurs;
00133 }
00134
00135 inline
00136 std::string &
00137 Element::defaultVal()
00138 {
00139 return dval;
00140 }
00141
00142 inline
00143 std::string &
00144 Element::fixedVal()
00145 {
00146 return fval;
00147 }
00148
00149 inline
00150 bool
00151 Element::isQualified() const
00152 {
00153 return bQualified;
00154 }
00155
00156 inline
00157 Element&
00158 Element::operator = (const Element & e)
00159 {
00160 elemName = e.elemName;
00161 elemType = e.elemType;
00162 bQualified = e.isQualified();
00163 dval = e.dval;
00164 fval = e.fval;
00165 return *this;
00166
00167
00168 }
00169 inline
00170 void
00171 Element::min(int m)
00172 {
00173 minOccurs=m;
00174 }
00175
00176 inline
00177 void
00178 Element::max(int m)
00179 {
00180 maxOccurs=m;
00181 }
00182
00183 inline
00184 void
00185 Element::addConstraint(Constraint* c)
00186 {
00187 cstr=c;
00188 }
00189
00190 inline
00191 Constraint*
00192 Element::constraint()
00193 {
00194 return cstr;
00195 }
00196 #endif