|
||||
File indexing completed on 2025-01-30 10:27:24
0001 /* 0002 * Licensed to the Apache Software Foundation (ASF) under one or more 0003 * contributor license agreements. See the NOTICE file distributed with 0004 * this work for additional information regarding copyright ownership. 0005 * The ASF licenses this file to You under the Apache License, Version 2.0 0006 * (the "License"); you may not use this file except in compliance with 0007 * the License. You may obtain a copy of the License at 0008 * 0009 * http://www.apache.org/licenses/LICENSE-2.0 0010 * 0011 * Unless required by applicable law or agreed to in writing, software 0012 * distributed under the License is distributed on an "AS IS" BASIS, 0013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 0014 * See the License for the specific language governing permissions and 0015 * limitations under the License. 0016 */ 0017 0018 /* 0019 * $Id$ 0020 */ 0021 0022 #if !defined(XERCESC_INCLUDE_GUARD_JANITOR_HPP) 0023 #define XERCESC_INCLUDE_GUARD_JANITOR_HPP 0024 0025 #include <xercesc/util/XMemory.hpp> 0026 #include <xercesc/framework/MemoryManager.hpp> 0027 0028 XERCES_CPP_NAMESPACE_BEGIN 0029 0030 template <class T> class Janitor : public XMemory 0031 { 0032 public : 0033 // ----------------------------------------------------------------------- 0034 // Constructors and Destructor 0035 // ----------------------------------------------------------------------- 0036 Janitor(T* const toDelete); 0037 ~Janitor(); 0038 0039 // ----------------------------------------------------------------------- 0040 // Public, non-virtual methods 0041 // ----------------------------------------------------------------------- 0042 void orphan(); 0043 0044 // small amount of auto_ptr compatibility 0045 T& operator*() const; 0046 T* operator->() const; 0047 T* get() const; 0048 T* release(); 0049 void reset(T* p = 0); 0050 bool isDataNull(); 0051 0052 private : 0053 // ----------------------------------------------------------------------- 0054 // Unimplemented constructors and operators 0055 // ----------------------------------------------------------------------- 0056 Janitor(); 0057 Janitor(const Janitor<T>&); 0058 Janitor<T>& operator=(const Janitor<T>&); 0059 0060 // ----------------------------------------------------------------------- 0061 // Private data members 0062 // 0063 // fData 0064 // This is the pointer to the object or structure that must be 0065 // destroyed when this object is destroyed. 0066 // ----------------------------------------------------------------------- 0067 T* fData; 0068 }; 0069 0070 0071 0072 template <class T> class ArrayJanitor : public XMemory 0073 { 0074 public : 0075 // ----------------------------------------------------------------------- 0076 // Constructors and Destructor 0077 // ----------------------------------------------------------------------- 0078 ArrayJanitor(T* const toDelete); 0079 ArrayJanitor(T* const toDelete, MemoryManager* const manager); 0080 ~ArrayJanitor(); 0081 0082 0083 // ----------------------------------------------------------------------- 0084 // Public, non-virtual methods 0085 // ----------------------------------------------------------------------- 0086 void orphan(); 0087 0088 // small amount of auto_ptr compatibility 0089 T& operator[](XMLSize_t index) const; 0090 T* get() const; 0091 T* release(); 0092 void reset(T* p = 0); 0093 void reset(T* p, MemoryManager* const manager); 0094 0095 private : 0096 // ----------------------------------------------------------------------- 0097 // Unimplemented constructors and operators 0098 // ----------------------------------------------------------------------- 0099 ArrayJanitor(); 0100 ArrayJanitor(const ArrayJanitor<T>& copy); 0101 ArrayJanitor<T>& operator=(const ArrayJanitor<T>& copy); 0102 0103 // ----------------------------------------------------------------------- 0104 // Private data members 0105 // 0106 // fData 0107 // This is the pointer to the object or structure that must be 0108 // destroyed when this object is destroyed. 0109 // ----------------------------------------------------------------------- 0110 T* fData; 0111 MemoryManager* fMemoryManager; 0112 }; 0113 0114 0115 0116 template <class T> class JanitorMemFunCall 0117 { 0118 public : 0119 0120 typedef void (T::*MFPT) (); 0121 0122 // ----------------------------------------------------------------------- 0123 // Constructors and Destructor 0124 // ----------------------------------------------------------------------- 0125 JanitorMemFunCall( 0126 T* object, 0127 MFPT toCall); 0128 0129 ~JanitorMemFunCall(); 0130 0131 // small amount of auto_ptr compatibility 0132 T& operator*() const; 0133 T* operator->() const; 0134 T* get() const; 0135 T* release(); 0136 void reset(T* p = 0); 0137 0138 private : 0139 // ----------------------------------------------------------------------- 0140 // Unimplemented constructors and operators 0141 // ----------------------------------------------------------------------- 0142 JanitorMemFunCall(); 0143 JanitorMemFunCall(const JanitorMemFunCall<T>&); 0144 JanitorMemFunCall<T>& operator=(const JanitorMemFunCall<T>&); 0145 0146 // ----------------------------------------------------------------------- 0147 // Private data members 0148 // 0149 // fObject 0150 // This is the pointer to the object for which we will call the 0151 // member function when this object is destroyed. 0152 // ----------------------------------------------------------------------- 0153 T* fObject; 0154 MFPT fToCall; 0155 }; 0156 0157 #if defined(__GNUC__) || (! defined(_AIX) && ! defined(__hpux) && ! defined(__sun)) 0158 XERCES_TEMPLATE_EXTERN template class XMLUTIL_EXPORT ArrayJanitor<XMLByte>; 0159 XERCES_TEMPLATE_EXTERN template class XMLUTIL_EXPORT ArrayJanitor<XMLCh>; 0160 #endif 0161 0162 XERCES_CPP_NAMESPACE_END 0163 0164 #if !defined(XERCES_TMPLSINC) 0165 #include <xercesc/util/Janitor.c> 0166 #endif 0167 0168 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |