Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.11


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

Interpreting class diagrams

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

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

Apache Logo