<HTML><HEAD><TITLE>Xalan-C++ API Documentation</TITLE></HEAD> <BODY> <h2 align="center">Xalan-C++ API Documentation</h2> <h3 align="center">The Xalan C++ XSLT Processor Version 1.4</h3> </BODY> <!-- Generated by Doxygen 1.1.2 on Mon Sep 16 08:25:28 2002 --> <center> <a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="classes.html">Alphabetical List</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> </center> <hr><h1>STLHelper.hpp</h1><a href="STLHelper.hpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>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) <a name="l00058"><a class="code" href="STLHelper.hpp.html#a0">00058</a></a> #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 <a class="code" href="class_deletefunctor.html">DeleteFunctor</a> : public unary_function<const T*, void> 00078 #else <a name="l00079"><a class="code" href="class_deletefunctor.html">00079</a></a> struct <a class="code" href="class_deletefunctor.html">DeleteFunctor</a> : 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 <a name="l00085"><a class="code" href="class_deletefunctor.html#s0">00085</a></a> typedef <a class="code" href="class_std__unary_function.html">std::unary_function</a><const T*, void> BaseClassType; 00086 #endif 00087 <a name="l00088"><a class="code" href="class_deletefunctor.html#s1">00088</a></a> typedef typename BaseClassType::result_type result_type; <a name="l00089"><a class="code" href="class_deletefunctor.html#s2">00089</a></a> typedef typename BaseClassType::argument_type argument_type; 00090 00096 result_type <a name="l00097"><a class="code" href="class_deletefunctor.html#a0">00097</a></a> 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 <a class="code" href="class_select1st.html">select1st</a> : public unary_function<PairType, PairType::first_type> 00118 #else <a name="l00119"><a class="code" href="class_select1st.html">00119</a></a> struct <a class="code" href="class_select1st.html">select1st</a> : 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 <a name="l00125"><a class="code" href="class_select1st.html#s0">00125</a></a> typedef <a class="code" href="class_std__unary_function.html">std::unary_function</a><PairType, typename PairType::first_type> BaseClassType; 00126 #endif 00127 <a name="l00128"><a class="code" href="class_select1st.html#s1">00128</a></a> typedef typename BaseClassType::result_type result_type; <a name="l00129"><a class="code" href="class_select1st.html#s2">00129</a></a> typedef typename BaseClassType::argument_type argument_type; 00130 <a name="l00131"><a class="code" href="class_select1st.html#s3">00131</a></a> typedef PairType value_type; 00132 00139 result_type <a name="l00140"><a class="code" href="class_select1st.html#a0">00140</a></a> 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 <a class="code" href="class_select2nd.html">select2nd</a> : public unary_function<PairType, PairType::second_type> 00155 #else <a name="l00156"><a class="code" href="class_select2nd.html">00156</a></a> struct <a class="code" href="class_select2nd.html">select2nd</a> : 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 <a name="l00162"><a class="code" href="class_select2nd.html#s0">00162</a></a> typedef <a class="code" href="class_std__unary_function.html">std::unary_function</a><PairType, typename PairType::second_type> BaseClassType; 00163 #endif 00164 <a name="l00165"><a class="code" href="class_select2nd.html#s1">00165</a></a> typedef typename BaseClassType::result_type result_type; <a name="l00166"><a class="code" href="class_select2nd.html#s2">00166</a></a> typedef typename BaseClassType::argument_type argument_type; 00167 <a name="l00168"><a class="code" href="class_select2nd.html#s3">00168</a></a> typedef PairType value_type; 00169 00176 result_type <a name="l00177"><a class="code" href="class_select2nd.html#a0">00177</a></a> 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 <a class="code" href="class_mapvaluedeletefunctor.html">MapValueDeleteFunctor</a> : public unary_function<const typename T::value_type&, void> 00193 #else <a name="l00194"><a class="code" href="class_mapvaluedeletefunctor.html">00194</a></a> struct <a class="code" href="class_mapvaluedeletefunctor.html">MapValueDeleteFunctor</a> : 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 <a name="l00200"><a class="code" href="class_mapvaluedeletefunctor.html#s0">00200</a></a> typedef <a class="code" href="class_std__unary_function.html">std::unary_function</a><const typename T::value_type&, void> BaseClassType; 00201 #endif 00202 <a name="l00203"><a class="code" href="class_mapvaluedeletefunctor.html#s1">00203</a></a> typedef typename BaseClassType::result_type result_type; <a name="l00204"><a class="code" href="class_mapvaluedeletefunctor.html#s2">00204</a></a> typedef typename BaseClassType::argument_type argument_type; 00205 00212 result_type <a name="l00213"><a class="code" href="class_mapvaluedeletefunctor.html#a0">00213</a></a> operator()(argument_type thePair) const 00214 { 00215 delete thePair.second; 00216 } 00217 }; 00218 00219 00220 00221 template<class T> 00222 <a class="code" href="class_mapvaluedeletefunctor.html">MapValueDeleteFunctor</a><T> <a name="l00223"><a class="code" href="STLHelper.hpp.html#a1">00223</a></a> makeMapValueDeleteFunctor(const T& /* theMap */) 00224 { 00225 return <a class="code" href="class_mapvaluedeletefunctor.html">MapValueDeleteFunctor</a><T>(); 00226 } 00227 00228 00229 00239 template<class T> 00240 #if defined(XALAN_NO_NAMESPACES) 00241 struct <a class="code" href="class_less_null_terminated_arrays.html">less_null_terminated_arrays</a> : public binary_function<const T*, const T*, bool> 00242 #else <a name="l00243"><a class="code" href="class_less_null_terminated_arrays.html">00243</a></a> struct <a class="code" href="class_less_null_terminated_arrays.html">less_null_terminated_arrays</a> : public std::binary_function<const T*, const T*, bool> 00244 #endif 00245 { 00246 #if defined(XALAN_NO_NAMESPACES) 00247 typedef binary_function<const T*, const T*, bool> BaseClassType; 00248 #else <a name="l00249"><a class="code" href="class_less_null_terminated_arrays.html#s0">00249</a></a> typedef <a class="code" href="class_std__binary_function.html">std::binary_function</a><const T*, const T*, bool> BaseClassType; 00250 #endif 00251 <a name="l00252"><a class="code" href="class_less_null_terminated_arrays.html#s1">00252</a></a> typedef typename BaseClassType::result_type result_type; <a name="l00253"><a class="code" href="class_less_null_terminated_arrays.html#s2">00253</a></a> typedef typename BaseClassType::first_argument_type first_argument_type; <a name="l00254"><a class="code" href="class_less_null_terminated_arrays.html#s3">00254</a></a> typedef typename BaseClassType::second_argument_type second_argument_type; 00255 00264 result_type <a name="l00265"><a class="code" href="class_less_null_terminated_arrays.html#a0">00265</a></a> operator()( 00266 first_argument_type theLHS, 00267 second_argument_type theRHS) const 00268 { 00269 while(*theLHS && *theRHS) 00270 { 00271 if (*theLHS != *theRHS) 00272 { 00273 break; 00274 } 00275 else 00276 { 00277 theLHS++; 00278 theRHS++; 00279 } 00280 } 00281 00282 return *theLHS < *theRHS ? true : false; 00283 } 00284 }; 00285 00286 00287 00288 template<class CollectionType> <a name="l00289"><a class="code" href="class_collectionclearguard.html">00289</a></a> class <a class="code" href="class_collectionclearguard.html">CollectionClearGuard</a> 00290 { 00291 public: 00292 <a name="l00293"><a class="code" href="class_collectionclearguard.html#a0">00293</a></a> <a class="code" href="class_collectionclearguard.html#a0">CollectionClearGuard</a>(CollectionType& theCollection) : 00294 m_collection(&theCollection) 00295 { 00296 } 00297 <a name="l00298"><a class="code" href="class_collectionclearguard.html#a1">00298</a></a> <a class="code" href="class_collectionclearguard.html#a1">~CollectionClearGuard</a>() 00299 { 00300 if (m_collection != 0) 00301 { 00302 m_collection->clear(); 00303 } 00304 } 00305 00306 void <a name="l00307"><a class="code" href="class_collectionclearguard.html#a2">00307</a></a> <a class="code" href="class_collectionclearguard.html#a2">release</a>() 00308 { 00309 m_collection = 0; 00310 } 00311 00312 private: 00313 00314 // Not implemented... 00315 <a class="code" href="class_collectionclearguard.html#a0">CollectionClearGuard</a>(const <a class="code" href="class_collectionclearguard.html">CollectionClearGuard</a><CollectionType>&); 00316 00317 <a class="code" href="class_collectionclearguard.html">CollectionClearGuard</a><CollectionType>& 00318 operator=(const <a class="code" href="class_collectionclearguard.html">CollectionClearGuard</a><CollectionType>&); 00319 00320 // Data members... 00321 CollectionType* m_collection; 00322 }; 00323 00324 00325 00326 template<class CollectionType, class DeleteFunctorType> <a name="l00327"><a class="code" href="class_collectiondeleteguard.html">00327</a></a> class <a class="code" href="class_collectiondeleteguard.html">CollectionDeleteGuard</a> 00328 { 00329 public: 00330 <a name="l00331"><a class="code" href="class_collectiondeleteguard.html#a0">00331</a></a> <a class="code" href="class_collectiondeleteguard.html#a0">CollectionDeleteGuard</a>(CollectionType& theCollection) : 00332 m_collection(&theCollection) 00333 { 00334 } 00335 <a name="l00336"><a class="code" href="class_collectiondeleteguard.html#a1">00336</a></a> <a class="code" href="class_collectiondeleteguard.html#a1">~CollectionDeleteGuard</a>() 00337 { 00338 if (m_collection != 0) 00339 { 00340 #if !defined(XALAN_NO_NAMESPACES) 00341 using std::for_each; 00342 #endif 00343 00344 // Delete all of the objects in the temp vector. 00345 for_each(m_collection->begin(), 00346 m_collection->end(), 00347 DeleteFunctorType()); 00348 } 00349 } 00350 00351 void <a name="l00352"><a class="code" href="class_collectiondeleteguard.html#a2">00352</a></a> <a class="code" href="class_collectiondeleteguard.html#a2">release</a>() 00353 { 00354 m_collection = 0; 00355 } 00356 00357 private: 00358 00359 // Not implemented... 00360 <a class="code" href="class_collectiondeleteguard.html#a0">CollectionDeleteGuard</a>(const <a class="code" href="class_collectiondeleteguard.html">CollectionDeleteGuard</a><CollectionType, DeleteFunctorType>&); 00361 00362 <a class="code" href="class_collectiondeleteguard.html">CollectionDeleteGuard</a><CollectionType, DeleteFunctorType>& 00363 operator=(const <a class="code" href="class_collectiondeleteguard.html">CollectionDeleteGuard</a><CollectionType, DeleteFunctorType>&); 00364 00365 // Data members... 00366 CollectionType* m_collection; 00367 }; 00368 00369 00370 00371 #endif // STLHELPERS_HEADER_GUARD_1357924680 </div></pre><p align="center"><a href="diagramnotes.html">Interpreting class diagrams</a></p> <p><FONT color="#000000" face="arial,helvetica,sanserif" size="-1"> <i><A href="http://www.stack.nl/~dimitri/doxygen/">Doxygen</A> and <A href="http://www.research.att.com/sw/tools/graphviz/">GraphViz</A> are used to generate this API documentation from the Xalan-C header files.</I></FONT></p> <TABLE border="0" cellpadding="0" cellspacing="0" width="820"><TR><TD bgcolor="#0086b2"><IMG height="1" src="images/dot.gif" width="1"></TD></TR></TABLE> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" WIDTH="80%"> <TR> <TD WIDTH="80%" VALIGN="TOP"> <P ALIGN="CENTER"><B>Xalan-C++ XSLT Processor Version 1.4</B><BR> Copyright © 2000, 2001, 2002 The Apache Software Foundation. All Rights Reserved.</i></p> </TD> </TR> <TR> <TD WIDTH="100%"> <P ALIGN="CENTER"><IMG SRC="ApacheLogo.jpg" WIDTH="387" HEIGHT="100" ALIGN="BOTTOM" BORDER="0"> </TD> </TR> </TABLE>