00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _TYPECONTAINERH
00025 #define _TYPECONTAINERH
00026 #include <map>
00027
00028 #include "xmlpull/XmlUtils.h"
00029 #include "schemaparser/SchemaParser.h"
00030
00031 #ifndef WSDLPULL_EXPORT
00032 #if (defined _MSC_VER) && (defined _MT)
00033 #define WSDLPULL_EXPORT __declspec (dllimport)
00034 #else
00035 #define WSDLPULL_EXPORT
00036 #endif
00037 #endif
00038
00039 namespace Schema {
00040 class TypeContainer;
00041
00042
00043 typedef struct
00044 {
00045 std::vector<TypeContainer *>tc;
00046 int count;
00047 int num;
00048 } Containers;
00049
00050 class WSDLPULL_EXPORT TypeContainer
00051 {
00052 public:
00053 TypeContainer(int typeId,const SchemaParser * sp);
00054 TypeContainer::TypeContainer(ContentModel* cm,
00055 const SchemaParser * sp);
00056 ~TypeContainer();
00057 TypeContainer *getAttributeContainer(std::string attName,
00058 bool create=false);
00059 TypeContainer *getBaseTypeContainer(bool create=false);
00060
00061 TypeContainer *getChildContainer(std::string elemName,
00062 bool create = false);
00063
00064 TypeContainer * getChildContainer(ContentModel* cm,
00065 bool create=false);
00066
00067
00068
00069 void *getValue();
00070
00071
00072
00073 void rewind();
00074
00075
00076
00077
00078 void * getValue(const std::string & name,Schema::Type & type);
00079
00080 const SchemaParser * schemaParser()const;
00081 bool isValueValid()const;
00082
00083
00084 int getTypeId()const;
00085
00086
00087 ContentModel* getContentModel()const;
00088
00089
00090 void setValue(const std::string & sValue,bool valid=true);
00091 void setValue(int iValue,bool valid=true);
00092 void setValue(char cValue,bool valid=true);
00093 void setValue(long lValue,bool valid=true);
00094 void setValue(unsigned long ulValue,bool valid=true);
00095 void setValue(float fValue,bool valid=true);
00096 void setValue(double dbValue,bool valid=true);
00097 void setValue(bool bValue,bool valid=true);
00098 void setValue(Qname & qnValue,bool valid=true);
00099
00100
00101 void setValAsString(const std::string &v);
00102 void print(std::ostream & os);
00103 friend std::ostream &operator<<(std::ostream &os, TypeContainer &tc);
00104 static bool printTypeNames_;
00105 private:
00106
00107 Schema::Type typeId_;
00108 ContentModel* cm_;
00109 std::map < std::string, Containers *> particleContainers_;
00110 std::map<ContentModel*,TypeContainer* >cmContainers_;
00111 std::map < std::string, TypeContainer *> attributeContainers_;
00112 const SchemaParser *sParser_;
00113 TypeContainer * baseContainer_;
00114
00115 union
00116 {
00117 std::string *sValue;
00118 int *iValue;
00119 unsigned int *uiValue;
00120 long *lValue;
00121 unsigned long *ulValue;
00122 short *shValue;
00123 unsigned short *usValue;
00124 float *fValue;
00125 double *dbValue;
00126 bool *bValue;
00127 char *cValue;
00128
00129
00130
00131
00132 Qname *qnValue;
00133
00134
00135 } Value;
00136 bool isValueValid_;
00137 std::string strVal;
00138 std::vector<TypeContainer*> tcTable;
00139
00140 void deleteValue();
00141 void printComplexType (std::ostream & os);
00142 void printSimpleType (std::ostream & os);
00143 void printContentModel(std::ostream & os);
00144
00145
00146 void rewindParticleContainers(std::map < std::string, Containers *> &particleContainers);
00147 };
00148
00149 inline
00150 void
00151 TypeContainer::setValue(const std::string & sValue,bool valid)
00152 {
00153 deleteValue();
00154 Value.sValue = new std::string(sValue);
00155 isValueValid_=valid;
00156 }
00157
00158 inline
00159 void
00160 TypeContainer::setValue(int iValue,bool valid)
00161 {
00162 deleteValue();
00163 Value.iValue = new int (iValue);
00164 isValueValid_=valid;
00165 }
00166
00167 inline
00168 void
00169 TypeContainer::setValue(char cValue,bool valid)
00170 {
00171 deleteValue();
00172 Value.cValue = new char (cValue);
00173 isValueValid_=valid;
00174 }
00175
00176 inline
00177 void
00178 TypeContainer::setValue(long lValue,bool valid)
00179 {
00180 deleteValue();
00181 Value.lValue = new long (lValue);
00182 isValueValid_=valid;
00183 }
00184
00185 inline
00186 void
00187 TypeContainer::setValue(unsigned long ulValue,bool valid)
00188 {
00189 deleteValue();
00190 Value.ulValue = new unsigned long (ulValue);
00191 isValueValid_=valid;
00192 }
00193
00194 inline
00195 void
00196 TypeContainer::setValue(float fValue,bool valid)
00197 {
00198 deleteValue();
00199 Value.fValue = new float;
00200 *(Value.fValue) = fValue;
00201 isValueValid_=valid;
00202 }
00203
00204 inline
00205 void
00206 TypeContainer::setValue(double dbValue,bool valid)
00207 {
00208 deleteValue();
00209 Value.dbValue = new double;
00210 *(Value.dbValue) = dbValue;
00211 isValueValid_=valid;
00212 }
00213
00214 inline
00215 void
00216 TypeContainer::setValue(bool bValue,bool valid)
00217 {
00218 deleteValue();
00219 Value.bValue = new bool;
00220 *(Value.bValue) = bValue;
00221 isValueValid_=valid;
00222 }
00223
00224 inline
00225 void
00226 TypeContainer::setValue(Qname & qnValue,bool valid)
00227 {
00228 deleteValue();
00229 Value.qnValue = new Qname(qnValue);
00230 isValueValid_=valid;
00231 }
00232
00233 inline
00234 int
00235 TypeContainer::getTypeId()const
00236 {
00237 return typeId_;
00238 }
00239
00240 inline
00241 ContentModel*
00242 TypeContainer::getContentModel()const
00243 {
00244 return cm_;
00245 }
00246
00247 inline
00248 void
00249 TypeContainer::setValAsString(const std::string&v)
00250 {
00251 strVal=v;
00252 }
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263 inline
00264 bool
00265 TypeContainer::isValueValid()const
00266 {
00267 return isValueValid_;
00268 }
00269 }
00270 #endif