00001 /* 00002 * Licensed to the Apache Software Foundation (ASF) under one 00003 * or more contributor license agreements. See the NOTICE file 00004 * distributed with this work for additional information 00005 * regarding copyright ownership. The ASF licenses this file 00006 * to you under the Apache License, Version 2.0 (the "License"); 00007 * you may not use this file except in compliance with the License. 00008 * You may obtain a copy of the License at 00009 * 00010 * http://www.apache.org/licenses/LICENSE-2.0 00011 * 00012 * Unless required by applicable law or agreed to in writing, software 00013 * distributed under the License is distributed on an "AS IS" BASIS, 00014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00015 * See the License for the specific language governing permissions and 00016 * limitations under the License. 00017 */ 00018 #if !defined(MUTABLENODEREFLIST_HEADER_GUARD_1357924680) 00019 #define MUTABLENODEREFLIST_HEADER_GUARD_1357924680 00020 00021 00022 00023 // Base include file. Must be first. 00024 #include <xalanc/XPath/XPathDefinitions.hpp> 00025 00026 00027 00028 #include <xalanc/XPath/NodeRefList.hpp> 00029 00030 00031 00032 XALAN_CPP_NAMESPACE_BEGIN 00033 00034 00035 00036 class XPathExecutionContext; 00037 class XalanDocument; 00038 class XalanNodeList; 00039 00040 00041 00042 /** 00043 * Local implementation of MutableNodeRefList. This class is for internal use 00044 * only. 00045 */ 00046 class XALAN_XPATH_EXPORT MutableNodeRefList : public NodeRefList 00047 { 00048 public: 00049 00050 /** 00051 * Construct an empty mutable node list. 00052 */ 00053 explicit 00054 MutableNodeRefList(MemoryManager& theManager); 00055 00056 static MutableNodeRefList* 00057 create(MemoryManager& theManager); 00058 /** 00059 * Construct a mutable node list from another list. 00060 * 00061 * @param theSource source list 00062 */ 00063 MutableNodeRefList(const MutableNodeRefList& theSource, 00064 MemoryManager& theManager); 00065 00066 /** 00067 * Construct a mutable node list from another list. 00068 * 00069 * @param theSource source list 00070 */ 00071 explicit 00072 MutableNodeRefList(const NodeRefListBase& theSource, 00073 MemoryManager& theManager); 00074 00075 virtual 00076 ~MutableNodeRefList(); 00077 00078 MutableNodeRefList& 00079 operator=(const MutableNodeRefList& theRHS); 00080 00081 MutableNodeRefList& 00082 operator=(const NodeRefList& theRHS); 00083 00084 MutableNodeRefList& 00085 operator=(const NodeRefListBase& theRHS); 00086 00087 MutableNodeRefList& 00088 operator=(const XalanNodeList* theRHS); 00089 00090 /** 00091 * Add a node at to the list. 00092 * 00093 * @param n node to add 00094 */ 00095 void 00096 addNode(XalanNode* n); 00097 00098 /** 00099 * Insert a node at a given position. 00100 * 00101 * @param n node to insert 00102 * @param pos position of insertion 00103 */ 00104 void 00105 insertNode( 00106 XalanNode* n, 00107 size_type pos); 00108 00109 /** 00110 * Remove a node from the list. 00111 * 00112 * @param n node to insert 00113 */ 00114 void 00115 removeNode(const XalanNode* n); 00116 00117 /** 00118 * Remove a node from the list. 00119 * 00120 * @param pos position of node in list 00121 */ 00122 void 00123 removeNode(size_type pos); 00124 00125 /** 00126 * Remove all nodes. 00127 */ 00128 void 00129 clear(); 00130 00131 /** 00132 * Set a item. 00133 * 00134 * @param pos position of node to modify 00135 * @param n node to insert, default is empty node 00136 */ 00137 void 00138 setNode( 00139 size_type pos, 00140 XalanNode* n = 0); 00141 00142 /** 00143 * Copy NodeList members into this nodelist, adding in document order. If 00144 * a node is null, don't add it. 00145 * 00146 * @param nodelist node list to add 00147 */ 00148 void 00149 addNodes(const XalanNodeList& nodelist); 00150 00151 /** 00152 * Copy NodeList members into this nodelist, adding in document order. If 00153 * a node is null, don't add it. 00154 * 00155 * @param nodelist node list to add 00156 */ 00157 void 00158 addNodes(const NodeRefListBase& nodelist); 00159 00160 /** 00161 * Copy NodeList members into this nodelist, adding in document order. 00162 * 00163 * @param nodelist node list to add 00164 * @param executionContext the current execution context 00165 */ 00166 void 00167 addNodesInDocOrder( 00168 const XalanNodeList& nodelist, 00169 XPathExecutionContext& executionContext); 00170 00171 /** 00172 * Copy NodeList members into this nodelist, adding in document order. 00173 * 00174 * @param nodelist node list to add 00175 * @param executionContext the current execution context 00176 */ 00177 void 00178 addNodesInDocOrder( 00179 const NodeRefListBase& nodelist, 00180 XPathExecutionContext& executionContext); 00181 00182 /** 00183 * Copy NodeList members into this nodelist, adding in document order. 00184 * 00185 * @param nodelist node list to add 00186 * @param executionContext the current execution context 00187 */ 00188 void 00189 addNodesInDocOrder( 00190 const MutableNodeRefList& nodelist, 00191 XPathExecutionContext& executionContext); 00192 00193 /** 00194 * Add a node into list where it should occur in document order. 00195 * 00196 * @param node node object to add 00197 * @param executionContext the current execution context 00198 */ 00199 void 00200 addNodeInDocOrder( 00201 XalanNode* node, 00202 XPathExecutionContext& executionContext); 00203 00204 /** 00205 * Clear any null entries in the node list. 00206 */ 00207 void 00208 clearNulls(); 00209 00210 /** 00211 * Reverse the nodes in the list. 00212 */ 00213 void 00214 reverse(); 00215 00216 /** 00217 * Reserve space for the supplied number of nodes. 00218 * This is taken as an optimization, and may be 00219 * ignored. You might want to call this when you 00220 * know the number of nodes you're about to add to 00221 * this list. 00222 * 00223 * Remember to take into account the current size of 00224 * the list when calling this. That means you will 00225 * probably want to add the result of getLength() to 00226 * the number of nodes you're planning to add. 00227 * 00228 * @param theCount the number of nodes to reserve space for 00229 */ 00230 void 00231 reserve(size_type theCount) 00232 { 00233 m_nodeList.reserve(theCount); 00234 } 00235 00236 /** 00237 * See if the order of the nodes is an unknown order. 00238 */ 00239 bool 00240 getUnknownOrder() const 00241 { 00242 return m_order == eUnknownOrder ? true : false; 00243 } 00244 00245 void 00246 setUnknownOrder() 00247 { 00248 m_order = eUnknownOrder; 00249 } 00250 00251 /** 00252 * See if the order of the nodes is document order. 00253 */ 00254 bool 00255 getDocumentOrder() const 00256 { 00257 return m_order == eDocumentOrder ? true : false; 00258 } 00259 00260 /** 00261 * Set the known order of the nodes. This should 00262 * only be done when the order is known. Otherwise, 00263 * disaster will ensue. 00264 */ 00265 void 00266 setDocumentOrder() 00267 { 00268 m_order = eDocumentOrder; 00269 } 00270 00271 /** 00272 * See if the order of the nodes is reverse document order. 00273 */ 00274 bool 00275 getReverseDocumentOrder() const 00276 { 00277 return m_order == eReverseDocumentOrder ? true : false; 00278 } 00279 00280 /** 00281 * Set the known order of the nodes. This should 00282 * only be done when the order is known. Otherwise, 00283 * disaster will ensue. 00284 */ 00285 void 00286 setReverseDocumentOrder() 00287 { 00288 m_order = eReverseDocumentOrder; 00289 } 00290 00291 typedef NodeListVectorType::iterator NodeListIteratorType; 00292 00293 class addNodeInDocOrderFunctor 00294 { 00295 public: 00296 00297 addNodeInDocOrderFunctor( 00298 MutableNodeRefList& theList, 00299 XPathExecutionContext& theExecutionContext) : 00300 m_list(theList), 00301 m_executionContext(theExecutionContext) 00302 { 00303 } 00304 00305 void 00306 operator()(XalanNode* theNode) const 00307 { 00308 m_list.addNodeInDocOrder(theNode, m_executionContext); 00309 } 00310 00311 private: 00312 00313 MutableNodeRefList& m_list; 00314 00315 XPathExecutionContext& m_executionContext; 00316 }; 00317 00318 void 00319 swap(MutableNodeRefList& theOther) 00320 { 00321 NodeRefList::swap(theOther); 00322 00323 const eOrder temp = m_order; 00324 00325 m_order = theOther.m_order; 00326 00327 theOther.m_order = temp; 00328 } 00329 00330 private: 00331 //not defined 00332 MutableNodeRefList(const MutableNodeRefList& theSource); 00333 00334 // An enum to determine what the order of the nodes is... 00335 enum eOrder { eUnknownOrder, eDocumentOrder, eReverseDocumentOrder }; 00336 00337 eOrder m_order; 00338 }; 00339 00340 XALAN_USES_MEMORY_MANAGER(MutableNodeRefList) 00341 00342 XALAN_CPP_NAMESPACE_END 00343 00344 00345 00346 #endif // MUTABLENODEREFLIST_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.11 |
|