Xerces-C++ 3.2.4
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
32class XMLPARSER_EXPORT XSValue : public XMemory
33{
34public:
35
83
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
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 //----------------------------------
201
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
262
266 XSValue(
267 DataType const dt
268 , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
269 );
270
272
273 // -----------------------------------------------------------------------
274 // Unimplemented constructors and operators
275 // -----------------------------------------------------------------------
276 XSValue(const XSValue&);
277 XSValue & operator=(const XSValue &);
278
279 //---------------------------------
281
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
char16_t XMLCh
Definition Xerces_autoconf_config.hpp:120
Configurable memory manager.
Definition MemoryManager.hpp:40
static MemoryManager * fgMemoryManager
The configurable memory manager.
Definition PlatformUtils.hpp:121
XMemory()
Protected default constructor.
Definition XMemory.hpp:130
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_UnknownType
Definition XSValue.hpp:100
@ 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
@ dg_strings
Definition XSValue.hpp:106
DoubleFloatType
Definition XSValue.hpp:110
@ DoubleFloatType_Zero
Definition XSValue.hpp:114
@ DoubleFloatType_Normal
Definition XSValue.hpp:115
@ DoubleFloatType_NegINF
Definition XSValue.hpp:111
@ DoubleFloatType_NaN
Definition XSValue.hpp:113
@ DoubleFloatType_PosINF
Definition XSValue.hpp:112
XMLVersion
Definition XSValue.hpp:84
@ ver_11
Definition XSValue.hpp:86
@ 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
@ dt_string
Definition XSValue.hpp:37
@ dt_gYearMonth
Definition XSValue.hpp:46
@ dt_Name
Definition XSValue.hpp:61
@ dt_gMonthDay
Definition XSValue.hpp:48
@ dt_integer
Definition XSValue.hpp:68
@ dt_gYear
Definition XSValue.hpp:47
@ dt_float
Definition XSValue.hpp:40
@ dt_IDREF
Definition XSValue.hpp:64
@ dt_NCName
Definition XSValue.hpp:62
@ dt_decimal
Definition XSValue.hpp:39
@ dt_time
Definition XSValue.hpp:44
@ dt_int
Definition XSValue.hpp:72
@ dt_anyURI
Definition XSValue.hpp:53
@ dt_token
Definition XSValue.hpp:57
@ dt_NMTOKENS
Definition XSValue.hpp:60
@ dt_negativeInteger
Definition XSValue.hpp:70
@ dt_positiveInteger
Definition XSValue.hpp:80
@ dt_ID
Definition XSValue.hpp:63
@ dt_nonPositiveInteger
Definition XSValue.hpp:69
@ dt_ENTITY
Definition XSValue.hpp:66
@ dt_NMTOKEN
Definition XSValue.hpp:59
@ dt_base64Binary
Definition XSValue.hpp:52
@ dt_short
Definition XSValue.hpp:73
@ dt_date
Definition XSValue.hpp:45
@ dt_IDREFS
Definition XSValue.hpp:65
@ dt_byte
Definition XSValue.hpp:74
@ dt_unsignedLong
Definition XSValue.hpp:76
@ dt_hexBinary
Definition XSValue.hpp:51
@ dt_unsignedInt
Definition XSValue.hpp:77
@ dt_duration
Definition XSValue.hpp:42
@ dt_nonNegativeInteger
Definition XSValue.hpp:75
@ dt_ENTITIES
Definition XSValue.hpp:67
@ dt_unsignedByte
Definition XSValue.hpp:79
@ dt_long
Definition XSValue.hpp:71
@ dt_boolean
Definition XSValue.hpp:38
@ dt_gMonth
Definition XSValue.hpp:50
@ dt_NOTATION
Definition XSValue.hpp:55
@ dt_language
Definition XSValue.hpp:58
@ dt_QName
Definition XSValue.hpp:54
@ dt_MAXCOUNT
Definition XSValue.hpp:81
@ dt_unsignedShort
Definition XSValue.hpp:78
@ dt_normalizedString
Definition XSValue.hpp:56
@ dt_dateTime
Definition XSValue.hpp:43
@ dt_double
Definition XSValue.hpp:41
@ dt_gDay
Definition XSValue.hpp:49
static DataType getDataType(const XMLCh *const dtString)
friend class XMLInitializer
Definition XSValue.hpp:394
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