00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #if !defined(XERCESC_INCLUDE_GUARD_XSVALUE_HPP)
00023 #define XERCESC_INCLUDE_GUARD_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 XMLPARSER_EXPORT 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 private:
00253
00254 typedef union
00255 {
00256 long f_long;
00257 unsigned long f_ulong;
00258 } t_value;
00259
00266 XSValue(
00267 DataType const dt
00268 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
00269 );
00270
00272
00273
00274
00275
00276 XSValue(const XSValue&);
00277 XSValue & operator=(const XSValue &);
00278
00279
00283
00284 static const XSValue::DataGroup inGroup[];
00285 static const bool numericSign[];
00286
00288
00289 static
00290 bool validateNumerics
00291 (
00292 const XMLCh* const content
00293 , DataType datatype
00294 , Status& status
00295 , MemoryManager* const manager
00296 );
00297
00298 static
00299 bool validateDateTimes
00300 (
00301 const XMLCh* const content
00302 , DataType datatype
00303 , Status& status
00304 , MemoryManager* const manager
00305 );
00306
00307 static
00308 bool validateStrings
00309 (
00310 const XMLCh* const content
00311 , DataType datatype
00312 , Status& status
00313 , XMLVersion version
00314 , MemoryManager* const manager
00315 );
00316
00317 static
00318 XMLCh* getCanRepNumerics
00319 (
00320 const XMLCh* const content
00321 , DataType datatype
00322 , Status& status
00323 , bool toValidate
00324 , MemoryManager* const manager
00325 );
00326
00327 static
00328 XMLCh* getCanRepDateTimes
00329 (
00330 const XMLCh* const content
00331 , DataType datatype
00332 , Status& status
00333 , bool toValidate
00334 , MemoryManager* const manager
00335 );
00336
00337 static
00338 XMLCh* getCanRepStrings
00339 (
00340 const XMLCh* const content
00341 , DataType datatype
00342 , Status& status
00343 , XMLVersion version
00344 , bool toValidate
00345 , MemoryManager* const manager
00346 );
00347
00348 static
00349 XSValue* getActValNumerics
00350 (
00351 const XMLCh* const content
00352 , DataType datatype
00353 , Status& status
00354 , bool toValidate
00355 , MemoryManager* const manager
00356 );
00357
00358 static
00359 XSValue* getActValDateTimes
00360 (
00361 const XMLCh* const content
00362 , DataType datatype
00363 , Status& status
00364 , MemoryManager* const manager
00365 );
00366
00367 static
00368 XSValue* getActValStrings
00369 (
00370 const XMLCh* const content
00371 , DataType datatype
00372 , Status& status
00373 , XMLVersion version
00374 , bool toValidate
00375 , MemoryManager* const manager
00376 );
00377
00378 static
00379 bool getActualNumericValue
00380 (
00381 const XMLCh* const content
00382 , Status& status
00383 , t_value& retVal
00384 , MemoryManager* const manager
00385 , DataType datatype
00386 );
00387
00388 static ValueHashTableOf<DataType>* fDataTypeRegistry;
00389
00390
00391
00392
00393 static void initializeRegistry();
00394 friend class XMLInitializer;
00395
00396
00397
00398
00399 bool fMemAllocated;
00400 MemoryManager* fMemoryManager;
00401
00402 };
00403
00404 XERCES_CPP_NAMESPACE_END
00405
00406 #endif