1 /* { dg-do compile } */
3 typedef __SIZE_TYPE__ size_t;
7 } pthread_barrierattr_t;
9 typedef unsigned short XMLCh;
10 typedef unsigned long XMLSize_t;
11 namespace xercesc_2_5 {
15 class DOMDocumentRange {
17 class DOMDocument: public DOMDocumentRange, public DOMNode {
27 public : void* operator new(size_t size, MemoryManager* memMgr);
28 void operator delete(void* p);
29 void operator delete(void* p, MemoryManager* memMgr);
33 NoError = 0 , HshTbl_ZeroModulus = 48 , HshTbl_BadHashFromKey = 49 };
38 namespace xercesc_2_5 {
39 class XMLException : public XMemory {
41 virtual ~XMLException();
42 XMLException(const char* const srcFile, const unsigned int srcLine, MemoryManager* const memoryManager = 0);
43 void loadExceptText ( const XMLExcepts::Codes toLoad );
47 class XMLPlatformUtils {
48 public : static MemoryManager* fgMemoryManager;
49 static inline size_t alignPointerForNewBlockAllocation(size_t ptrSize);
51 inline size_t XMLPlatformUtils::alignPointerForNewBlockAllocation(size_t ptrSize) {
53 class HashBase : public XMemory {
55 virtual bool equals(const void *const key1, const void *const key2) = 0;
59 class IllegalArgumentException : public XMLException {
61 IllegalArgumentException(const char* const srcFile , const unsigned int srcLine , const XMLExcepts::Codes toThrow , MemoryManager* memoryManager = 0) : XMLException(srcFile, srcLine, memoryManager) {
62 loadExceptText(toThrow);
65 class RuntimeException : public XMLException {
67 RuntimeException(const char* const srcFile , const unsigned int srcLine , const XMLExcepts::Codes toThrow , MemoryManager* memoryManager = 0) : XMLException(srcFile, srcLine, memoryManager) {
68 loadExceptText(toThrow);
73 virtual ~MemoryManager() {
75 virtual void* allocate(size_t size) = 0;
77 template <class TElem> class BaseRefVectorOf : public XMemory {
78 BaseRefVectorOf ( const unsigned int maxElems , const bool adoptElems = true , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager );
79 virtual ~BaseRefVectorOf();
83 template <class TElem> BaseRefVectorOf<TElem>::BaseRefVectorOf( const unsigned int maxElems , const bool adoptElems , MemoryManager* const manager) : fAdoptedElems(adoptElems) {
84 for (unsigned int index = 0;
86 index++) fElemList[index] = 0;
88 template <class TElem> BaseRefVectorOf<TElem>::~BaseRefVectorOf() {
92 static bool equals ( const XMLCh* const str1 , const XMLCh* const str2 );
93 static void moveChars ( XMLCh* const targetStr , const XMLCh* const srcStr , const unsigned int count );
95 inline void XMLString::moveChars( XMLCh* const targetStr , const XMLCh* const srcStr , const unsigned int count) {
97 inline bool XMLString::equals( const XMLCh* const str1 , const XMLCh* const str2) {
98 const XMLCh* psz1 = str1;
99 const XMLCh* psz2 = str2;
100 if (psz1 == 0 || psz2 == 0) {
105 namespace xercesc_2_5 {
106 class HashPtr : public HashBase {
107 virtual bool equals(const void *const key1, const void *const key2);
109 template <class TVal> struct DOMDeepNodeListPoolTableBucketElem : public XMemory {
114 template <class TVal> class DOMDeepNodeListPool {
116 DOMDeepNodeListPool ( const XMLSize_t modulus , const bool adoptElems , const XMLSize_t initSize = 128 );
117 TVal* getByKey(const void* const key1, const XMLCh* const key2, const XMLCh* const key3);
118 DOMDeepNodeListPoolTableBucketElem<TVal>* findBucketElem(const void* const key1, const XMLCh* const key2, const XMLCh* const key3, XMLSize_t& hashVal);
120 DOMDeepNodeListPoolTableBucketElem<TVal>** fBucketList;
121 XMLSize_t fHashModulus;
124 XMLSize_t fIdPtrsCount;
125 MemoryManager* fMemoryManager;
127 template <class TVal> DOMDeepNodeListPool<TVal>::DOMDeepNodeListPool( const XMLSize_t modulus , const bool adoptElems , const XMLSize_t initSize) : fAdoptedElems(adoptElems) , fBucketList(0) , fHash(0) , fIdPtrs(0) {
128 fHash = new (fMemoryManager) HashPtr();
129 fIdPtrs = (TVal**) fMemoryManager->allocate(fIdPtrsCount * sizeof(TVal*));
130 if (modulus == 0) throw IllegalArgumentException("./xercesc/dom/impl/bad.c", 38, XMLExcepts::HshTbl_ZeroModulus, fMemoryManager);
132 template <class TVal> TVal* DOMDeepNodeListPool<TVal>::getByKey(const void* const key1, const XMLCh* const key2, const XMLCh* const key3) {
134 DOMDeepNodeListPoolTableBucketElem<TVal>* findIt = findBucketElem(key1, key2, key3, hashVal);
136 template <class TVal> DOMDeepNodeListPoolTableBucketElem<TVal>* DOMDeepNodeListPool<TVal>:: findBucketElem(const void* const key1, const XMLCh* const key2, const XMLCh* const key3, XMLSize_t& hashVal) {
137 if (hashVal > fHashModulus) throw RuntimeException("./xercesc/dom/impl/bad.c", 64, XMLExcepts::HshTbl_BadHashFromKey, fMemoryManager);
138 DOMDeepNodeListPoolTableBucketElem<TVal>* curElem = fBucketList[hashVal];
139 if (fHash->equals(key1, curElem->fKey1) && (XMLString::equals(key2, curElem->fKey2)) && (XMLString::equals(key3, curElem->fKey3))) {
143 class DOMDeepNodeListImpl;
144 class DOMDocumentImpl: public DOMDocument {
145 DOMNodeList* getElementsByTagName(const XMLCh * tagname) const;
146 DOMNodeList* getDeepNodeList(const DOMNode *rootNode, const XMLCh *tagName);
147 DOMNodeList* getDeepNodeList(const DOMNode *rootNode, const XMLCh *namespaceURI, const XMLCh *localName);
148 DOMDeepNodeListPool<DOMDeepNodeListImpl>* fNodeListPool;
151 void * operator new(size_t amt, xercesc_2_5:: DOMDocument *doc);
152 namespace xercesc_2_5 {
155 class DOMDeepNodeListImpl: public DOMNodeList {
157 DOMNodeList *DOMDocumentImpl::getElementsByTagName(const XMLCh *tagname) const {
158 return ((DOMDocumentImpl*)this)->getDeepNodeList(this,tagname);
160 DOMNodeList *DOMDocumentImpl::getDeepNodeList(const DOMNode *rootNode, const XMLCh *tagName) {
162 fNodeListPool = new (this) DOMDeepNodeListPool<DOMDeepNodeListImpl>(109, false);
164 DOMNodeList* retList = fNodeListPool->getByKey(rootNode, tagName, 0);
166 DOMNodeList *DOMDocumentImpl::getDeepNodeList(const DOMNode *rootNode, const XMLCh *namespaceURI, const XMLCh *localName) {
167 DOMNodeList* retList = fNodeListPool->getByKey(rootNode, localName, namespaceURI);