http://xml.apache.org/http://www.apache.org/http://www.w3.org/

Home

Readme
Release Info

Installation
Download
Build

FAQs
Samples
API Docs

DOM C++ Binding
Programming
Migration Guide

Feedback
Bug-Reporting
PDF Document

CVS Repository
Mail Archive

API Docs for SAX and DOM
 

Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

XSValue.hpp

Go to the documentation of this file.
00001 /*
00002  * Copyright 2004,2004 The Apache Software Foundation.
00003  * 
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  * 
00008  *      http://www.apache.org/licenses/LICENSE-2.0
00009  * 
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 /*
00018  * $Log: XSValue.hpp,v $
00019  * Revision 1.12  2004/09/23 21:22:47  peiyongz
00020  * Documentation
00021  * st_noContent added
00022  * unused parameter removed
00023  *
00024  * Revision 1.11  2004/09/13 21:24:20  peiyongz
00025  * 1. returned data to contain datatype in addition to value
00026  * 2. registry to map type name (in string) to type name enum
00027  *
00028  * Revision 1.10  2004/09/09 20:08:31  peiyongz
00029  * Using new error code
00030  *
00031  * Revision 1.9  2004/09/08 19:56:05  peiyongz
00032  * Remove parameter toValidate from validation interface
00033  *
00034  * Revision 1.8  2004/09/08 13:56:09  peiyongz
00035  * Apache License Version 2.0
00036  *
00037  * Revision 1.7  2004/08/31 20:52:25  peiyongz
00038  * Return additional double value for decimal
00039  * remove tz_hh/tz_mm
00040  *
00041  * Revision 1.6  2004/08/31 15:14:47  peiyongz
00042  * remove XSValueContext
00043  *
00044  * Revision 1.5  2004/08/17 21:11:41  peiyongz
00045  * no more Unrepresentable
00046  *
00047  * Revision 1.4  2004/08/13 21:29:20  peiyongz
00048  * fMemAllocated
00049  *
00050  * Revision 1.3  2004/08/12 14:24:34  peiyongz
00051  * HP aCC A.03
00052  *
00053  * Revision 1.2  2004/08/11 17:06:44  peiyongz
00054  * Do not panic if can't create RegEx
00055  *
00056  * $Id: XSValue.hpp,v 1.12 2004/09/23 21:22:47 peiyongz Exp $
00057  */
00058 
00059 #if !defined(XSVALUE_HPP)
00060 #define XSVALUE_HPP
00061 
00062 #include <xercesc/util/PlatformUtils.hpp>
00063 #include <xercesc/util/RefHashTableOf.hpp>
00064 
00065 XERCES_CPP_NAMESPACE_BEGIN
00066 
00067 class RegularExpression;
00068 
00069 class  XSValue : public XMemory
00070 {
00071 public:
00072 
00073     enum DataType {
00074               dt_string               = 0,
00075               dt_boolean              = 1,
00076               dt_decimal              = 2,
00077               dt_float                = 3,
00078               dt_double               = 4,
00079               dt_duration             = 5,
00080               dt_dateTime             = 6,
00081               dt_time                 = 7,
00082               dt_date                 = 8,
00083               dt_gYearMonth           = 9,
00084               dt_gYear                = 10,
00085               dt_gMonthDay            = 11,
00086               dt_gDay                 = 12,
00087               dt_gMonth               = 13,
00088               dt_hexBinary            = 14,
00089               dt_base64Binary         = 15,
00090               dt_anyURI               = 16,
00091               dt_QName                = 17,
00092               dt_NOTATION             = 18,
00093               dt_normalizedString     = 19,
00094               dt_token                = 20,
00095               dt_language             = 21,
00096               dt_NMTOKEN              = 22,
00097               dt_NMTOKENS             = 23,
00098               dt_Name                 = 24,
00099               dt_NCName               = 25,
00100               dt_ID                   = 26,
00101               dt_IDREF                = 27,
00102               dt_IDREFS               = 28,
00103               dt_ENTITY               = 29,
00104               dt_ENTITIES             = 30,
00105               dt_integer              = 31,
00106               dt_nonPositiveInteger   = 32,
00107               dt_negativeInteger      = 33,
00108               dt_long                 = 34,
00109               dt_int                  = 35,
00110               dt_short                = 36,
00111               dt_byte                 = 37,
00112               dt_nonNegativeInteger   = 38,
00113               dt_unsignedLong         = 39,
00114               dt_unsignedInt          = 40,
00115               dt_unsignedShort        = 41,
00116               dt_unsignedByte         = 42,
00117               dt_positiveInteger      = 43,
00118               dt_MAXCOUNT             = 44
00119     };
00120 
00121     enum XMLVersion {
00122             ver_10,
00123             ver_11
00124     };
00125 
00126     enum Status {
00127             st_Init,
00128             st_InvalidRange,
00129             st_NoContent,
00130             st_NoCanRep,
00131             st_NoActVal,
00132             st_NotSupported,
00133             st_CantCreateRegEx,
00134             st_FOCA0002,        //invalid lexical value 
00135             st_FOCA0001,        //input value too large for decimal 
00136             st_FOCA0003,        //input value too large for integer 
00137             st_FODT0003,        //invalid timezone value 
00138             st_UnknownType
00139     };
00140 
00141     enum DataGroup {
00142             dg_numerics,
00143             dg_datetimes,
00144             dg_strings
00145     };
00146 
00147     //  Constructors and Destructor
00148     // -----------------------------------------------------------------------
00151     ~XSValue();
00153 
00154     //---------------------------------
00157 
00167     static
00168     bool     validate
00169              (
00170                 const XMLCh*          const content    
00171               ,       DataType              datatype
00172               ,       Status&               status
00173               ,       XMLVersion            version    = ver_10
00174               ,       MemoryManager*  const manager    = XMLPlatformUtils::fgMemoryManager
00175              );
00176 
00188     static
00189     XMLCh*   getCanonicalRepresentation
00190              (
00191                 const XMLCh*          const content    
00192               ,       DataType              datatype
00193               ,       Status&               status
00194               ,       XMLVersion            version    = ver_10
00195               ,       bool                  toValidate = true 
00196               ,       MemoryManager*  const manager    = XMLPlatformUtils::fgMemoryManager
00197              );
00198 
00212     static
00213     XSValue* getActualValue
00214              (
00215                 const XMLCh*          const content    
00216               ,       DataType              datatype
00217               ,       Status&               status
00218               ,       XMLVersion            version    = ver_10
00219               ,       bool                  toValidate = true 
00220               ,       MemoryManager*  const manager    = XMLPlatformUtils::fgMemoryManager
00221              );
00222 
00223     static
00224     DataType  getDataType  (const XMLCh* const dtString);
00225 
00227 
00228     //----------------------------------
00231     struct {
00232 
00233         DataType f_datatype;
00234         
00235         union {
00236                          bool      f_bool;
00237                          char      f_char;                    
00238                 unsigned char      f_uchar;
00239                          short     f_short;
00240                 unsigned short     f_ushort;
00241                          int       f_int;
00242                 unsigned int       f_uint;
00243                          long      f_long;
00244                 unsigned long      f_ulong;
00245                          float     f_float;
00246                          double    f_double;
00247                          XMLCh*    f_strVal;
00248 
00249                 struct decimal {
00250                                 int              f_sign;
00251                                 unsigned int     f_scale;  
00252                                 unsigned long    f_integral;
00253                                 unsigned long    f_fraction;
00254                                 double           f_dvalue;
00255                 } f_decimal;
00256 
00257                 struct datetime {
00258                                 int       f_year;
00259                                 int       f_month;
00260                                 int       f_day;
00261                                 int       f_hour;
00262                                 int       f_min;
00263                                 int       f_second;
00264                                 double    f_milisec;
00265 
00266                 } f_datetime;
00267 
00268         } fValue;
00269 
00270     } fData;
00271 
00272     static
00273     void reinitMutex();
00274 
00275     static
00276     void reinitRegEx();
00277 
00278     static
00279     void reinitRegistry();
00280 
00281 private:
00282 
00283     typedef union
00284     {
00285                 long  f_long;
00286        unsigned long  f_ulong;
00287     } t_value;
00288 
00295     XSValue(
00296              DataType        const dt
00297            , MemoryManager*  const manager = XMLPlatformUtils::fgMemoryManager
00298            );
00299 
00301 
00302     // -----------------------------------------------------------------------
00303     //  Unimplemented constructors and operators
00304     // -----------------------------------------------------------------------
00305     XSValue(const XSValue&);
00306     XSValue & operator=(const XSValue &);
00307 
00308     //---------------------------------
00312 
00313     static const XSValue::DataGroup inGroup[];
00314 
00316 
00317     static
00318     bool     validateNumerics
00319              (
00320                 const XMLCh*          const content    
00321               ,       DataType              datatype
00322               ,       Status&               status
00323               ,       XMLVersion            version
00324               ,       MemoryManager*  const manager
00325              );
00326 
00327     static
00328     bool     validateDateTimes
00329              (
00330                 const XMLCh*          const content    
00331               ,       DataType              datatype
00332               ,       Status&               status
00333               ,       XMLVersion            version
00334               ,       MemoryManager*  const manager
00335              );
00336 
00337     static
00338     bool     validateStrings
00339              (
00340                 const XMLCh*          const content    
00341               ,       DataType              datatype
00342               ,       Status&               status
00343               ,       XMLVersion            version
00344               ,       MemoryManager*  const manager
00345              );
00346 
00347     static
00348     XMLCh*   getCanRepNumerics
00349              (
00350                 const XMLCh*          const content    
00351               ,       DataType              datatype
00352               ,       Status&               status
00353               ,       XMLVersion            version
00354               ,       bool                  toValidate
00355               ,       MemoryManager*  const manager
00356              );
00357 
00358     static
00359     XMLCh*   getCanRepDateTimes
00360              (
00361                 const XMLCh*          const content    
00362               ,       DataType              datatype
00363               ,       Status&               status
00364               ,       XMLVersion            version
00365               ,       bool                  toValidate
00366               ,       MemoryManager*  const manager
00367              );
00368 
00369     static
00370     XMLCh*   getCanRepStrings
00371              (
00372                 const XMLCh*          const content    
00373               ,       DataType              datatype
00374               ,       Status&               status
00375               ,       XMLVersion            version
00376               ,       bool                  toValidate
00377               ,       MemoryManager*  const manager
00378              );
00379 
00380     static
00381     XSValue*  getActValNumerics
00382              (
00383                 const XMLCh*          const content    
00384               ,       DataType              datatype
00385               ,       Status&               status
00386               ,       XMLVersion            version
00387               ,       MemoryManager*  const manager
00388              );
00389 
00390     static
00391     XSValue*  getActValDateTimes
00392              (
00393                 const XMLCh*          const content    
00394               ,       DataType              datatype
00395               ,       Status&               status
00396               ,       XMLVersion            version
00397               ,       MemoryManager*  const manager
00398              );
00399 
00400     static
00401     XSValue*  getActValStrings
00402              (
00403                 const XMLCh*          const content    
00404               ,       DataType              datatype
00405               ,       Status&               status
00406               ,       XMLVersion            version
00407               ,       bool                  toValidate
00408               ,       MemoryManager*  const manager
00409              );
00410 
00411     static
00412     bool      getActualValue
00413               (
00414                  const XMLCh*         const content
00415                ,       Status&               status
00416                ,       XMLVersion            version    
00417                ,       int                   ct
00418                ,       t_value&              retVal               
00419                ,       int                   base
00420                ,       MemoryManager* const  manager
00421                );
00422 
00423     static RefHashTableOf<XSValue>*    fDataTypeRegistry;
00424 
00425     // -----------------------------------------------------------------------
00426     //  data members
00427     // -----------------------------------------------------------------------
00428     bool                fMemAllocated;
00429     MemoryManager*      fMemoryManager;
00430 
00431 };
00432 
00433 XERCES_CPP_NAMESPACE_END
00434 
00435 #endif


Copyright © 1994-2004 The Apache Software Foundation. All Rights Reserved.