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 <Include/PlatformDefinitions.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 { 00082 #if defined(XALAN_NO_NAMESPACES) 00083 typedef unary_function<const T*, void> BaseClassType; 00084 #else 00085 typedef std::unary_function<const T*, void> BaseClassType; 00086 #endif 00087 00088 typedef typename BaseClassType::result_type result_type; 00089 typedef typename BaseClassType::argument_type argument_type; 00090 00096 result_type 00097 operator()(argument_type thePointer) const 00098 { 00099 #if defined(XALAN_CANNOT_DELETE_CONST) 00100 delete (T*)thePointer; 00101 #else 00102 delete thePointer; 00103 #endif 00104 } 00105 }; 00106 00107 00108 00109 #if !defined(XALAN_SGI_BASED_STL) 00110 00115 template <class PairType> 00116 #if defined(XALAN_NO_NAMESPACES) 00117 struct select1st : public unary_function<PairType, PairType::first_type> 00118 #else 00119 struct select1st : public std::unary_function<PairType, typename PairType::first_type> 00120 #endif 00121 { 00122 #if defined(XALAN_NO_NAMESPACES) 00123 typedef unary_function<PairType, PairType::first_type> BaseClassType; 00124 #else 00125 typedef std::unary_function<PairType, typename PairType::first_type> BaseClassType; 00126 #endif 00127 00128 typedef typename BaseClassType::result_type result_type; 00129 typedef typename BaseClassType::argument_type argument_type; 00130 00131 typedef PairType value_type; 00132 00139 result_type 00140 operator()(const argument_type& thePair) const 00141 { 00142 return thePair.first; 00143 } 00144 }; 00145 00146 00147 00152 template <class PairType> 00153 #if defined(XALAN_NO_NAMESPACES) 00154 struct select2nd : public unary_function<PairType, PairType::second_type> 00155 #else 00156 struct select2nd : public std::unary_function<PairType, typename PairType::second_type> 00157 #endif 00158 { 00159 #if defined(XALAN_NO_NAMESPACES) 00160 typedef unary_function<PairType, PairType::second_type> BaseClassType; 00161 #else 00162 typedef std::unary_function<PairType, typename PairType::second_type> BaseClassType; 00163 #endif 00164 00165 typedef typename BaseClassType::result_type result_type; 00166 typedef typename BaseClassType::argument_type argument_type; 00167 00168 typedef PairType value_type; 00169 00176 result_type 00177 operator()(const argument_type& thePair) const 00178 { 00179 return thePair.second; 00180 } 00181 }; 00182 00183 #endif 00184 00185 00186 00190 template <class T> 00191 #if defined(XALAN_NO_NAMESPACES) 00192 struct MapValueDeleteFunctor : public unary_function<const typename T::value_type&, void> 00193 #else 00194 struct MapValueDeleteFunctor : public std::unary_function<const typename T::value_type&, void> 00195 #endif 00196 { 00197 #if defined(XALAN_NO_NAMESPACES) 00198 typedef unary_function<const typename T::value_type&, void> BaseClassType; 00199 #else 00200 typedef std::unary_function<const typename T::value_type&, void> BaseClassType; 00201 #endif 00202 00203 typedef typename BaseClassType::result_type result_type; 00204 typedef typename BaseClassType::argument_type argument_type; 00205 00212 result_type 00213 operator()(argument_type thePair) const 00214 { 00215 #if defined(XALAN_CANNOT_DELETE_CONST) 00216 delete (T*)thePair.second; 00217 #else 00218 delete thePair.second; 00219 #endif 00220 } 00221 }; 00222 00223 00224 00225 template<class T> 00226 MapValueDeleteFunctor<T> 00227 makeMapValueDeleteFunctor(const T& /* theMap */) 00228 { 00229 return MapValueDeleteFunctor<T>(); 00230 } 00231 00232 00233 00234 template <class T> 00235 #if defined(XALAN_NO_NAMESPACES) 00236 struct MapKeyDeleteFunctor : public unary_function<const typename T::value_type&, void> 00237 #else 00238 struct MapKeyDeleteFunctor : public std::unary_function<const typename T::value_type&, void> 00239 #endif 00240 { 00241 #if defined(XALAN_NO_NAMESPACES) 00242 typedef unary_function<const typename T::value_type&, void> BaseClassType; 00243 #else 00244 typedef std::unary_function<const typename T::value_type&, void> BaseClassType; 00245 #endif 00246 00247 typedef typename BaseClassType::result_type result_type; 00248 typedef typename BaseClassType::argument_type argument_type; 00249 00256 result_type 00257 operator()(argument_type thePair) 00258 { 00259 delete thePair.first; 00260 } 00261 }; 00262 00263 00264 00265 template<class T> 00266 MapKeyDeleteFunctor<T> 00267 makeMapKeyDeleteFunctor(const T& /* theMap */) 00268 { 00269 return MapKeyDeleteFunctor<T>(); 00270 } 00271 00272 00273 00283 template<class T> 00284 #if defined(XALAN_NO_NAMESPACES) 00285 struct less_null_terminated_arrays : public binary_function<const T*, const T*, bool> 00286 #else 00287 struct less_null_terminated_arrays : public std::binary_function<const T*, const T*, bool> 00288 #endif 00289 { 00290 #if defined(XALAN_NO_NAMESPACES) 00291 typedef binary_function<const T*, const T*, bool> BaseClassType; 00292 #else 00293 typedef std::binary_function<const T*, const T*, bool> BaseClassType; 00294 #endif 00295 00296 typedef typename BaseClassType::result_type result_type; 00297 typedef typename BaseClassType::first_argument_type first_argument_type; 00298 typedef typename BaseClassType::second_argument_type second_argument_type; 00299 00308 result_type 00309 operator()( 00310 first_argument_type theLHS, 00311 second_argument_type theRHS) const 00312 { 00313 while(*theLHS && *theRHS) 00314 { 00315 if (*theLHS != *theRHS) 00316 { 00317 break; 00318 } 00319 else 00320 { 00321 theLHS++; 00322 theRHS++; 00323 } 00324 } 00325 00326 return *theLHS < *theRHS ? true : false; 00327 } 00328 }; 00329 00330 00331 00332 template<class CollectionType> 00333 class CollectionClearGuard 00334 { 00335 public: 00336 00337 CollectionClearGuard(CollectionType& theCollection) : 00338 m_collection(&theCollection) 00339 { 00340 } 00341 00342 ~CollectionClearGuard() 00343 { 00344 if (m_collection != 0) 00345 { 00346 m_collection->clear(); 00347 } 00348 } 00349 00350 void 00351 release() 00352 { 00353 m_collection = 0; 00354 } 00355 00356 private: 00357 00358 // Not implemented... 00359 CollectionClearGuard(const CollectionClearGuard<CollectionType>&); 00360 00361 CollectionClearGuard<CollectionType>& 00362 operator=(const CollectionClearGuard<CollectionType>&); 00363 00364 // Data members... 00365 CollectionType* m_collection; 00366 }; 00367 00368 00369 00370 template<class CollectionType, class DeleteFunctorType> 00371 class CollectionDeleteGuard 00372 { 00373 public: 00374 00375 CollectionDeleteGuard(CollectionType& theCollection) : 00376 m_collection(&theCollection) 00377 { 00378 } 00379 00380 ~CollectionDeleteGuard() 00381 { 00382 if (m_collection != 0) 00383 { 00384 #if !defined(XALAN_NO_NAMESPACES) 00385 using std::for_each; 00386 #endif 00387 00388 // Delete all of the objects in the temp vector. 00389 for_each(m_collection->begin(), 00390 m_collection->end(), 00391 DeleteFunctorType()); 00392 } 00393 } 00394 00395 void 00396 release() 00397 { 00398 m_collection = 0; 00399 } 00400 00401 private: 00402 00403 // Not implemented... 00404 CollectionDeleteGuard(const CollectionDeleteGuard<CollectionType, DeleteFunctorType>&); 00405 00406 CollectionDeleteGuard<CollectionType, DeleteFunctorType>& 00407 operator=(const CollectionDeleteGuard<CollectionType, DeleteFunctorType>&); 00408 00409 // Data members... 00410 CollectionType* m_collection; 00411 }; 00412 00413 00414 00415 #endif // STLHELPERS_HEADER_GUARD_1357924680
Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.
![]() |
Xalan-C++ XSLT Processor Version 1.3 |
|