Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.10

XalanAutoPtr.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #if !defined(XALANAUTOPTR_HEADER_GUARD_1357924680)
17 #define XALANAUTOPTR_HEADER_GUARD_1357924680
18 
19 
20 
21 // Base include file. Must be first.
23 
24 
25 
26 #include <cstddef>
27 
28 
29 
30 XALAN_CPP_NAMESPACE_BEGIN
31 
32 
33 
34 // We're using our own auto_ptr-like class due to wide
35 // variations amongst the varous platforms we have to
36 // support
37 template<class Type>
39 {
40 public:
41 
42  XalanAutoPtr(Type* thePointer = 0) :
43  m_pointer(thePointer)
44  {
45  }
46 
47  XalanAutoPtr(const XalanAutoPtr<Type>& theSource) :
48  m_pointer(((XalanAutoPtr<Type>&)theSource).release())
49  {
50  }
51 
54  {
55  if (this != &theRHS)
56  {
57  // This test ought not to be necessary, but
58  // MSVC 6.0 calls delete, which checks for 0.
59  // The problem with that is the locking is
60  // extremely expensive.
61  if (m_pointer != 0)
62  {
63  delete m_pointer;
64  }
65 
66  m_pointer = theRHS.release();
67  }
68 
69  return *this;
70  }
71 
73  {
74  // See note in operator=() about this...
75  if (m_pointer != 0)
76  {
77  delete m_pointer;
78  }
79  }
80 
81  Type&
82  operator*() const
83  {
84  return *m_pointer;
85  }
86 
87  Type*
88  operator->() const
89  {
90  return m_pointer;
91  }
92 
93  Type*
94  get() const
95  {
96  return m_pointer;
97  }
98 
99  Type*
101  {
102  Type* const temp = m_pointer;
103 
104  m_pointer = 0;
105 
106  return temp;
107  }
108 
109  void
110  reset(Type* thePointer = 0)
111  {
112  // See note in operator=() about this...
113  if (m_pointer != 0)
114  {
115  delete m_pointer;
116  }
117 
118  m_pointer = thePointer;
119  }
120 
121 private:
122 
123  Type* m_pointer;
124 };
125 
126 
127 
128 // A class similar to XalanAutoPtr, but for arrays.
129 template<class Type>
131 {
132 public:
133 
134  XalanArrayAutoPtr(Type* thePointer = 0) :
135  m_pointer(thePointer)
136  {
137  }
138 
140  m_pointer(((XalanArrayAutoPtr<Type>&)theSource).release())
141  {
142  }
143 
146  {
147  if (this != &theRHS)
148  {
149  // This test ought not to be necessary, but
150  // MSVC 6.0 calls delete, which checks for 0.
151  // The problem with that is the locking is
152  // extremely expensive.
153  if (m_pointer != 0)
154  {
155  delete [] m_pointer;
156  }
157 
158  m_pointer = theRHS.release();
159  }
160 
161  return *this;
162  }
163 
165  {
166  // See note in operator=() about this...
167  if (m_pointer != 0)
168  {
169  delete [] m_pointer;
170  }
171  }
172 
173  Type&
174  operator*() const
175  {
176  return *m_pointer;
177  }
178 
179  Type&
180 #if defined(XALAN_STRICT_ANSI_HEADERS)
181  operator[](std::size_t index) const
182 #else
183  operator[](size_t index) const
184 #endif
185  {
186  return m_pointer[index];
187  }
188 
189  Type*
190  get() const
191  {
192  return m_pointer;
193  }
194 
195  Type*
197  {
198  Type* const temp = m_pointer;
199 
200  m_pointer = 0;
201 
202  return temp;
203  }
204 
205  void
206  reset(Type* thePointer = 0)
207  {
208  // See note in operator=() about this...
209  if (m_pointer != 0)
210  {
211  delete [] m_pointer;
212  }
213 
214  m_pointer = thePointer;
215  }
216 
217 private:
218 
219  Type* m_pointer;
220 };
221 
222 
223 
224 XALAN_CPP_NAMESPACE_END
225 
226 
227 
228 #endif // if !defined(XALANAUTOPTR_HEADER_GUARD_1357924680)
XalanArrayAutoPtr< Type > & operator=(XalanArrayAutoPtr< Type > &theRHS)
Definition: XalanAutoPtr.hpp:145
XalanArrayAutoPtr(Type *thePointer=0)
Definition: XalanAutoPtr.hpp:134
Type & operator[](size_t index) const
Definition: XalanAutoPtr.hpp:183
Type * release()
Definition: XalanAutoPtr.hpp:100
Type & operator*() const
Definition: XalanAutoPtr.hpp:82
~XalanArrayAutoPtr()
Definition: XalanAutoPtr.hpp:164
Type & operator*() const
Definition: XalanAutoPtr.hpp:174
XalanArrayAutoPtr(const XalanArrayAutoPtr< Type > &theSource)
Definition: XalanAutoPtr.hpp:139
Type * operator->() const
Definition: XalanAutoPtr.hpp:88
XalanAutoPtr< Type > & operator=(XalanAutoPtr< Type > &theRHS)
Definition: XalanAutoPtr.hpp:53
XalanAutoPtr(Type *thePointer=0)
Definition: XalanAutoPtr.hpp:42
Type * release()
Definition: XalanAutoPtr.hpp:196
void reset(Type *thePointer=0)
Definition: XalanAutoPtr.hpp:110
XalanAutoPtr(const XalanAutoPtr< Type > &theSource)
Definition: XalanAutoPtr.hpp:47
void reset(Type *thePointer=0)
Definition: XalanAutoPtr.hpp:206
~XalanAutoPtr()
Definition: XalanAutoPtr.hpp:72
Definition: XalanAutoPtr.hpp:38
Definition: XalanAutoPtr.hpp:130

Interpreting class diagrams

Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.

dot

Xalan-C++ XSLT Processor Version 1.10
Copyright © 1999-2004 The Apache Software Foundation. All Rights Reserved.

Apache Logo