00001 /* 00002 * Copyright (c) 2001-2006 00003 * DecisionSoft Limited. All rights reserved. 00004 * Copyright (c) 2004-2006 00005 * Progress Software Corporation. All rights reserved. 00006 * Copyright (c) 2004-2006 00007 * Oracle. All rights reserved. 00008 * 00009 * See the file LICENSE for redistribution information. 00010 * 00011 * $Id: Sequence.hpp,v 1.8 2006/11/01 16:37:15 jpcs Exp $ 00012 */ 00013 00014 #ifndef _SEQUENCE_HPP 00015 #define _SEQUENCE_HPP 00016 00017 #include <vector> 00018 00019 #include <xqilla/framework/XQillaExport.hpp> 00020 #include <xqilla/items/ATDecimalOrDerived.hpp> 00021 #include <xqilla/framework/XPath2MemoryManager.hpp> 00022 00023 #include <xercesc/util/XMemory.hpp> 00024 #include <xercesc/util/PlatformUtils.hpp> 00025 00026 class DynamicContext; 00027 00028 typedef std::vector<Item::Ptr, XQillaAllocator<Item::Ptr> > VectorOfItems; 00029 00033 class XQILLA_API Sequence : public XERCES_CPP_NAMESPACE_QUALIFIER XMemory 00034 { 00035 00036 public: 00037 typedef VectorOfItems::iterator iterator; 00038 typedef VectorOfItems::const_iterator const_iterator; 00039 typedef VectorOfItems::reverse_iterator reverse_iterator; 00040 typedef VectorOfItems::const_reverse_iterator const_reverse_iterator; 00041 00042 // constructor that takes one Item 00043 Sequence(const Item::Ptr &item, XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager* memMgr = 00044 XERCES_CPP_NAMESPACE_QUALIFIER XMLPlatformUtils::fgMemoryManager); 00045 // constructor that creates a empty sequence 00046 Sequence(XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager* memMgr = 00047 XERCES_CPP_NAMESPACE_QUALIFIER XMLPlatformUtils::fgMemoryManager); 00049 Sequence(unsigned int n, XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager* memMgr = 00050 XERCES_CPP_NAMESPACE_QUALIFIER XMLPlatformUtils::fgMemoryManager); 00051 // copy constructor 00052 Sequence(const Sequence&, XERCES_CPP_NAMESPACE_QUALIFIER MemoryManager* memMgr); 00053 // copy constructor 00054 Sequence(const Sequence&); 00055 Sequence &operator=(const Sequence &); 00056 00057 ~Sequence(); 00058 00059 void clear(); 00060 00061 const Item::Ptr &first() const; 00062 const Item::Ptr &second() const; 00063 00065 Sequence::iterator begin(void); 00066 Sequence::const_iterator begin(void) const; 00067 00069 Sequence::iterator end(void); 00070 Sequence::const_iterator end(void) const; 00071 00073 Sequence::reverse_iterator rbegin(void); 00074 Sequence::const_reverse_iterator rbegin(void) const; 00075 00076 Sequence::reverse_iterator rend(void); 00077 Sequence::const_reverse_iterator rend(void) const; 00078 00080 unsigned int getLength(void) const; 00081 00083 const Item::Ptr &item(unsigned int index) const; 00085 const Item::Ptr &item(const ATDecimalOrDerived::Ptr &index) const; 00086 00088 void addItem(const Item::Ptr &item); 00089 00091 void addItemFront(const Item::Ptr &item); 00092 00094 void joinSequence(const Sequence & s); 00095 00097 bool isEmpty() const; 00098 00100 void sortIntoDocumentOrder(const DynamicContext *context); 00101 00103 void sortWithCollation(const Collation *collation, const DynamicContext *context); 00104 00105 private: 00106 VectorOfItems _itemList; 00107 }; 00108 00109 #endif