00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #if !defined(XSVALUE_HPP)
00023 #define XSVALUE_HPP
00024
00025 #include <xercesc/util/PlatformUtils.hpp>
00026 #include <xercesc/util/ValueHashTableOf.hpp>
00027
00028 XERCES_CPP_NAMESPACE_BEGIN
00029
00030 class RegularExpression;
00031
00032 class XSValue : public XMemory
00033 {
00034 public:
00035
00036 enum DataType {
00037 dt_string = 0,
00038 dt_boolean = 1,
00039 dt_decimal = 2,
00040 dt_float = 3,
00041 dt_double = 4,
00042 dt_duration = 5,
00043 dt_dateTime = 6,
00044 dt_time = 7,
00045 dt_date = 8,
00046 dt_gYearMonth = 9,
00047 dt_gYear = 10,
00048 dt_gMonthDay = 11,
00049 dt_gDay = 12,
00050 dt_gMonth = 13,
00051 dt_hexBinary = 14,
00052 dt_base64Binary = 15,
00053 dt_anyURI = 16,
00054 dt_QName = 17,
00055 dt_NOTATION = 18,
00056 dt_normalizedString = 19,
00057 dt_token = 20,
00058 dt_language = 21,
00059 dt_NMTOKEN = 22,
00060 dt_NMTOKENS = 23,
00061 dt_Name = 24,
00062 dt_NCName = 25,
00063 dt_ID = 26,
00064 dt_IDREF = 27,
00065 dt_IDREFS = 28,
00066 dt_ENTITY = 29,
00067 dt_ENTITIES = 30,
00068 dt_integer = 31,
00069 dt_nonPositiveInteger = 32,
00070 dt_negativeInteger = 33,
00071 dt_long = 34,
00072 dt_int = 35,
00073 dt_short = 36,
00074 dt_byte = 37,
00075 dt_nonNegativeInteger = 38,
00076 dt_unsignedLong = 39,
00077 dt_unsignedInt = 40,
00078 dt_unsignedShort = 41,
00079 dt_unsignedByte = 42,
00080 dt_positiveInteger = 43,
00081 dt_MAXCOUNT = 44
00082 };
00083
00084 enum XMLVersion {
00085 ver_10,
00086 ver_11
00087 };
00088
00089 enum Status {
00090 st_Init,
00091 st_NoContent,
00092 st_NoCanRep,
00093 st_NoActVal,
00094 st_NotSupported,
00095 st_CantCreateRegEx,
00096 st_FOCA0002,
00097 st_FOCA0001,
00098 st_FOCA0003,
00099 st_FODT0003,
00100 st_UnknownType
00101 };
00102
00103 enum DataGroup {
00104 dg_numerics,
00105 dg_datetimes,
00106 dg_strings
00107 };
00108
00109 enum DoubleFloatType
00110 {
00111 DoubleFloatType_NegINF,
00112 DoubleFloatType_PosINF,
00113 DoubleFloatType_NaN,
00114 DoubleFloatType_Zero,
00115 DoubleFloatType_Normal
00116 };
00117
00118
00119
00122 ~XSValue();
00124
00125
00128
00138 static
00139 bool validate
00140 (
00141 const XMLCh* const content
00142 , DataType datatype
00143 , Status& status
00144 , XMLVersion version = ver_10
00145 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
00146 );
00147
00159 static
00160 XMLCh* getCanonicalRepresentation
00161 (
00162 const XMLCh* const content
00163 , DataType datatype
00164 , Status& status
00165 , XMLVersion version = ver_10
00166 , bool toValidate = true
00167 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
00168 );
00169
00183 static
00184 XSValue* getActualValue
00185 (
00186 const XMLCh* const content
00187 , DataType datatype
00188 , Status& status
00189 , XMLVersion version = ver_10
00190 , bool toValidate = true
00191 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
00192 );
00193
00194 static
00195 DataType getDataType (const XMLCh* const dtString);
00196
00198
00199
00202 struct XSValue_Data {
00203
00204 DataType f_datatype;
00205
00206 union {
00207 bool f_bool;
00208 char f_char;
00209 unsigned char f_uchar;
00210 short f_short;
00211 unsigned short f_ushort;
00212 int f_int;
00213 unsigned int f_uint;
00214 long f_long;
00215 unsigned long f_ulong;
00216 float f_float;
00217 double f_double;
00218 XMLCh* f_strVal;
00219 XMLByte* f_byteVal;
00220
00221 struct decimal {
00222 double f_dvalue;
00223 } f_decimal;
00224
00225 struct datetime {
00226 int f_year;
00227 int f_month;
00228 int f_day;
00229 int f_hour;
00230 int f_min;
00231 int f_second;
00232 double f_milisec;
00233
00234 } f_datetime;
00235
00236 struct doubletype {
00237 double f_double;
00238 DoubleFloatType f_doubleEnum;
00239 } f_doubleType;
00240
00241 struct floattype {
00242 float f_float;
00243 DoubleFloatType f_floatEnum;
00244 } f_floatType;
00245
00246
00247
00248 } fValue;
00249
00250 } fData;
00251
00252 static
00253 void reinitMutex();
00254
00255 static
00256 void reinitRegEx();
00257
00258 static
00259 void reinitRegistry();
00260
00261 private:
00262
00263 typedef union
00264 {
00265 long f_long;
00266 unsigned long f_ulong;
00267 } t_value;
00268
00275 XSValue(
00276 DataType const dt
00277 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
00278 );
00279
00281
00282
00283
00284
00285 XSValue(const XSValue&);
00286 XSValue & operator=(const XSValue &);
00287
00288
00292
00293 static const XSValue::DataGroup inGroup[];
00294 static const bool numericSign[];
00295
00297
00298 static
00299 bool validateNumerics
00300 (
00301 const XMLCh* const content
00302 , DataType datatype
00303 , Status& status
00304 , MemoryManager* const manager
00305 );
00306
00307 static
00308 bool validateDateTimes
00309 (
00310 const XMLCh* const content
00311 , DataType datatype
00312 , Status& status
00313 , MemoryManager* const manager
00314 );
00315
00316 static
00317 bool validateStrings
00318 (
00319 const XMLCh* const content
00320 , DataType datatype
00321 , Status& status
00322 , XMLVersion version
00323 , MemoryManager* const manager
00324 );
00325
00326 static
00327 XMLCh* getCanRepNumerics
00328 (
00329 const XMLCh* const content
00330 , DataType datatype
00331 , Status& status
00332 , bool toValidate
00333 , MemoryManager* const manager
00334 );
00335
00336 static
00337 XMLCh* getCanRepDateTimes
00338 (
00339 const XMLCh* const content
00340 , DataType datatype
00341 , Status& status
00342 , bool toValidate
00343 , MemoryManager* const manager
00344 );
00345
00346 static
00347 XMLCh* getCanRepStrings
00348 (
00349 const XMLCh* const content
00350 , DataType datatype
00351 , Status& status
00352 , XMLVersion version
00353 , bool toValidate
00354 , MemoryManager* const manager
00355 );
00356
00357 static
00358 XSValue* getActValNumerics
00359 (
00360 const XMLCh* const content
00361 , DataType datatype
00362 , Status& status
00363 , bool toValidate
00364 , MemoryManager* const manager
00365 );
00366
00367 static
00368 XSValue* getActValDateTimes
00369 (
00370 const XMLCh* const content
00371 , DataType datatype
00372 , Status& status
00373 , MemoryManager* const manager
00374 );
00375
00376 static
00377 XSValue* getActValStrings
00378 (
00379 const XMLCh* const content
00380 , DataType datatype
00381 , Status& status
00382 , XMLVersion version
00383 , bool toValidate
00384 , MemoryManager* const manager
00385 );
00386
00387 static
00388 bool getActualNumericValue
00389 (
00390 const XMLCh* const content
00391 , Status& status
00392 , t_value& retVal
00393 , MemoryManager* const manager
00394 , DataType datatype
00395 );
00396
00397 static ValueHashTableOf<DataType>* fDataTypeRegistry;
00398
00399
00400
00401
00402 static void initializeRegistry();
00403 friend class XMLInitializer;
00404
00405
00406
00407
00408 bool fMemAllocated;
00409 MemoryManager* fMemoryManager;
00410
00411 };
00412
00413 XERCES_CPP_NAMESPACE_END
00414
00415 #endif