Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:15:11

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 
0023 // ---------------------------------------------------------------------------
0024 //  Includes
0025 // ---------------------------------------------------------------------------
0026 #if defined(XERCES_TMPLSINC)
0027 #include <xercesc/util/CountedPointer.hpp>
0028 #endif
0029 
0030 XERCES_CPP_NAMESPACE_BEGIN
0031 
0032 // ---------------------------------------------------------------------------
0033 //  CountedPointerTo: Constructors and Destructor
0034 // ---------------------------------------------------------------------------
0035 template <class T> CountedPointerTo<T>::
0036 CountedPointerTo(const CountedPointerTo<T>& toCopy) :
0037 
0038     fPtr(toCopy.fPtr)
0039 {
0040     if (fPtr)
0041         fPtr->addRef();
0042 }
0043 
0044 template <class T> CountedPointerTo<T>::CountedPointerTo(T* p) :
0045 
0046     fPtr(p)
0047 {
0048     if (fPtr)
0049         fPtr->addRef();
0050 }
0051 
0052 template <class T> CountedPointerTo<T>::~CountedPointerTo()
0053 {
0054     if (fPtr)
0055         fPtr->removeRef();
0056 }
0057 
0058 
0059 // ---------------------------------------------------------------------------
0060 //  CountedPointerTo: Operators
0061 // ---------------------------------------------------------------------------
0062 template <class T> CountedPointerTo<T>&
0063 CountedPointerTo<T>::operator=(const CountedPointerTo<T>& other)
0064 {
0065     if (this == &other)
0066         return *this;
0067 
0068     if (other.fPtr)
0069         other.fPtr->addRef();
0070 
0071     if (fPtr)
0072         fPtr->removeRef();
0073 
0074     fPtr = other.fPtr;
0075     return *this;
0076 }
0077 
0078 template <class T> CountedPointerTo<T>::operator T*()
0079 {
0080     return fPtr;
0081 }
0082 
0083 template <class T> const T* CountedPointerTo<T>::operator->() const
0084 {
0085     return fPtr;
0086 }
0087 
0088 template <class T> T* CountedPointerTo<T>::operator->()
0089 {
0090     return fPtr;
0091 }
0092 
0093 template <class T> const T& CountedPointerTo<T>::operator*() const
0094 {
0095     if (!fPtr)
0096         ThrowXMLwithMemMgr(NullPointerException, XMLExcepts::CPtr_PointerIsZero, 0);
0097     return *fPtr;
0098 }
0099 
0100 template <class T> T& CountedPointerTo<T>::operator*()
0101 {
0102     if (!fPtr)
0103         ThrowXMLwithMemMgr(NullPointerException, XMLExcepts::CPtr_PointerIsZero, 0);
0104     return *fPtr;
0105 }
0106 
0107 XERCES_CPP_NAMESPACE_END