00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _SIMPLETYPEH
00022 #define _SIMPLETYPEH
00023 #include <list>
00024 #include <map>
00025 #include <vector>
00026
00027 #include <schemaparser/XSDType.h>
00028 #include <xmlpull/Qname.h>
00029 #include <xmlpull/XmlUtils.h>
00030 #include <schemaparser/SchemaParserException.h>
00031
00032
00033
00034 typedef union
00035 {
00036 int length;
00037 struct
00038 {
00039 int minlen, maxlen;
00040 } lenRange;
00041 int numEnums;
00042 int wsp;
00043 struct
00044 {
00045 int maxinc, mininc, maxex, minex;
00046 } valRange;
00047 int tot;
00048 int frac;
00049 const char *pattern;
00050 } facetValueType;
00051
00052 class SimpleType:public XSDType
00053 {
00054 public:
00060 SimpleType(const std::string & ns);
00061 ~SimpleType();
00063
00070 bool isList() const;
00075 bool isUnion() const;
00080 bool isSimple() const;
00081
00082
00083 bool isvalidFacet(std::string facet);
00084 bool isValidInt(int val)const;
00085 bool isValidFloat(float val)const;
00086 bool isValidString(std::string val)const;
00087 bool getFacetValue(int facet, void **val);
00088 const std::list<int>* unionTypes()const;
00089
00091
00093 void setUnionType(int id);
00094 void setListType(int id);
00095 void setFacetValue(std::string facet,std::string val);
00097
00098
00099 enum
00100 {
00101 NONE = 0,
00102 LENGTH = 0x1,
00103 MINLEN = 0x2,
00104 MAXLEN = 0x4,
00105 ENUM =0x8,
00106 WSP = 0x10,
00107 MAXINC = 0x20,
00108 MININC = 0x40,
00109 MAXEX =0x80,
00110 MINEX = 0x100,
00111 TOTALDIGITS = 0x200,
00112 FRAC = 0x400,
00113 PATTERN = 0x800
00114 };
00115
00116
00117 enum
00118 {
00119 PRESERVE,
00120 REPLACE,
00121 COLLAPSE
00122 };
00123 #ifdef LOGGING
00124 void print(ostream & out);
00125 #endif
00126 private:
00127 std::vector<int> facetId_;
00128 std::map<std::string,int> facets_;
00129 list < std::string > enumValues_;
00130 int *validFacets_;
00131 facetValueType facetValue_;
00132 void error(std::string msg);
00133 bool isList_;
00134 bool isUnion_;
00135 std::list<int> * uTypes_;
00136 };
00137
00138 inline
00139 bool
00140 SimpleType::isList() const
00141 {
00142 return isList_;
00143 }
00144
00145 inline
00146 bool
00147 SimpleType::isUnion() const
00148 {
00149 return isUnion_;
00150 }
00151
00152 inline
00153 void
00154 SimpleType::setListType(int typeId)
00155 {
00156 isList_ = true;
00157 setBaseType(typeId);
00158 }
00159
00160 inline
00161 void
00162 SimpleType::setUnionType(int typeId)
00163 {
00164 isUnion_ = true;
00165 if(uTypes_ == 0){
00166 uTypes_ = new std::list<int>();
00167 }
00168 uTypes_->push_back(typeId);
00169 }
00170
00171 inline
00172 bool
00173 SimpleType::isSimple() const
00174 {
00175 return true;
00176 }
00177 inline
00178 const std::list<int>*
00179 SimpleType::unionTypes()const
00180 {
00181 return uTypes_;
00182 }
00183 #endif