Xalan-C++ API Reference  1.12.0
MutableNodeRefList.hpp
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 #if !defined(MUTABLENODEREFLIST_HEADER_GUARD_1357924680)
19 #define MUTABLENODEREFLIST_HEADER_GUARD_1357924680
20 
21 
22 
23 // Base include file. Must be first.
25 
26 
27 
29 
30 
31 
32 namespace XALAN_CPP_NAMESPACE {
33 
34 
35 
36 class XPathExecutionContext;
37 class XalanDocument;
38 class XalanNodeList;
39 
40 
41 
42 /**
43  * Local implementation of MutableNodeRefList. This class is for internal use
44  * only.
45  */
47 {
48 public:
49 
50  /**
51  * Construct an empty mutable node list.
52  */
53  explicit
54  MutableNodeRefList(MemoryManager& theManager);
55 
56  static MutableNodeRefList*
57  create(MemoryManager& theManager);
58  /**
59  * Construct a mutable node list from another list.
60  *
61  * @param theSource source list
62  */
63  MutableNodeRefList(const MutableNodeRefList& theSource,
64  MemoryManager& theManager);
65 
66  /**
67  * Construct a mutable node list from another list.
68  *
69  * @param theSource source list
70  */
71  explicit
72  MutableNodeRefList(const NodeRefListBase& theSource,
73  MemoryManager& theManager);
74 
75  virtual
77 
79  operator=(const MutableNodeRefList& theRHS);
80 
82  operator=(const NodeRefList& theRHS);
83 
85  operator=(const NodeRefListBase& theRHS);
86 
88  operator=(const XalanNodeList* theRHS);
89 
90  /**
91  * Add a node at to the list.
92  *
93  * @param n node to add
94  */
95  void
96  addNode(XalanNode* n);
97 
98  /**
99  * Insert a node at a given position.
100  *
101  * @param n node to insert
102  * @param pos position of insertion
103  */
104  void
105  insertNode(
106  XalanNode* n,
107  size_type pos);
108 
109  /**
110  * Remove a node from the list.
111  *
112  * @param n node to insert
113  */
114  void
115  removeNode(const XalanNode* n);
116 
117  /**
118  * Remove a node from the list.
119  *
120  * @param pos position of node in list
121  */
122  void
123  removeNode(size_type pos);
124 
125  /**
126  * Remove all nodes.
127  */
128  void
129  clear();
130 
131  /**
132  * Set a item.
133  *
134  * @param pos position of node to modify
135  * @param n node to insert, default is empty node
136  */
137  void
138  setNode(
139  size_type pos,
140  XalanNode* n = 0);
141 
142  /**
143  * Copy NodeList members into this nodelist, adding in document order. If
144  * a node is null, don't add it.
145  *
146  * @param nodelist node list to add
147  */
148  void
149  addNodes(const XalanNodeList& nodelist);
150 
151  /**
152  * Copy NodeList members into this nodelist, adding in document order. If
153  * a node is null, don't add it.
154  *
155  * @param nodelist node list to add
156  */
157  void
158  addNodes(const NodeRefListBase& nodelist);
159 
160  /**
161  * Copy NodeList members into this nodelist, adding in document order.
162  *
163  * @param nodelist node list to add
164  * @param executionContext the current execution context
165  */
166  void
167  addNodesInDocOrder(
168  const XalanNodeList& nodelist,
169  XPathExecutionContext& executionContext);
170 
171  /**
172  * Copy NodeList members into this nodelist, adding in document order.
173  *
174  * @param nodelist node list to add
175  * @param executionContext the current execution context
176  */
177  void
178  addNodesInDocOrder(
179  const NodeRefListBase& nodelist,
180  XPathExecutionContext& executionContext);
181 
182  /**
183  * Copy NodeList members into this nodelist, adding in document order.
184  *
185  * @param nodelist node list to add
186  * @param executionContext the current execution context
187  */
188  void
189  addNodesInDocOrder(
190  const MutableNodeRefList& nodelist,
191  XPathExecutionContext& executionContext);
192 
193  /**
194  * Add a node into list where it should occur in document order.
195  *
196  * @param node node object to add
197  * @param executionContext the current execution context
198  */
199  void
200  addNodeInDocOrder(
201  XalanNode* node,
202  XPathExecutionContext& executionContext);
203 
204  /**
205  * Clear any null entries in the node list.
206  */
207  void
208  clearNulls();
209 
210  /**
211  * Reverse the nodes in the list.
212  */
213  void
214  reverse();
215 
216  /**
217  * Reserve space for the supplied number of nodes.
218  * This is taken as an optimization, and may be
219  * ignored. You might want to call this when you
220  * know the number of nodes you're about to add to
221  * this list.
222  *
223  * Remember to take into account the current size of
224  * the list when calling this. That means you will
225  * probably want to add the result of getLength() to
226  * the number of nodes you're planning to add.
227  *
228  * @param theCount the number of nodes to reserve space for
229  */
230  void
231  reserve(size_type theCount)
232  {
233  m_nodeList.reserve(theCount);
234  }
235 
236  /**
237  * See if the order of the nodes is an unknown order.
238  */
239  bool
241  {
242  return m_order == eUnknownOrder ? true : false;
243  }
244 
245  void
247  {
248  m_order = eUnknownOrder;
249  }
250 
251  /**
252  * See if the order of the nodes is document order.
253  */
254  bool
256  {
257  return m_order == eDocumentOrder ? true : false;
258  }
259 
260  /**
261  * Set the known order of the nodes. This should
262  * only be done when the order is known. Otherwise,
263  * disaster will ensue.
264  */
265  void
267  {
268  m_order = eDocumentOrder;
269  }
270 
271  /**
272  * See if the order of the nodes is reverse document order.
273  */
274  bool
276  {
277  return m_order == eReverseDocumentOrder ? true : false;
278  }
279 
280  /**
281  * Set the known order of the nodes. This should
282  * only be done when the order is known. Otherwise,
283  * disaster will ensue.
284  */
285  void
287  {
288  m_order = eReverseDocumentOrder;
289  }
290 
292 
294  {
295  public:
296 
298  MutableNodeRefList& theList,
299  XPathExecutionContext& theExecutionContext) :
300  m_list(theList),
301  m_executionContext(theExecutionContext)
302  {
303  }
304 
305  void
306  operator()(XalanNode* theNode) const
307  {
308  m_list.addNodeInDocOrder(theNode, m_executionContext);
309  }
310 
311  private:
312 
313  MutableNodeRefList& m_list;
314 
315  XPathExecutionContext& m_executionContext;
316  };
317 
318  void
320  {
321  NodeRefList::swap(theOther);
322 
323  const eOrder temp = m_order;
324 
325  m_order = theOther.m_order;
326 
327  theOther.m_order = temp;
328  }
329 
330 private:
331  //not defined
332  MutableNodeRefList(const MutableNodeRefList& theSource);
333 
334  // An enum to determine what the order of the nodes is...
335  enum eOrder { eUnknownOrder, eDocumentOrder, eReverseDocumentOrder };
336 
337  eOrder m_order;
338 };
339 
340 XALAN_USES_MEMORY_MANAGER(MutableNodeRefList)
341 
342 }
343 
344 
345 
346 #endif // MUTABLENODEREFLIST_HEADER_GUARD_1357924680
xalanc::MutableNodeRefList::setUnknownOrder
void setUnknownOrder()
Definition: MutableNodeRefList.hpp:246
XALAN_CPP_NAMESPACE
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
Definition: XalanVersion.hpp:76
xalanc::clear
void clear(XalanDOMString &theString)
Remove all elements from target string.
Definition: DOMStringHelper.hpp:2475
xalanc::XalanNode
Definition: XalanNode.hpp:38
XALAN_USES_MEMORY_MANAGER
#define XALAN_USES_MEMORY_MANAGER(Type)
Definition: XalanMemoryManagement.hpp:589
xalanc::MutableNodeRefList::setDocumentOrder
void setDocumentOrder()
Set the known order of the nodes.
Definition: MutableNodeRefList.hpp:266
xalanc::MutableNodeRefList::NodeListIteratorType
NodeListVectorType::iterator NodeListIteratorType
Definition: MutableNodeRefList.hpp:291
xalanc::MutableNodeRefList
Local implementation of MutableNodeRefList.
Definition: MutableNodeRefList.hpp:46
xalanc::swap
void swap(XalanVector< Type > &theLHS, XalanVector< Type > &theRHS)
Definition: XalanVector.hpp:1107
xalanc::NodeRefList
Local implementation of NodeRefList.
Definition: NodeRefList.hpp:43
NodeRefList.hpp
XALAN_XPATH_EXPORT
#define XALAN_XPATH_EXPORT
Definition: XPathDefinitions.hpp:35
xalanc::MutableNodeRefList::reserve
void reserve(size_type theCount)
Reserve space for the supplied number of nodes.
Definition: MutableNodeRefList.hpp:231
xalanc::MutableNodeRefList::setReverseDocumentOrder
void setReverseDocumentOrder()
Set the known order of the nodes.
Definition: MutableNodeRefList.hpp:286
xalanc::XalanNodeList
Definition: XalanNodeList.hpp:36
xalanc::MutableNodeRefList::getUnknownOrder
bool getUnknownOrder() const
See if the order of the nodes is an unknown order.
Definition: MutableNodeRefList.hpp:240
xalanc::MutableNodeRefList::addNodeInDocOrderFunctor
Definition: MutableNodeRefList.hpp:293
xalanc::MutableNodeRefList::addNodeInDocOrderFunctor::addNodeInDocOrderFunctor
addNodeInDocOrderFunctor(MutableNodeRefList &theList, XPathExecutionContext &theExecutionContext)
Definition: MutableNodeRefList.hpp:297
xalanc::XPathExecutionContext
Definition: XPathExecutionContext.hpp:82
xalanc::NodeRefListBase
Local implementation of NodeRefList.
Definition: NodeRefListBase.hpp:44
xalanc::NodeRefListBase::size_type
XalanSize_t size_type
Definition: NodeRefListBase.hpp:53
xalanc::MutableNodeRefList::getDocumentOrder
bool getDocumentOrder() const
See if the order of the nodes is document order.
Definition: MutableNodeRefList.hpp:255
xalanc::MutableNodeRefList::getReverseDocumentOrder
bool getReverseDocumentOrder() const
See if the order of the nodes is reverse document order.
Definition: MutableNodeRefList.hpp:275
xalanc::MutableNodeRefList::swap
void swap(MutableNodeRefList &theOther)
Definition: MutableNodeRefList.hpp:319
XPathDefinitions.hpp
xalanc::MutableNodeRefList::addNodeInDocOrderFunctor::operator()
void operator()(XalanNode *theNode) const
Definition: MutableNodeRefList.hpp:306