/* * Copyright (c) 2001, DecisionSoft Limited All rights reserved. * Please see LICENSE.TXT for more information. */ #ifndef _ATDOUBLEORDERIVEDIMPL_HPP #define _ATDOUBLEORDERIVEDIMPL_HPP #include #include #include #include #define DOUBLE_MAX_DIGITS 25 class PATHAN_EXPORT ATDoubleOrDerivedImpl : public ATDoubleOrDerived { public: /** Releases the memory used by this Item */ virtual void release() const; /* constructor */ ATDoubleOrDerivedImpl(const XMLCh* typeURI, const XMLCh* typeName, const XMLCh* value, XPath2MemoryManager* memMgr, const DynamicContext* context); /* constructor */ ATDoubleOrDerivedImpl(const XMLCh* typeURI, const XMLCh* typeName, const MAPM value, XPath2MemoryManager* memMgr, const DynamicContext* context); /** destructor -- do nothing*/ virtual ~ATDoubleOrDerivedImpl() { }; /* Get the name of the primitive type (basic type) of this type * (ie "decimal" for xs:decimal) */ virtual const XMLCh* getPrimitiveTypeName() const; /* Get the namespace URI for this type */ virtual const XMLCh* getTypeURI() const; /* Get the name of this type (ie "integer" for xs:integer) */ virtual const XMLCh* getTypeName() const; /* returns the XMLCh* (canonical) representation of this type */ virtual const XMLCh* asString(const DynamicContext* context) const; /* Promote this to the given type, if possible */ virtual const Numeric* promoteTypeIfApplicable(const XMLCh* typeURI, const XMLCh* typeName, const DynamicContext* context) const; /* returns true if the two objects' decimal values are equal * false otherwise */ virtual bool equals(const AnyAtomicType* target, const DynamicContext* context) const; /** Returns true if this is less than other, false otherwise */ virtual bool lessThan(const Numeric* other, const DynamicContext* context) const; /** Returns true if this is greater than other, false otherwise */ virtual bool greaterThan(const Numeric* other, const DynamicContext* context) const; /** Returns a Numeric object which is the sum of this and other */ virtual const Numeric* add(const Numeric* other, const DynamicContext* context) const; /** Returns a Numeric object which is the difference of this and * other */ virtual const Numeric* subtract(const Numeric* other, const DynamicContext* context) const; /** Returns a Numeric object which is the product of this and other */ virtual const Numeric* multiply(const Numeric* other, const DynamicContext* context) const; /** Returns a Numeric object which is the quotient of this and other */ virtual const Numeric* divide(const Numeric* other, const DynamicContext* context) const; /** Returns the arithmetic product of its operands as a Numeric */ virtual const Numeric* mod(const Numeric* other, const DynamicContext* context) const; /** Returns the floor of this Numeric */ virtual const Numeric* floor(const DynamicContext* context) const; /** Returns the ceiling of this Numeric */ virtual const Numeric* ceiling(const DynamicContext* context) const; /** Rounds this Numeric */ virtual const Numeric* round(const DynamicContext* context) const; /** Rounds this Numeric to the given precision, and rounds a half to even */ virtual const Numeric* roundHalfToEven(const ATDecimalOrDerived* &precision, const DynamicContext* context) const; /** Returns the Additive inverse of this Numeric */ virtual const Numeric* invert(const DynamicContext* context) const; /** Returns the absolute value of this Numeric */ virtual const Numeric* abs(const DynamicContext* context) const; /** Does this Numeric have value 0? */ virtual bool isZero() const; /** Is this Numeric negative? */ virtual bool isNegative() const; /** Is this Numeric positive? */ virtual bool isPositive() const; /* Is this xs:double not a number */ virtual bool isNaN() const; /* Is this xs:double infinite? */ virtual bool isInfinite() const; /* Get the primitive index associated with this type */ static AnyAtomicType::AtomicObjectType getTypeIndex(); /* Get the primitive type name */ static const XMLCh* getPrimitiveName(); /* Get the primitive index associated with this type */ virtual AnyAtomicType::AtomicObjectType getPrimitiveTypeIndex() const; enum state {NUM, NaN, INF, NEG_INF}; protected: /* If possible, cast this type to the target type */ virtual const AnyAtomicType* castAsInternal(const XMLCh* targetURI, const XMLCh* targetType, const DynamicContext* context) const; private: /* set the value of this decimal */ void setDouble(const XMLCh* const value); /* returns a new infinity ATDoubleOrDerived*/ const ATDoubleOrDerived* infinity(const DynamicContext* context) const; /* returns a new negative infinity ATDoubleOrDerived*/ const ATDoubleOrDerived* negInfinity(const DynamicContext* context) const; /* returns a NaN ATDoubleOrDerived*/ const ATDoubleOrDerived* notANumber(const DynamicContext* context) const; /* returns a -0 ATDoubleOrDerived*/ const ATDoubleOrDerived* negZero(const DynamicContext* context) const; /*returns a ATDoubleOrDerived of value value*/ const ATDoubleOrDerived* newDouble(MAPM value, const DynamicContext* context) const; /*The value of this double*/ MAPM _double; /* is it NaN, INF, NegINF, or just a double (NUM) */ state _state; /* whether or not this value is negative */ bool _isNegative; /* the name of this type */ const XMLCh* _typeName; /* the uri of this type */ const XMLCh* _typeURI; }; #endif // _ATDOUBLEORDERIVEDIMPL_HPP