/* * Copyright (c) 2001, DecisionSoft Limited All rights reserved. * Please see LICENSE.TXT for more information. */ #ifndef _DATAITEMIMPL_HPP #define _DATAITEMIMPL_HPP class Sequence; class DynamicContext; class Numeric; #include /** class which is used as base for all the different data types */ class PATHAN_EXPORT DataItemImpl : public DataItem { public: DataItemImpl(XPath2MemoryManager* memMgr); virtual ~DataItemImpl(); DataItem::whichType getType(void) const; ///returns the predicate list to be applied to each node we select const VectorOfDataItems& getPredicates(void) const; //these can create a step if there are none!! virtual void addPredicates(const VectorOfDataItems &steps); /** Returns true if this DataItem has no predicates, and is an instance of DataItemSequence or DataItemLiteral */ virtual bool isConstant() const; /** Returns true if this DataItem has no predicates, and is an instance of DataItemSequence or DataItemLiteral. If the literal value of this DataItem is a single DateOrTimeType, then hasTimezone() on it must return true, otherwise this method will return false. */ virtual bool isConstantAndHasTimezone(StaticContext* context) const; ///calls collapseTreeInternal and then checks predicates virtual Sequence collapseTree(DynamicContext* context, int flags=0) const; //collapase the compiled expression based on context virtual Sequence collapseTreeInternal(DynamicContext* context, int flags=0) const = 0; void checkPredicates(Sequence &s, DynamicContext *context) const; virtual Sequence checkPredicate(const Sequence &s, const DataItem *predicate, DynamicContext *context) const; bool checkPredicate(const DataItem* predicate, DynamicContext* context) const; const Numeric *getConstantNumericPredicate(const DataItem *predicate, StaticContext *context) const; /** Calls staticResolution on the DataItems, then if isConstant() is true for all of them, and constantFold is true, returns the result of the constantFold() method, otherwise returns the result of the resolvePredicates() method. */ DataItem *resolveDataItems(VectorOfDataItems &dis, StaticContext *context, StaticResolutionContext *src, bool constantFold); /** Calls staticResolution on the DataItems, then if isConstantAndHasTimezone() is true for all of them, and constantFold is true, returns the result of the constantFold() method, otherwise returns the result of the resolvePredicates() method. */ DataItem *resolveDataItemsForDateOrTime(VectorOfDataItems &dis, StaticContext *context, StaticResolutionContext *src, bool constantFold); /** Calls staticResolution on the DataItem, then if isConstant() is true for it, and constantFold is true, returns the result of the constantFold() method, otherwise returns the result of the resolvePredicates() method. */ DataItem *resolveDataItem(DataItem *&di, StaticContext *context, StaticResolutionContext *src, bool constantFold); /** Calls staticResolution on the predicates of this DataItem, constant folding if possible */ DataItem *resolvePredicates(StaticContext *context, StaticResolutionContext *src); virtual DataItemImpl *resolvePredicate(VectorOfDataItems::reverse_iterator it, VectorOfDataItems &newPreds, StaticContext *context, StaticResolutionContext *src); /** Performs constant folding on this DataItem, transfering any predicates to the returned DataItem */ DataItem *constantFold(StaticContext *context, StaticResolutionContext *src) const; protected: void setType(DataItem::whichType t); XPath2MemoryManager* getMemoryManager(void) const; VectorOfDataItems _predList; private: whichType _type; XPath2MemoryManager* _memMgr; }; #endif