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