/* * Copyright (c) 2001, DecisionSoft Limited All rights reserved. * Please see LICENSE.TXT for more information. */ #ifndef _ATDATEORDERIVEDIMPL_HPP #define _ATDATEORDERIVEDIMPL_HPP #include #include #include class Timezone; class ATDecimalOrDerived; class ATDurationOrDerived; class XPath2MemoryManager; class DynamicContext; class PATHAN_EXPORT ATDateOrDerivedImpl : public ATDateOrDerived { public: /* constructor */ ATDateOrDerivedImpl(const XMLCh* typeURI, const XMLCh* typeName, const XMLCh* value, XPath2MemoryManager* memMgr, const DynamicContext* context); /* 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; /** Releases the memory used by this Item */ virtual void release() const; /* returns true if the two objects represent the same date, * false otherwise */ virtual bool equals(const AnyAtomicType* target, const DynamicContext* context) const; /** * Returns true if and only if this date is greater than the given date. * The order relation on date values is the order relation on their * starting instants. */ virtual bool greaterThan(const ATDateOrDerived* date, const DynamicContext* context) const; /** * Returns true if and only if this date is less than the given date. * The order relation on date values is the order relation on their * starting instants. */ virtual bool lessThan(const ATDateOrDerived* date, const DynamicContext* context) const; /** * Returns an integer representing the year component of this object */ virtual const ATDecimalOrDerived* getYears() const; /** * Returns an integer representing the month component of this object */ virtual const ATDecimalOrDerived* getMonths() const; /** * Returns an integer representing the day component of this object */ virtual const ATDecimalOrDerived* getDays() const; virtual const ATDateOrDerived* normalize(const DynamicContext* context) const; /** * Returns the timezone associated with this object, or * null, if the timezone is not set */ virtual const Timezone* getTimezone() const; /** * Returns true if the timezone is defined for this object, false otherwise. */ virtual bool hasTimezone() const; /** * Setter for timezone. Overrides the current timezone. (Not to be * confused with addTimezone(). */ virtual const ATDateOrDerived* setTimezone(const Timezone* timezone, const DynamicContext* context) const; /** * Returns an ATDateOrDerived with a timezone added to it */ virtual const ATDateOrDerived* addTimezone(const ATDurationOrDerived* timezone, const DynamicContext* context) const; /** * Returns a date with the given yearMonthDuration added to it */ virtual const ATDateOrDerived* addYearMonthDuration(const ATDurationOrDerived* yearMonth, const DynamicContext* context) const; /** * Returns a date with the given dayTimeDuration added to it */ virtual const ATDateOrDerived* addDayTimeDuration(const ATDurationOrDerived* dayTime, const DynamicContext* context) const; /** * Returns a date with the given number of days added to it */ virtual const ATDateOrDerived* addDays(const ATDecimalOrDerived* days, const DynamicContext* context) const; /** * Returns a date with the given yearMonthDuration subtracted from it */ virtual const ATDateOrDerived* subtractYearMonthDuration(const ATDurationOrDerived* yearMonth, const DynamicContext* context) const; /** * Returns a date with the given dayTimeDuration subtracted from it */ virtual const ATDateOrDerived* subtractDayTimeDuration(const ATDurationOrDerived* dayTime, const DynamicContext* context) const; /** * Returns a date with the given number of days subtracted from it */ virtual const ATDateOrDerived* subtractDays(const ATDecimalOrDerived* days, const DynamicContext* context) const; /** * Returns a dayTimeDuration corresponding to the difference between this * and the given ATDateOrDerived* */ virtual const ATDurationOrDerived* subtractDate(const ATDateOrDerived* date, const DynamicContext* context) 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; 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: // private constructor for use with clone() ATDateOrDerivedImpl(const XMLCh* typeURI, const XMLCh* typeName, const ATDecimalOrDerived* YY, const ATDecimalOrDerived* MM, const ATDecimalOrDerived* DD, const Timezone* timezone, bool hasTimezone, XPath2MemoryManager* memMgr); void setDate(const XMLCh* const date, const DynamicContext* context); const ATDateOrDerived* addDays(MAPM days, const DynamicContext* context) const; const ATDateOrDerived* subtractDays(MAPM days, const DynamicContext* context) const; const ATDateOrDerived* addYearMonthDuration(MAPM years, MAPM months, const DynamicContext* context) const; /* returns the XMLCh* (lexical := prefix:localname) representation of this type */ const XMLCh* asLexicalString(const DynamicContext* context) const; ////////////////////////////////////// // Horrible Hack to make Dates // // work for now. Loss of Precision! // ////////////////////////////////////// int asInt(MAPM num) const; /*The value of this date*/ const ATDecimalOrDerived* _YY; // year const ATDecimalOrDerived* _MM; // month const ATDecimalOrDerived* _DD; // day /* the timezone associated with this ATDateOrDerived */ const Timezone* _timezone; /* true if the timezone is defined */ bool _hasTimezone; /* the name of this type */ const XMLCh* _typeName; /* the uri of this type */ const XMLCh* _typeURI; }; #endif // _ATDATEORDERIVEDIMPL_HPP