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