00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef _ANYATOMICTYPE_HPP
00015 #define _ANYATOMICTYPE_HPP
00016
00017 #include <xqilla/framework/XQillaExport.hpp>
00018 #include <xqilla/items/Item.hpp>
00019 #include <xercesc/util/XercesDefs.hpp>
00020
00021 class DynamicContext;
00022 class StaticContext;
00023
00024 class XQILLA_API AnyAtomicType: public Item
00025 {
00026
00027 public:
00028 enum AtomicObjectType {
00029 ANY_SIMPLE_TYPE = 0,
00030 ANY_URI = 1,
00031 BASE_64_BINARY = 2,
00032 BOOLEAN = 3,
00033 DATE = 4,
00034 DATE_TIME = 5,
00035 DAY_TIME_DURATION = 6,
00036 DECIMAL = 7,
00037 DOUBLE = 8,
00038 DURATION = 9,
00039 FLOAT = 10,
00040 G_DAY = 11,
00041 G_MONTH = 12,
00042 G_MONTH_DAY = 13,
00043 G_YEAR = 14,
00044 G_YEAR_MONTH = 15,
00045 HEX_BINARY = 16,
00046 NOTATION = 17,
00047 QNAME = 18,
00048 STRING = 19,
00049 TIME = 20,
00050 UNTYPED_ATOMIC = 21,
00051 YEAR_MONTH_DURATION= 22,
00052 NumAtomicObjectTypes= 23
00053 };
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083 typedef RefCountPointer<const AnyAtomicType> Ptr;
00084
00085
00086 virtual bool isAtomicValue() const;
00087
00088
00089 virtual bool isNode() const;
00090
00091
00092 virtual bool isNumericValue() const;
00093
00094
00095 virtual bool isDateOrTimeTypeValue() const;
00096
00097
00098 virtual const XMLCh* getPrimitiveTypeURI() const;
00099
00100
00101 virtual const XMLCh* getPrimitiveTypeName() const = 0;
00102
00103
00104 virtual const XMLCh* getTypeURI() const = 0;
00105
00106
00107 virtual const XMLCh* getTypeName() const = 0;
00108
00109
00110 AnyAtomicType::Ptr castAs(AtomicObjectType targetIndex, const DynamicContext* context) const;
00111
00112
00113 AnyAtomicType::Ptr castAsNoCheck(AtomicObjectType targetIndex, const XMLCh* targetURI, const XMLCh* targetType,
00114 const DynamicContext* context) const;
00115
00116
00117 AnyAtomicType::Ptr castAs(AtomicObjectType targetIndex, const XMLCh* targetURI, const XMLCh* targetType,
00118 const DynamicContext* context) const;
00119
00120
00121 virtual bool castable(AtomicObjectType targetIndex, const XMLCh* targetURI, const XMLCh* targetType,
00122 const DynamicContext* context) const;
00123
00124
00125 virtual const XMLCh* asString(const DynamicContext* context) const = 0;
00126
00127
00128
00129 virtual bool equals(const AnyAtomicType::Ptr &target, const DynamicContext* context) const = 0;
00130
00131
00132 virtual bool isOfType(const XMLCh* targetURI, const XMLCh* targetType, const DynamicContext* context) const;
00133
00134
00135
00136 virtual bool isInstanceOfType(const XMLCh* targetURI, const XMLCh* targetType, const StaticContext* context) const;
00137
00150 bool castIsSupported(AtomicObjectType targetIndex, const DynamicContext* context) const;
00151
00152 virtual AtomicObjectType getPrimitiveTypeIndex() const = 0;
00153
00154 static const XMLCh fgDT_ANYATOMICTYPE[];
00155
00156 protected:
00157
00158 virtual AnyAtomicType::Ptr castAsInternal(AtomicObjectType targetIndex, const XMLCh* targetURI,
00159 const XMLCh* targetType, const DynamicContext* context) const;
00160
00161 private:
00162
00163
00164
00165
00166
00167 class CastTable {
00168 public:
00169 CastTable();
00170 bool getCell(AtomicObjectType source,
00171 AtomicObjectType target) const;
00172 private:
00173 bool staticCastTable[NumAtomicObjectTypes][NumAtomicObjectTypes];
00174 };
00175
00176
00177
00178 static const CastTable staticCastTable;
00179 };
00180
00181 #endif // _ANYATOMICTYPE_HPP