Xerces-C++ 3.2.5
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$
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
30class RegularExpression;
31
33{
34public:
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
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
108
117
118 // Constructors and Destructor
119 // -----------------------------------------------------------------------
124
125 //---------------------------------
128
138 static
140 (
141 const XMLCh* const content
142 , DataType datatype
143 , Status& status
144 , XMLVersion version = ver_10
146 );
147
159 static
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
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 //----------------------------------
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 {
228 int f_day;
230 int f_min;
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
252private:
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
#define XMLPARSER_EXPORT
Definition XercesDefs.hpp:163
#define XERCES_CPP_NAMESPACE_BEGIN
Definition XercesDefs.hpp:112
unsigned char XMLByte
Definition XercesDefs.hpp:65
#define XERCES_CPP_NAMESPACE_END
Definition XercesDefs.hpp:113
uint16_t XMLCh
Definition Xerces_autoconf_config.hpp:120
Configurable memory manager.
Definition MemoryManager.hpp:40
Utilities that must be implemented in a class-specific way.
Definition XMLInitializer.hpp:38
static MemoryManager * fgMemoryManager
The configurable memory manager.
Definition PlatformUtils.hpp:121
This class makes it possible to override the C++ memory management by adding new/delete operators to ...
Definition XMemory.hpp:41
Definition XSValue.hpp:33
Status
Definition XSValue.hpp:89
@ st_FOCA0003
Definition XSValue.hpp:98
@ st_CantCreateRegEx
Definition XSValue.hpp:95
@ st_Init
Definition XSValue.hpp:90
@ st_NotSupported
Definition XSValue.hpp:94
@ st_FOCA0002
Definition XSValue.hpp:96
@ st_NoContent
Definition XSValue.hpp:91
@ st_FOCA0001
Definition XSValue.hpp:97
@ st_NoCanRep
Definition XSValue.hpp:92
@ st_FODT0003
Definition XSValue.hpp:99
@ st_NoActVal
Definition XSValue.hpp:93
static XSValue * getActualValue(const XMLCh *const content, DataType datatype, Status &status, XMLVersion version=ver_10, bool toValidate=true, MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager)
Get the actual value, in the form of XSValue, for a given string of the data type specified.
static bool validate(const XMLCh *const content, DataType datatype, Status &status, XMLVersion version=ver_10, MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager)
Validate a given string of the data type specified.
DataGroup
Definition XSValue.hpp:103
@ dg_datetimes
Definition XSValue.hpp:105
@ dg_numerics
Definition XSValue.hpp:104
DoubleFloatType
Definition XSValue.hpp:110
@ DoubleFloatType_Zero
Definition XSValue.hpp:114
@ DoubleFloatType_NegINF
Definition XSValue.hpp:111
@ DoubleFloatType_NaN
Definition XSValue.hpp:113
@ DoubleFloatType_PosINF
Definition XSValue.hpp:112
XMLVersion
Definition XSValue.hpp:84
@ ver_10
Definition XSValue.hpp:85
static XMLCh * getCanonicalRepresentation(const XMLCh *const content, DataType datatype, Status &status, XMLVersion version=ver_10, bool toValidate=true, MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager)
Get the canonical representation for a given string of the data type specified.
DataType
Definition XSValue.hpp:36
static DataType getDataType(const XMLCh *const dtString)
public data
Definition XSValue.hpp:202
DoubleFloatType f_floatEnum
Definition XSValue.hpp:243
long f_long
Definition XSValue.hpp:214
unsigned short f_ushort
Definition XSValue.hpp:211
int f_hour
Definition XSValue.hpp:229
bool f_bool
Definition XSValue.hpp:207
char f_char
Definition XSValue.hpp:208
double f_milisec
Definition XSValue.hpp:232
XMLByte * f_byteVal
Definition XSValue.hpp:219
DataType f_datatype
Definition XSValue.hpp:204
int f_month
Definition XSValue.hpp:227
DoubleFloatType f_doubleEnum
Definition XSValue.hpp:238
int f_year
Definition XSValue.hpp:226
int f_second
Definition XSValue.hpp:231
unsigned long f_ulong
Definition XSValue.hpp:215
double f_double
Definition XSValue.hpp:217
float f_float
Definition XSValue.hpp:216
int f_day
Definition XSValue.hpp:228
unsigned int f_uint
Definition XSValue.hpp:213
XMLCh * f_strVal
Definition XSValue.hpp:218
short f_short
Definition XSValue.hpp:210
unsigned char f_uchar
Definition XSValue.hpp:209
double f_dvalue
Definition XSValue.hpp:222
int f_min
Definition XSValue.hpp:230
int f_int
Definition XSValue.hpp:212