Xerces-C++  3.1.2
XSValue.hpp
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 /*
19  * $Id: XSValue.hpp 932887 2010-04-11 13:04:59Z borisk $
20  */
21 
22 #if !defined(XERCESC_INCLUDE_GUARD_XSVALUE_HPP)
23 #define XERCESC_INCLUDE_GUARD_XSVALUE_HPP
24 
26 #include <xercesc/util/ValueHashTableOf.hpp>
27 
29 
30 class RegularExpression;
31 
33 {
34 public:
35 
36  enum DataType {
37  dt_string = 0,
38  dt_boolean = 1,
39  dt_decimal = 2,
40  dt_float = 3,
41  dt_double = 4,
42  dt_duration = 5,
43  dt_dateTime = 6,
44  dt_time = 7,
45  dt_date = 8,
46  dt_gYearMonth = 9,
47  dt_gYear = 10,
48  dt_gMonthDay = 11,
49  dt_gDay = 12,
50  dt_gMonth = 13,
51  dt_hexBinary = 14,
52  dt_base64Binary = 15,
53  dt_anyURI = 16,
54  dt_QName = 17,
55  dt_NOTATION = 18,
56  dt_normalizedString = 19,
57  dt_token = 20,
58  dt_language = 21,
59  dt_NMTOKEN = 22,
60  dt_NMTOKENS = 23,
61  dt_Name = 24,
62  dt_NCName = 25,
63  dt_ID = 26,
64  dt_IDREF = 27,
65  dt_IDREFS = 28,
66  dt_ENTITY = 29,
67  dt_ENTITIES = 30,
68  dt_integer = 31,
69  dt_nonPositiveInteger = 32,
70  dt_negativeInteger = 33,
71  dt_long = 34,
72  dt_int = 35,
73  dt_short = 36,
74  dt_byte = 37,
75  dt_nonNegativeInteger = 38,
76  dt_unsignedLong = 39,
77  dt_unsignedInt = 40,
78  dt_unsignedShort = 41,
79  dt_unsignedByte = 42,
80  dt_positiveInteger = 43,
81  dt_MAXCOUNT = 44
82  };
83 
84  enum XMLVersion {
86  ver_11
87  };
88 
89  enum Status {
96  st_FOCA0002, //invalid lexical value
97  st_FOCA0001, //input value too large/too small for decimal
98  st_FOCA0003, //input value too large for integer
99  st_FODT0003, //invalid timezone value
100  st_UnknownType
101  };
102 
103  enum DataGroup {
106  dg_strings
107  };
108 
110  {
115  DoubleFloatType_Normal
116  };
117 
118  // Constructors and Destructor
119  // -----------------------------------------------------------------------
122  ~XSValue();
124 
125  //---------------------------------
128 
138  static
139  bool validate
140  (
141  const XMLCh* const content
142  , DataType datatype
143  , Status& status
144  , XMLVersion version = ver_10
146  );
147 
159  static
160  XMLCh* getCanonicalRepresentation
161  (
162  const XMLCh* const content
163  , DataType datatype
164  , Status& status
165  , XMLVersion version = ver_10
166  , bool toValidate = true
168  );
169 
183  static
184  XSValue* getActualValue
185  (
186  const XMLCh* const content
187  , DataType datatype
188  , Status& status
189  , XMLVersion version = ver_10
190  , bool toValidate = true
192  );
193 
194  static
195  DataType getDataType (const XMLCh* const dtString);
196 
198 
199  //----------------------------------
202  struct XSValue_Data {
203 
205 
206  union {
207  bool f_bool;
208  char f_char;
209  unsigned char f_uchar;
210  short f_short;
211  unsigned short f_ushort;
212  int f_int;
213  unsigned int f_uint;
214  long f_long;
215  unsigned long f_ulong;
216  float f_float;
217  double f_double;
220 
221  struct decimal {
222  double f_dvalue;
223  } f_decimal;
224 
225  struct datetime {
226  int f_year;
227  int f_month;
228  int f_day;
229  int f_hour;
230  int f_min;
231  int f_second;
232  double f_milisec;
233 
234  } f_datetime;
235 
236  struct doubletype {
237  double f_double;
239  } f_doubleType;
240 
241  struct floattype {
242  float f_float;
244  } f_floatType;
245 
246 
247 
248  } fValue;
249 
250  } fData;
251 
252 private:
253 
254  typedef union
255  {
256  long f_long;
257  unsigned long f_ulong;
258  } t_value;
259 
266  XSValue(
267  DataType const dt
269  );
270 
272 
273  // -----------------------------------------------------------------------
274  // Unimplemented constructors and operators
275  // -----------------------------------------------------------------------
276  XSValue(const XSValue&);
277  XSValue & operator=(const XSValue &);
278 
279  //---------------------------------
283 
284  static const XSValue::DataGroup inGroup[];
285  static const bool numericSign[];
286 
288 
289  static
290  bool validateNumerics
291  (
292  const XMLCh* const content
293  , DataType datatype
294  , Status& status
295  , MemoryManager* const manager
296  );
297 
298  static
299  bool validateDateTimes
300  (
301  const XMLCh* const content
302  , DataType datatype
303  , Status& status
304  , MemoryManager* const manager
305  );
306 
307  static
308  bool validateStrings
309  (
310  const XMLCh* const content
311  , DataType datatype
312  , Status& status
313  , XMLVersion version
314  , MemoryManager* const manager
315  );
316 
317  static
318  XMLCh* getCanRepNumerics
319  (
320  const XMLCh* const content
321  , DataType datatype
322  , Status& status
323  , bool toValidate
324  , MemoryManager* const manager
325  );
326 
327  static
328  XMLCh* getCanRepDateTimes
329  (
330  const XMLCh* const content
331  , DataType datatype
332  , Status& status
333  , bool toValidate
334  , MemoryManager* const manager
335  );
336 
337  static
338  XMLCh* getCanRepStrings
339  (
340  const XMLCh* const content
341  , DataType datatype
342  , Status& status
343  , XMLVersion version
344  , bool toValidate
345  , MemoryManager* const manager
346  );
347 
348  static
349  XSValue* getActValNumerics
350  (
351  const XMLCh* const content
352  , DataType datatype
353  , Status& status
354  , bool toValidate
355  , MemoryManager* const manager
356  );
357 
358  static
359  XSValue* getActValDateTimes
360  (
361  const XMLCh* const content
362  , DataType datatype
363  , Status& status
364  , MemoryManager* const manager
365  );
366 
367  static
368  XSValue* getActValStrings
369  (
370  const XMLCh* const content
371  , DataType datatype
372  , Status& status
373  , XMLVersion version
374  , bool toValidate
375  , MemoryManager* const manager
376  );
377 
378  static
379  bool getActualNumericValue
380  (
381  const XMLCh* const content
382  , Status& status
383  , t_value& retVal
384  , MemoryManager* const manager
385  , DataType datatype
386  );
387 
388  static ValueHashTableOf<DataType>* fDataTypeRegistry;
389 
390  // -----------------------------------------------------------------------
391  // static helper methods
392  // -----------------------------------------------------------------------
393  static void initializeRegistry();
394  friend class XMLInitializer;
395 
396  // -----------------------------------------------------------------------
397  // data members
398  // -----------------------------------------------------------------------
399  bool fMemAllocated;
400  MemoryManager* fMemoryManager;
401 
402 };
403 
405 
406 #endif
DataType
Definition: XSValue.hpp:36
Definition: XSValue.hpp:112
DoubleFloatType
Definition: XSValue.hpp:109
DoubleFloatType f_floatEnum
Definition: XSValue.hpp:243
This class makes it possible to override the C++ memory management by adding new/delete operators to ...
Definition: XMemory.hpp:40
Definition: XSValue.hpp:95
static MemoryManager * fgMemoryManager
The configurable memory manager.
Definition: PlatformUtils.hpp:121
Definition: XSValue.hpp:113
unsigned short f_ushort
Definition: XSValue.hpp:211
XMLVersion
Definition: XSValue.hpp:84
short f_short
Definition: XSValue.hpp:210
Definition: XSValue.hpp:98
bool f_bool
Definition: XSValue.hpp:207
Status
Definition: XSValue.hpp:89
int f_day
Definition: XSValue.hpp:228
Utilities that must be implemented in a class-specific way.
Definition: XMLInitializer.hpp:37
public data
Definition: XSValue.hpp:202
Definition: XSValue.hpp:114
Definition: XSValue.hpp:91
XMLCh * f_strVal
Definition: XSValue.hpp:218
Definition: XSValue.hpp:99
double f_dvalue
Definition: XSValue.hpp:222
Definition: XSValue.hpp:90
Definition: XSValue.hpp:32
double f_double
Definition: XSValue.hpp:217
#define XMLPARSER_EXPORT
Definition: XercesDefs.hpp:163
int f_hour
Definition: XSValue.hpp:229
Definition: XSValue.hpp:104
DataType f_datatype
Definition: XSValue.hpp:204
DataGroup
Definition: XSValue.hpp:103
Configurable memory manager.
Definition: MemoryManager.hpp:39
Definition: XSValue.hpp:85
long f_long
Definition: XSValue.hpp:214
Definition: XSValue.hpp:111
Definition: XSValue.hpp:96
DoubleFloatType f_doubleEnum
Definition: XSValue.hpp:238
#define XERCES_CPP_NAMESPACE_BEGIN
Definition: XercesDefs.hpp:112
char f_char
Definition: XSValue.hpp:208
wchar_t XMLCh
Definition: Xerces_autoconf_config.borland.hpp:92
int f_month
Definition: XSValue.hpp:227
unsigned char f_uchar
Definition: XSValue.hpp:209
unsigned int f_uint
Definition: XSValue.hpp:213
float f_float
Definition: XSValue.hpp:216
unsigned char XMLByte
Definition: XercesDefs.hpp:65
Definition: XSValue.hpp:97
#define XERCES_CPP_NAMESPACE_END
Definition: XercesDefs.hpp:113
int f_year
Definition: XSValue.hpp:226
unsigned long f_ulong
Definition: XSValue.hpp:215
Definition: XSValue.hpp:94
double f_milisec
Definition: XSValue.hpp:232
int f_second
Definition: XSValue.hpp:231
Definition: XSValue.hpp:105
int f_min
Definition: XSValue.hpp:230
Definition: XSValue.hpp:93
int f_int
Definition: XSValue.hpp:212
Definition: XSValue.hpp:92
XMLByte * f_byteVal
Definition: XSValue.hpp:219