00001 /* 00002 * The Apache Software License, Version 1.1 00003 * 00004 * 00005 * Copyright (c) 1999 The Apache Software Foundation. All rights 00006 * reserved. 00007 * 00008 * Redistribution and use in source and binary forms, with or without 00009 * modification, are permitted provided that the following conditions 00010 * are met: 00011 * 00012 * 1. Redistributions of source code must retain the above copyright 00013 * notice, this list of conditions and the following disclaimer. 00014 * 00015 * 2. Redistributions in binary form must reproduce the above copyright 00016 * notice, this list of conditions and the following disclaimer in 00017 * the documentation and/or other materials provided with the 00018 * distribution. 00019 * 00020 * 3. The end-user documentation included with the redistribution, 00021 * if any, must include the following acknowledgment: 00022 * "This product includes software developed by the 00023 * Apache Software Foundation (http://www.apache.org/)." 00024 * Alternately, this acknowledgment may appear in the software itself, 00025 * if and wherever such third-party acknowledgments normally appear. 00026 * 00027 * 4. The names "Xalan" and "Apache Software Foundation" must 00028 * not be used to endorse or promote products derived from this 00029 * software without prior written permission. For written 00030 * permission, please contact apache@apache.org. 00031 * 00032 * 5. Products derived from this software may not be called "Apache", 00033 * nor may "Apache" appear in their name, without prior written 00034 * permission of the Apache Software Foundation. 00035 * 00036 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 00037 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00038 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00039 * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR 00040 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00041 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00042 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 00043 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00044 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00045 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 00046 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00047 * SUCH DAMAGE. 00048 * ==================================================================== 00049 * 00050 * This software consists of voluntary contributions made by many 00051 * individuals on behalf of the Apache Software Foundation and was 00052 * originally based on software copyright (c) 1999, International 00053 * Business Machines, Inc., http://www.ibm.com. For more 00054 * information on the Apache Software Foundation, please see 00055 * <http://www.apache.org/>. 00056 */ 00057 #if !defined(STLHELPERS_HEADER_GUARD_1357924680) 00058 #define STLHELPERS_HEADER_GUARD_1357924680 00059 00060 00061 00062 // Base include file. Must be first. 00063 #include "PlatformSupportDefinitions.hpp" 00064 00065 00066 00067 #include <algorithm> 00068 #include <functional> 00069 00070 00071 00075 template <class T> 00076 #if defined(XALAN_NO_NAMESPACES) 00077 struct DeleteFunctor : public unary_function<const T*, void> 00078 #else 00079 struct DeleteFunctor : public std::unary_function<const T*, void> 00080 #endif 00081 { 00087 result_type 00088 operator()(argument_type thePointer) const 00089 { 00090 #if defined(XALAN_CANNOT_DELETE_CONST) 00091 delete (T*)thePointer; 00092 #else 00093 delete thePointer; 00094 #endif 00095 } 00096 }; 00097 00098 00099 00100 #if !defined(XALAN_SGI_BASED_STL) 00101 00106 template <class PairType> 00107 #if defined(XALAN_NO_NAMESPACES) 00108 struct select1st : public unary_function<PairType, PairType::first_type> 00109 #else 00110 struct select1st : public std::unary_function<PairType, PairType::first_type> 00111 #endif 00112 { 00113 typedef typename PairType value_type; 00114 00121 typename result_type 00122 operator()(const typename argument_type& thePair) const 00123 { 00124 return thePair.first; 00125 } 00126 }; 00127 00128 00129 00134 template <class PairType> 00135 #if defined(XALAN_NO_NAMESPACES) 00136 struct select2nd : public unary_function<PairType, PairType::second_type> 00137 #else 00138 struct select2nd : public std::unary_function<PairType, PairType::second_type> 00139 #endif 00140 { 00141 typedef typename PairType value_type; 00142 00149 typename result_type 00150 operator()(const typename argument_type& thePair) const 00151 { 00152 return thePair.second; 00153 } 00154 }; 00155 00156 #endif 00157 00158 00159 00163 template <class T> 00164 #if defined(XALAN_NO_NAMESPACES) 00165 struct MapValueDeleteFunctor : public unary_function<const T::value_type&, void> 00166 #else 00167 struct MapValueDeleteFunctor : public std::unary_function<const typename T::value_type&, void> 00168 #endif 00169 { 00176 result_type 00177 operator()(argument_type thePair) const 00178 { 00179 delete thePair.second; 00180 } 00181 }; 00182 00183 00184 00185 template<class T> 00186 MapValueDeleteFunctor<T> 00187 makeMapValueDeleteFunctor(const T& /* theMap */) 00188 { 00189 return MapValueDeleteFunctor<T>(); 00190 } 00191 00192 00193 00194 template <class T> 00195 #if defined(XALAN_NO_NAMESPACES) 00196 struct MapKeyDeleteFunctor : public unary_function<const T::value_type&, void> 00197 #else 00198 struct MapKeyDeleteFunctor : public std::unary_function<const typename T::value_type&, void> 00199 #endif 00200 { 00207 result_type 00208 operator()(argument_type thePair) 00209 { 00210 delete thePair.first; 00211 } 00212 }; 00213 00214 00215 00216 template<class T> 00217 MapKeyDeleteFunctor<T> 00218 makeMapKeyDeleteFunctor(const T& /* theMap */) 00219 { 00220 return MapKeyDeleteFunctor<T>(); 00221 } 00222 00223 00224 00234 template<class T> 00235 #if defined(XALAN_NO_NAMESPACES) 00236 struct less_null_terminated_arrays : public binary_function<const T*, const T*, bool> 00237 #else 00238 struct less_null_terminated_arrays : public std::binary_function<const T*, const T*, bool> 00239 #endif 00240 { 00249 result_type 00250 operator()( 00251 first_argument_type theLHS, 00252 second_argument_type theRHS) const 00253 { 00254 while(*theLHS && *theRHS) 00255 { 00256 if (*theLHS != *theRHS) 00257 { 00258 break; 00259 } 00260 else 00261 { 00262 theLHS++; 00263 theRHS++; 00264 } 00265 } 00266 00267 return *theLHS < *theRHS ? true : false; 00268 } 00269 }; 00270 00271 00272 00273 template<class CollectionType, class DeleteFunctorType> 00274 class CollectionDeleteGuard 00275 { 00276 public: 00277 00278 CollectionDeleteGuard(CollectionType& theCollection) : 00279 m_collection(&theCollection) 00280 { 00281 } 00282 00283 ~CollectionDeleteGuard() 00284 { 00285 if (m_collection != 0) 00286 { 00287 #if !defined(XALAN_NO_NAMESPACES) 00288 using std::for_each; 00289 #endif 00290 00291 // Delete all of the objects in the temp vector. 00292 for_each(m_collection->begin(), 00293 m_collection->end(), 00294 DeleteFunctorType()); 00295 } 00296 } 00297 00298 void 00299 release() 00300 { 00301 m_collection = 0; 00302 } 00303 00304 private: 00305 00306 // Not implemented... 00307 CollectionDeleteGuard(const CollectionDeleteGuard<CollectionType, DeleteFunctorType>&); 00308 00309 CollectionDeleteGuard<CollectionType, DeleteFunctorType>& 00310 operator=(const CollectionDeleteGuard<CollectionType, DeleteFunctorType>&); 00311 00312 // Data members... 00313 CollectionType* m_collection; 00314 }; 00315 00316 00317 00318 #endif // STLHELPERS_HEADER_GUARD_1357924680
Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.
![]() |
Xalan-C++ XSL Transformer Version 1.0 |
|