Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.8

Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

NodeSorter.hpp

Go to the documentation of this file.
00001 /* 00002 * Copyright 1999-2004 The Apache Software Foundation. 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 #if !defined(XALAN_NODESORTER_HEADER_GUARD) 00017 #define XALAN_NODESORTER_HEADER_GUARD 00018 00025 // Base include file. Must be first. 00026 #include "XSLTDefinitions.hpp" 00027 00028 00029 00030 #include <functional> 00031 #include <vector> 00032 00033 00034 00035 #include <xalanc/XPath/XObject.hpp> 00036 00037 00038 00039 #include <xalanc/XSLT/NodeSortKey.hpp> 00040 00041 00042 00043 XALAN_CPP_NAMESPACE_BEGIN 00044 00045 00046 00047 class MutableNodeRefList; 00048 class StylesheetExecutionContext; 00049 class XalanNode; 00050 class XPath; 00051 00052 00053 00057 class XALAN_XSLT_EXPORT NodeSorter 00058 { 00059 public: 00060 00061 struct XALAN_XSLT_EXPORT VectorEntry 00062 { 00063 public: 00064 00065 VectorEntry( 00066 XalanNode* theNode = 0, 00067 unsigned int thePosition = 0) : 00068 m_node(theNode), 00069 m_position(thePosition) 00070 { 00071 } 00072 00073 XalanNode* m_node; 00074 unsigned int m_position; 00075 }; 00076 00077 #if defined(XALAN_NO_STD_NAMESPACE) 00078 typedef vector<VectorEntry> NodeVectorType; 00079 typedef vector<NodeSortKey> NodeSortKeyVectorType; 00080 #else 00081 typedef std::vector<VectorEntry> NodeVectorType; 00082 typedef std::vector<NodeSortKey> NodeSortKeyVectorType; 00083 #endif 00084 00085 explicit 00086 NodeSorter(); 00087 00088 ~NodeSorter(); 00089 00090 NodeSortKeyVectorType& 00091 getSortKeys() 00092 { 00093 return m_keys; 00094 } 00095 00103 void 00104 sort( 00105 StylesheetExecutionContext& executionContext, 00106 MutableNodeRefList& theList); 00107 00111 #if defined(XALAN_NO_STD_NAMESPACE) 00112 struct XALAN_XSLT_EXPORT NodeSortKeyCompare : public binary_function<const NodeVectorType::value_type&, const NodeVectorType::value_type&, bool> 00113 #else 00114 struct XALAN_XSLT_EXPORT NodeSortKeyCompare : public std::binary_function<const NodeVectorType::value_type&, const NodeVectorType::value_type&, bool> 00115 #endif 00116 { 00117 public: 00118 00126 NodeSortKeyCompare( 00127 StylesheetExecutionContext& executionContext, 00128 NodeSorter& theSorter, 00129 const NodeVectorType& theNodes, 00130 const NodeSortKeyVectorType& theNodeSortKeys) : 00131 m_executionContext(executionContext), 00132 m_sorter(theSorter), 00133 m_nodes(theNodes), 00134 m_nodeSortKeys(theNodeSortKeys) 00135 { 00136 } 00137 00147 int 00148 compare( 00149 first_argument_type theLHS, 00150 second_argument_type theRHS, 00151 unsigned int theKeyIndex = 0) const; 00152 00161 result_type 00162 operator()( 00163 first_argument_type theLHS, 00164 second_argument_type theRHS, 00165 unsigned int theKeyIndex = 0) const 00166 { 00167 return compare(theLHS, theRHS, theKeyIndex) < 0 ? true : false; 00168 } 00169 00170 protected: 00171 00172 double 00173 getNumberResult( 00174 const NodeSortKey& theKey, 00175 unsigned int theKeyIndex, 00176 first_argument_type theEntry) const; 00177 00178 const XalanDOMString& 00179 getStringResult( 00180 const NodeSortKey& theKey, 00181 unsigned int theKeyIndex, 00182 first_argument_type theEntry) const; 00183 00184 private: 00185 00186 StylesheetExecutionContext& m_executionContext; 00187 NodeSorter& m_sorter; 00188 const NodeVectorType& m_nodes; 00189 const NodeSortKeyVectorType& m_nodeSortKeys; 00190 }; 00191 00192 friend struct NodeSortKeyCompare; 00193 00194 #if defined(XALAN_NO_STD_NAMESPACE) 00195 typedef vector<double> NumberVectorType; 00196 typedef vector<XObjectPtr> XObjectVectorType; 00197 typedef vector<XalanDOMString> StringVectorType; 00198 00199 typedef vector<NumberVectorType> NumberCacheType; 00200 typedef vector<XObjectVectorType> XObjectCacheType; 00201 typedef vector<StringVectorType> StringCacheType; 00202 #else 00203 typedef std::vector<double> NumberVectorType; 00204 typedef std::vector<XObjectPtr> XObjectVectorType; 00205 typedef std::vector<XalanDOMString> StringVectorType; 00206 00207 typedef std::vector<NumberVectorType> NumberCacheType; 00208 typedef std::vector<XObjectVectorType> XObjectCacheType; 00209 typedef std::vector<StringVectorType> StringCacheType; 00210 #endif 00211 00212 typedef NumberCacheType NumberResultsCacheType; 00213 00214 #if defined(XALAN_NODESORTER_CACHE_XOBJECTS) 00215 typedef XObjectCacheType StringResultsCacheType; 00216 #else 00217 typedef StringCacheType StringResultsCacheType; 00218 #endif 00219 00220 private: 00221 00228 void 00229 sort(StylesheetExecutionContext& executionContext); 00230 00231 // Data members... 00232 NumberResultsCacheType m_numberResultsCache; 00233 00234 StringResultsCacheType m_stringResultsCache; 00235 00236 NodeSortKeyVectorType m_keys; 00237 00238 NodeVectorType m_scratchVector; 00239 }; 00240 00241 00242 00243 XALAN_CPP_NAMESPACE_END 00244 00245 00246 00247 #endif // XALAN_NODESORTER_HEADER_GUARD

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.8
Copyright © 1999-2004 The Apache Software Foundation. All Rights Reserved.