/* * Copyright (c) 2001, DecisionSoft Limited All rights reserved. * Please see LICENSE.TXT for more information. */ #ifndef _SEQUENCE_HPP #define _SEQUENCE_HPP #include #include // needed for the definition of PathanAllocator #include class Item; class SequenceType; class DynamicContext; class ATDecimalOrDerived; class ATBooleanOrDerived; // xerces forward declare XERCES_CPP_NAMESPACE_BEGIN class DOMNodeList; XERCES_CPP_NAMESPACE_END typedef std::vector > VectorOfItems; /** defines the behaviour for the string data type*/ class PATHAN_EXPORT Sequence { public: typedef VectorOfItems::iterator iterator; typedef VectorOfItems::const_iterator const_iterator; typedef VectorOfItems::reverse_iterator reverse_iterator; typedef VectorOfItems::const_reverse_iterator const_reverse_iterator; // constructor that takes one Item Sequence(const Item* item, XPath2MemoryManager* memMgr); // constructor that takes a node list Sequence(const XERCES_CPP_NAMESPACE_QUALIFIER DOMNodeList *domList, XPath2MemoryManager* memMgr); // constructor that creates a empty sequence Sequence(XPath2MemoryManager* memMgr); /// construct and reserve space for n elements Sequence(unsigned int n, XPath2MemoryManager* memMgr); // copy constructor Sequence(const Sequence&, XPath2MemoryManager* memMgr); // copy constructor Sequence(const Sequence&); Sequence & operator=(const Sequence &); // no-op ~Sequence(); void clear(); const Item* first() const; const Item* second() const; ///Begin an iterator Sequence::iterator begin(void); Sequence::const_iterator begin(void) const; ///Find the end of the iterator Sequence::iterator end(void); Sequence::const_iterator end(void) const; ///Reverse iterator methods Sequence::reverse_iterator rbegin(void); Sequence::const_reverse_iterator rbegin(void) const; Sequence::reverse_iterator rend(void); Sequence::const_reverse_iterator rend(void) const; ///Returns the number of nodes in the list unsigned int getLength(void) const; ///Return the indexth item in the collection const Item* item(unsigned int index) const; ///Return the indexth item in the collection - takes ATDecimalOrDerived const Item* item(const ATDecimalOrDerived* index) const; /// add an item to this sequence void addItem(const Item* item); /// add an item to this sequence void addItemFront(const Item* item); /// combine another sequence onto this sequence void joinSequence(const Sequence & s); ///Returns true if the list is empty bool isEmpty() const; Sequence castAs(const SequenceType* sequenceType, DynamicContext* context) const; /// perform atomization Sequence atomize(const DynamicContext* context) const; /// sort into document order (only works for Sequences containing only Nodes) void sortIntoDocumentOrder(); /// sort as strings, using the given collation void sortWithCollation(const Collation *collation, const DynamicContext *context); // helper methods /// castAs( X("string") ) getDOMString(), default context const XMLCh* castAsSingleString(DynamicContext* context) const; /** returns the effective boolean value of the sequence */ bool getEffectiveBooleanValue(const DynamicContext* context) const; private: VectorOfItems _itemList; XPath2MemoryManager *_memMgr; }; #endif