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