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  */
64  MemoryManager& theManager);
65 
66  /**
67  * Construct a mutable node list from another list.
68  *
69  * @param theSource source list
70  */
71  explicit
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
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
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
116 
117  /**
118  * Remove a node from the list.
119  *
120  * @param pos position of node in list
121  */
122  void
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
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
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
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
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
201  XalanNode* node,
202  XPathExecutionContext& executionContext);
203 
204  /**
205  * Clear any null entries in the node list.
206  */
207  void
209 
210  /**
211  * Reverse the nodes in the list.
212  */
213  void
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
#define XALAN_XPATH_EXPORT
#define XALAN_USES_MEMORY_MANAGER(Type)
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
addNodeInDocOrderFunctor(MutableNodeRefList &theList, XPathExecutionContext &theExecutionContext)
Local implementation of MutableNodeRefList.
void addNodeInDocOrder(XalanNode *node, XPathExecutionContext &executionContext)
Add a node into list where it should occur in document order.
void clearNulls()
Clear any null entries in the node list.
MutableNodeRefList(const MutableNodeRefList &theSource, MemoryManager &theManager)
Construct a mutable node list from another list.
void reverse()
Reverse the nodes in the list.
MutableNodeRefList & operator=(const NodeRefListBase &theRHS)
void addNodes(const NodeRefListBase &nodelist)
Copy NodeList members into this nodelist, adding in document order.
void addNodes(const XalanNodeList &nodelist)
Copy NodeList members into this nodelist, adding in document order.
void reserve(size_type theCount)
Reserve space for the supplied number of nodes.
void setNode(size_type pos, XalanNode *n=0)
Set a item.
void setReverseDocumentOrder()
Set the known order of the nodes.
bool getDocumentOrder() const
See if the order of the nodes is document order.
MutableNodeRefList & operator=(const XalanNodeList *theRHS)
MutableNodeRefList(MemoryManager &theManager)
Construct an empty mutable node list.
void removeNode(size_type pos)
Remove a node from the list.
MutableNodeRefList & operator=(const MutableNodeRefList &theRHS)
MutableNodeRefList & operator=(const NodeRefList &theRHS)
void removeNode(const XalanNode *n)
Remove a node from the list.
void swap(MutableNodeRefList &theOther)
MutableNodeRefList(const NodeRefListBase &theSource, MemoryManager &theManager)
Construct a mutable node list from another list.
void clear()
Remove all nodes.
void insertNode(XalanNode *n, size_type pos)
Insert a node at a given position.
void addNodesInDocOrder(const MutableNodeRefList &nodelist, XPathExecutionContext &executionContext)
Copy NodeList members into this nodelist, adding in document order.
bool getReverseDocumentOrder() const
See if the order of the nodes is reverse document order.
void setDocumentOrder()
Set the known order of the nodes.
static MutableNodeRefList * create(MemoryManager &theManager)
void addNodesInDocOrder(const NodeRefListBase &nodelist, XPathExecutionContext &executionContext)
Copy NodeList members into this nodelist, adding in document order.
void addNode(XalanNode *n)
Add a node at to the list.
NodeListVectorType::iterator NodeListIteratorType
bool getUnknownOrder() const
See if the order of the nodes is an unknown order.
void addNodesInDocOrder(const XalanNodeList &nodelist, XPathExecutionContext &executionContext)
Copy NodeList members into this nodelist, adding in document order.
Local implementation of NodeRefList.
Local implementation of NodeRefList.
Definition: NodeRefList.hpp:44
void swap(XalanVector< Type > &theLHS, XalanVector< Type > &theRHS)