/* * Copyright (c) 2002, DecisionSoft Limited All rights reserved. * Please see LICENSE.TXT for more information. */ #ifndef __XPATH2MEMORYMANAGERIMPL_HPP #define __XPATH2MEMORYMANAGERIMPL_HPP #include #include #include XERCES_CPP_NAMESPACE_BEGIN class DOMNode; class XMLGrammarPool; XERCES_CPP_NAMESPACE_END class Sequence; class VariableStore; class FunctionLookup; class DynamicContext; class Collation; class CollationHelper; class PathanNSResolver; class Item; class Node; class PATHAN_EXPORT XPath2MemoryManagerImpl : public XPath2MemoryManager { public: XPath2MemoryManagerImpl(); virtual ~XPath2MemoryManagerImpl(); // from MemoryManager virtual void* allocate(size_t numElements); virtual void deallocate(void* p); /** Returns a copy of the given string */ virtual const XMLCh* getPooledString(const XMLCh *src); /** Returns a copy of the transcoding of the given string */ virtual const XMLCh* getPooledString(const char *src); /** mark an Item* for release */ virtual void markForRelease(Item* p); /** Use with extreme caution! */ virtual void reset(); virtual void dumpStatistics(); /** create a node */ virtual const Node* createNode(const XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *newNode); /** create a context */ virtual DynamicContext* createContext(XERCES_CPP_NAMESPACE_QUALIFIER XMLGrammarPool* xmlgr); /** create a collation */ virtual Collation* createCollation(CollationHelper* helper); /** create a resolver */ virtual PathanNSResolver* createNSResolver(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode *resolverNode); /** create a store for variables */ virtual VariableStore* createVariableStore(); /** create a store for variables */ virtual VariableTypeStore* createVariableTypeStore(); /** create a function table */ virtual FunctionLookup* createFunctionTable(); protected: void initialise(); void releaseAll(); private: #ifdef WIN32 HANDLE fHeap; #else struct PATHAN_EXPORT MemList { MemList *prev; MemList *next; }; MemList *fCurrentBlock; #endif typedef XERCES_CPP_NAMESPACE_QUALIFIER RefHashTableOf StringPool; typedef XERCES_CPP_NAMESPACE_QUALIFIER RefHashTableOfEnumerator StringPoolEnumerator; StringPool *fStringPool; struct PATHAN_EXPORT ItemList { ItemList *prev; Item *item; }; // The Item* need to be released, or the MAPM field will leak memory ItemList *fToBeReleased; }; #endif //__XPATH2MEMORYMANAGERIMPL_HPP