/* * Copyright (c) 2001, DecisionSoft Limited All rights reserved. * Please see LICENSE.TXT for more information. */ #ifndef __NUMERIC_HPP #define __NUMERIC_HPP #include #include #include class DynamicContext; class ATDecimalOrDerived; class PATHAN_EXPORT Numeric : public AnyAtomicType { public: /* is this type numeric? Return true */ virtual bool isNumericValue() const { return true; }; /* Get the name of the primitive type (basic type) of this type * (ie "decimal" for xs:decimal) */ virtual const XMLCh* getPrimitiveTypeName() const = 0; /* Get the namespace URI for this type */ virtual const XMLCh* getTypeURI() const = 0; /* Get the name of this type (ie "integer" for xs:integer) */ virtual const XMLCh* getTypeName() const = 0; /* returns the XMLCh* (canonical) representation of this type */ virtual const XMLCh* asString(const DynamicContext* context) const = 0; /* Promote this to the given type, if possible */ virtual const Numeric* promoteTypeIfApplicable(const XMLCh* typeURI, const XMLCh* typeName, const DynamicContext* context) const = 0; /* returns true if the two Numeric values are equal * false otherwise */ virtual bool equals(const AnyAtomicType* target, const DynamicContext* context) const = 0; /** Returns true if this is less than other, false otherwise */ virtual bool lessThan(const Numeric* other, const DynamicContext* context) const = 0; /** Returns true if this is greater than other, false otherwise */ virtual bool greaterThan(const Numeric* other, const DynamicContext* context) const = 0; /** Returns a Numeric object which is the sum of this and other */ virtual const Numeric* add(const Numeric* other, const DynamicContext* context) const = 0; /** Returns a Numeric object which is the difference of this and * other */ virtual const Numeric* subtract(const Numeric* other, const DynamicContext* context) const = 0; /** Returns a Numeric object which is the product of this and other */ virtual const Numeric* multiply(const Numeric* other, const DynamicContext* context) const = 0; /** Returns a Numeric object which is the quotient of this and other */ virtual const Numeric* divide(const Numeric* other, const DynamicContext* context) const = 0; /** Returns the arithmetic product of its operands as a Numeric */ virtual const Numeric* mod(const Numeric* other, const DynamicContext* context) const = 0; /** Returns the floor of this Numeric */ virtual const Numeric* floor(const DynamicContext* context) const = 0; /** Returns the ceiling of this Numeric */ virtual const Numeric* ceiling(const DynamicContext* context) const = 0; /** Rounds this Numeric */ virtual const Numeric* round(const DynamicContext* context) const = 0; /** Rounds this Numeric to the given precision, and rounds a half to even */ virtual const Numeric* roundHalfToEven(const ATDecimalOrDerived* &precision, const DynamicContext* context) const = 0; /** Returns the Additive inverse of this Numeric */ virtual const Numeric* invert(const DynamicContext* context) const = 0; /** Does this Numeric have value 0? */ virtual bool isZero() const = 0; /** Is this Numeric positive? */ virtual bool isPositive() const = 0; /** Is this Numeric negative? */ virtual bool isNegative() const = 0; /** Releases the memory used by this Item */ virtual void release() const = 0; virtual AnyAtomicType::AtomicObjectType getPrimitiveTypeIndex() const = 0; static const XMLCh NaN_string[]; static const XMLCh NAN_string[]; static const XMLCh INF_string[]; static const XMLCh NegINF_string[]; static const XMLCh NegZero_string[]; static const XMLCh PosZero_string[]; protected: /* Protected constructor */ Numeric(XPath2MemoryManager* memMgr): AnyAtomicType(memMgr) {}; }; #endif // __NUMERIC_HPP