XSValue.hpp
Go to the documentation of this file.
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id$
*/
#if !defined(XERCESC_INCLUDE_GUARD_XSVALUE_HPP)
#define XERCESC_INCLUDE_GUARD_XSVALUE_HPP
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/util/ValueHashTableOf.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class RegularExpression;
class XMLPARSER_EXPORT XSValue : public XMemory
{
public:
enum DataType {
dt_string = 0,
dt_boolean = 1,
dt_decimal = 2,
dt_float = 3,
dt_double = 4,
dt_duration = 5,
dt_dateTime = 6,
dt_time = 7,
dt_date = 8,
dt_gYearMonth = 9,
dt_gYear = 10,
dt_gMonthDay = 11,
dt_gDay = 12,
dt_gMonth = 13,
dt_hexBinary = 14,
dt_base64Binary = 15,
dt_anyURI = 16,
dt_QName = 17,
dt_NOTATION = 18,
dt_normalizedString = 19,
dt_token = 20,
dt_language = 21,
dt_NMTOKEN = 22,
dt_NMTOKENS = 23,
dt_Name = 24,
dt_NCName = 25,
dt_ID = 26,
dt_IDREF = 27,
dt_IDREFS = 28,
dt_ENTITY = 29,
dt_ENTITIES = 30,
dt_integer = 31,
dt_nonPositiveInteger = 32,
dt_negativeInteger = 33,
dt_long = 34,
dt_int = 35,
dt_short = 36,
dt_byte = 37,
dt_nonNegativeInteger = 38,
dt_unsignedLong = 39,
dt_unsignedInt = 40,
dt_unsignedShort = 41,
dt_unsignedByte = 42,
dt_positiveInteger = 43,
dt_MAXCOUNT = 44
};
enum XMLVersion {
ver_10,
ver_11
};
enum Status {
st_Init,
st_NoContent,
st_NoCanRep,
st_NoActVal,
st_NotSupported,
st_CantCreateRegEx,
st_FOCA0002, //invalid lexical value
st_FOCA0001, //input value too large/too small for decimal
st_FOCA0003, //input value too large for integer
st_FODT0003, //invalid timezone value
st_UnknownType
};
enum DataGroup {
dg_numerics,
dg_datetimes,
dg_strings
};
enum DoubleFloatType
{
DoubleFloatType_NegINF,
DoubleFloatType_PosINF,
DoubleFloatType_NaN,
DoubleFloatType_Zero,
DoubleFloatType_Normal
};
// Constructors and Destructor
// -----------------------------------------------------------------------
~XSValue();
//---------------------------------
static
bool validate
(
const XMLCh* const content
, DataType datatype
, Status& status
, XMLVersion version = ver_10
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
static
XMLCh* getCanonicalRepresentation
(
const XMLCh* const content
, DataType datatype
, Status& status
, XMLVersion version = ver_10
, bool toValidate = true
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
static
XSValue* getActualValue
(
const XMLCh* const content
, DataType datatype
, Status& status
, XMLVersion version = ver_10
, bool toValidate = true
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
static
DataType getDataType (const XMLCh* const dtString);
//----------------------------------
struct XSValue_Data {
DataType f_datatype;
union {
bool f_bool;
char f_char;
unsigned char f_uchar;
short f_short;
unsigned short f_ushort;
int f_int;
unsigned int f_uint;
long f_long;
unsigned long f_ulong;
float f_float;
double f_double;
XMLCh* f_strVal;
XMLByte* f_byteVal;
struct decimal {
double f_dvalue;
} f_decimal;
struct datetime {
int f_year;
int f_month;
int f_day;
int f_hour;
int f_min;
int f_second;
double f_milisec;
} f_datetime;
struct doubletype {
double f_double;
DoubleFloatType f_doubleEnum;
} f_doubleType;
struct floattype {
float f_float;
DoubleFloatType f_floatEnum;
} f_floatType;
} fValue;
} fData;
private:
typedef union
{
long f_long;
unsigned long f_ulong;
} t_value;
XSValue(
DataType const dt
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
);
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
XSValue(const XSValue&);
XSValue & operator=(const XSValue &);
//---------------------------------
static const XSValue::DataGroup inGroup[];
static const bool numericSign[];
static
bool validateNumerics
(
const XMLCh* const content
, DataType datatype
, Status& status
, MemoryManager* const manager
);
static
bool validateDateTimes
(
const XMLCh* const content
, DataType datatype
, Status& status
, MemoryManager* const manager
);
static
bool validateStrings
(
const XMLCh* const content
, DataType datatype
, Status& status
, XMLVersion version
, MemoryManager* const manager
);
static
XMLCh* getCanRepNumerics
(
const XMLCh* const content
, DataType datatype
, Status& status
, bool toValidate
, MemoryManager* const manager
);
static
XMLCh* getCanRepDateTimes
(
const XMLCh* const content
, DataType datatype
, Status& status
, bool toValidate
, MemoryManager* const manager
);
static
XMLCh* getCanRepStrings
(
const XMLCh* const content
, DataType datatype
, Status& status
, XMLVersion version
, bool toValidate
, MemoryManager* const manager
);
static
XSValue* getActValNumerics
(
const XMLCh* const content
, DataType datatype
, Status& status
, bool toValidate
, MemoryManager* const manager
);
static
XSValue* getActValDateTimes
(
const XMLCh* const content
, DataType datatype
, Status& status
, MemoryManager* const manager
);
static
XSValue* getActValStrings
(
const XMLCh* const content
, DataType datatype
, Status& status
, XMLVersion version
, bool toValidate
, MemoryManager* const manager
);
static
bool getActualNumericValue
(
const XMLCh* const content
, Status& status
, t_value& retVal
, MemoryManager* const manager
, DataType datatype
);
static ValueHashTableOf<DataType>* fDataTypeRegistry;
// -----------------------------------------------------------------------
// static helper methods
// -----------------------------------------------------------------------
static void initializeRegistry();
friend class XMLInitializer;
// -----------------------------------------------------------------------
// data members
// -----------------------------------------------------------------------
bool fMemAllocated;
MemoryManager* fMemoryManager;
};
XERCES_CPP_NAMESPACE_END
#endif
XMemory
This class makes it possible to override the C++ memory management by adding new/delete operators to ...
Definition: XMemory.hpp:40
XSValue::XSValue_Data::f_uint
unsigned int f_uint
Definition: XSValue.hpp:213
XERCES_CPP_NAMESPACE_BEGIN
#define XERCES_CPP_NAMESPACE_BEGIN
Definition: XercesDefs.hpp:112
XSValue::st_FOCA0001
@ st_FOCA0001
Definition: XSValue.hpp:97
XSValue::XSValue_Data::f_float
float f_float
Definition: XSValue.hpp:216
XSValue::DoubleFloatType
DoubleFloatType
Definition: XSValue.hpp:109
XSValue::XSValue_Data::f_dvalue
double f_dvalue
Definition: XSValue.hpp:222
XSValue::Status
Status
Definition: XSValue.hpp:89
XSValue::XSValue_Data::f_year
int f_year
Definition: XSValue.hpp:226
XSValue::XSValue_Data::f_long
long f_long
Definition: XSValue.hpp:214
XSValue::XSValue_Data::f_ushort
unsigned short f_ushort
Definition: XSValue.hpp:211
XSValue::DataGroup
DataGroup
Definition: XSValue.hpp:103
XERCES_CPP_NAMESPACE_END
#define XERCES_CPP_NAMESPACE_END
Definition: XercesDefs.hpp:113
XSValue::XSValue_Data::f_milisec
double f_milisec
Definition: XSValue.hpp:232
XSValue::st_FOCA0002
@ st_FOCA0002
Definition: XSValue.hpp:96
XSValue::XSValue_Data::f_day
int f_day
Definition: XSValue.hpp:228
XSValue::XSValue_Data::f_byteVal
XMLByte * f_byteVal
Definition: XSValue.hpp:219
XMLByte
unsigned char XMLByte
Definition: XercesDefs.hpp:65
XSValue::XSValue_Data::f_doubleEnum
DoubleFloatType f_doubleEnum
Definition: XSValue.hpp:238
XSValue::XSValue_Data
public data
Definition: XSValue.hpp:202
XSValue::st_NoActVal
@ st_NoActVal
Definition: XSValue.hpp:93
PlatformUtils.hpp
XSValue::XSValue_Data::f_strVal
XMLCh * f_strVal
Definition: XSValue.hpp:218
XSValue::DoubleFloatType_PosINF
@ DoubleFloatType_PosINF
Definition: XSValue.hpp:112
XSValue::XSValue_Data::f_short
short f_short
Definition: XSValue.hpp:210
XSValue::st_NotSupported
@ st_NotSupported
Definition: XSValue.hpp:94
XMLCh
uint16_t XMLCh
Definition: Xerces_autoconf_config.hpp:120
XSValue::XSValue_Data::f_bool
bool f_bool
Definition: XSValue.hpp:207
XSValue::dg_datetimes
@ dg_datetimes
Definition: XSValue.hpp:105
XMLPlatformUtils::fgMemoryManager
static MemoryManager * fgMemoryManager
The configurable memory manager.
Definition: PlatformUtils.hpp:121
XSValue::XSValue_Data::f_uchar
unsigned char f_uchar
Definition: XSValue.hpp:209
XSValue::XSValue_Data::f_hour
int f_hour
Definition: XSValue.hpp:229
XSValue::st_CantCreateRegEx
@ st_CantCreateRegEx
Definition: XSValue.hpp:95
XSValue::XSValue_Data::f_ulong
unsigned long f_ulong
Definition: XSValue.hpp:215
XMLInitializer
Utilities that must be implemented in a class-specific way.
Definition: XMLInitializer.hpp:37
XSValue::XSValue_Data::f_floatEnum
DoubleFloatType f_floatEnum
Definition: XSValue.hpp:243
XSValue::st_NoCanRep
@ st_NoCanRep
Definition: XSValue.hpp:92
XSValue::st_FODT0003
@ st_FODT0003
Definition: XSValue.hpp:99
XSValue::XSValue_Data::f_second
int f_second
Definition: XSValue.hpp:231
XSValue
Definition: XSValue.hpp:32
XSValue::XMLVersion
XMLVersion
Definition: XSValue.hpp:84
XSValue::DoubleFloatType_NaN
@ DoubleFloatType_NaN
Definition: XSValue.hpp:113
XSValue::st_Init
@ st_Init
Definition: XSValue.hpp:90
XSValue::XSValue_Data::f_double
double f_double
Definition: XSValue.hpp:217
XSValue::DataType
DataType
Definition: XSValue.hpp:36
XSValue::XSValue_Data::f_int
int f_int
Definition: XSValue.hpp:212
XSValue::XSValue_Data::f_datatype
DataType f_datatype
Definition: XSValue.hpp:204
XSValue::st_NoContent
@ st_NoContent
Definition: XSValue.hpp:91
XSValue::st_FOCA0003
@ st_FOCA0003
Definition: XSValue.hpp:98
MemoryManager
Configurable memory manager.
Definition: MemoryManager.hpp:39
XSValue::XSValue_Data::f_char
char f_char
Definition: XSValue.hpp:208
XMLPARSER_EXPORT
#define XMLPARSER_EXPORT
Definition: XercesDefs.hpp:163
XSValue::ver_10
@ ver_10
Definition: XSValue.hpp:85
XSValue::DoubleFloatType_NegINF
@ DoubleFloatType_NegINF
Definition: XSValue.hpp:111
XSValue::DoubleFloatType_Zero
@ DoubleFloatType_Zero
Definition: XSValue.hpp:114
XSValue::dg_numerics
@ dg_numerics
Definition: XSValue.hpp:104
XSValue::XSValue_Data::f_month
int f_month
Definition: XSValue.hpp:227
XSValue::XSValue_Data::f_min
int f_min
Definition: XSValue.hpp:230