Xalan-C++ API Reference  1.12.0
XalanSourceTreeDocument.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(XALANSOURCETREEDOCUMENT_HEADER_GUARD_1357924680)
19 #define XALANSOURCETREEDOCUMENT_HEADER_GUARD_1357924680
20 
21 
22 
24 
25 
26 
29 
30 
31 
34 
35 
36 
40 
41 
42 
53 
54 
55 
56 namespace XERCES_CPP_NAMESPACE
57 {
58  class Attributes;
59  class AttributeList;
60 }
61 
62 
63 
64 namespace XALAN_CPP_NAMESPACE {
65 
66 
67 
68 typedef xercesc::Attributes AttributesType;
69 typedef xercesc::AttributeList AttributeListType;
70 
71 
72 
73 class PrefixResolver;
74 class XalanSourceTreeAttr;
75 
76 
77 
79 {
80 public:
81 
83 
84  typedef XalanMap<
85  const XalanDOMChar*,
87 
88  typedef XalanMap<
91 
92 
93  /**
94  * Perform static initialization. See class XalanSourceTreeInit.
95  */
96  static void
97  initialize(MemoryManager& theManager);
98 
99  /**
100  * Perform static shut down. See class XalanSourceTreeInit.
101  */
102  static void
103  terminate();
104 
105 
106  enum { eDefaultAttributeAllocatorBlockSize = 100,
107  eDefaultAttributeNSAllocatorBlockSize = 50,
108  eDefaultCommentAllocatorBlockSize = 10,
109  eDefaultElementAllocatorBlockSize = 100,
110  eDefaultElementNSAllocatorBlockSize = 100,
111  eDefaultPIAllocatorBlockSize = 10,
112  eDefaultTextAllocatorBlockSize = 100,
113  eDefaultTextIWSAllocatorBlockSize = 100,
114  eDefaultNamesStringPoolBlockSize = XalanDOMStringPool::eDefaultBlockSize,
115  eDefaultNamesStringPoolBucketCount = XalanDOMStringPool::eDefaultBucketCount,
116  eDefaultNamesStringPoolBucketSize = XalanDOMStringPool::eDefaultBucketSize,
117  eDefaultValuesStringPoolBlockSize = XalanDOMStringPool::eDefaultBlockSize,
118  eDefaultValuesStringPoolBucketCount = 997,
119  eDefaultValuesStringPoolBucketSize = XalanDOMStringPool::eDefaultBucketSize };
120 
121 
126 
127  /**
128  *
129  * Constructor for XalanSourceTreeDocument.
130  *
131  * @param fPoolAllText If false, text node data that is not whitespace will not be pooled.
132  * @param theNamesStringPoolBlockSize The block size for allocating strings in the name pool
133  * @param theNamesStringPoolBucketCount The number of buckets for allocating strings in the name pool
134  * @param theNamesStringPoolBucketSize The bucket size for allocating strings in the name pool
135  * @param theValuesStringPoolBlockSize The block size for allocating strings in the values pool
136  * @param theValuesStringPoolBucketCount The number of buckets for allocating strings in the values pool
137  * @param theValuesStringPoolBucketSize The bucket size for allocating strings in the values pool
138  *
139  */
141  MemoryManager& theManager,
142  bool fPoolAllText = s_poolAllTextNodes,
143  block_size_type theNamesStringPoolBlockSize = eDefaultNamesStringPoolBlockSize,
144  bucket_count_type theNamesStringPoolBucketCount = eDefaultNamesStringPoolBucketCount,
145  bucket_size_type theNamesStringPoolBucketSize = eDefaultNamesStringPoolBucketSize,
146  block_size_type theValuesStringPoolBlockSize = eDefaultValuesStringPoolBlockSize,
147  bucket_count_type theValuesStringPoolBucketCount = eDefaultValuesStringPoolBucketCount,
148  bucket_size_type theValuesStringPoolBucketSize = eDefaultValuesStringPoolBucketSize);
149 
150 
152  create(
153  MemoryManager& theManager,
154  bool fPoolAllText = s_poolAllTextNodes,
155  block_size_type theNamesStringPoolBlockSize = eDefaultNamesStringPoolBlockSize,
156  bucket_count_type theNamesStringPoolBucketCount = eDefaultNamesStringPoolBucketCount,
157  bucket_size_type theNamesStringPoolBucketSize = eDefaultNamesStringPoolBucketSize,
158  block_size_type theValuesStringPoolBlockSize = eDefaultValuesStringPoolBlockSize,
159  bucket_count_type theValuesStringPoolBucketCount = eDefaultValuesStringPoolBucketCount,
160  bucket_size_type theValuesStringPoolBucketSize = eDefaultValuesStringPoolBucketSize);
161 
162  /**
163  *
164  * Constructor for XalanSourceTreeDocument.
165  *
166  * @param theAttributeBlockSize The block size for allocating attribute nodes
167  * @param theAttributeNSBlockSize The block size for allocating attribute NS nodes
168  * @param theCommentBlockSize The block size for allocating comment nodes
169  * @param theElementBlockSize The block size for allocating element nodes
170  * @param theElementNSBlockSize The block size for allocating element nodes
171  * @param theTextBlockSize The block size for allocating text nodes,
172  * @param theTextIWSBlockSize The block size for allocating text IWS nodes,
173  * @param fPoolAllText If false, text node data that is not whitespace will not be pooled.
174  *
175  */
177  MemoryManager& theManager,
178  allocator_size_type theAttributeBlockSize,
179  allocator_size_type theAttributeNSBlockSize,
180  allocator_size_type theCommentBlockSize,
181  allocator_size_type theElementBlockSize,
182  allocator_size_type theElementNSBlockSize,
183  allocator_size_type thePIBlockSize,
184  allocator_size_type theTextBlockSize,
185  allocator_size_type theTextIWSBlockSize,
186  bool fPoolAllText = s_poolAllTextNodes);
187 
188  virtual
190 
191  // These interfaces are inherited from XalanNode...
192  virtual const XalanDOMString&
193  getNodeName() const;
194 
195  virtual const XalanDOMString&
196  getNodeValue() const;
197 
198  virtual NodeType
199  getNodeType() const;
200 
201  virtual XalanNode*
202  getParentNode() const;
203 
204  virtual const XalanNodeList*
205  getChildNodes() const;
206 
207  virtual XalanNode*
208  getFirstChild() const;
209 
210  virtual XalanNode*
211  getLastChild() const;
212 
213  virtual XalanNode*
214  getPreviousSibling() const;
215 
216  virtual XalanNode*
217  getNextSibling() const;
218 
219  virtual const XalanNamedNodeMap*
220  getAttributes() const;
221 
222  virtual XalanDocument*
223  getOwnerDocument() const;
224 
225  virtual const XalanDOMString&
226  getNamespaceURI() const;
227 
228  virtual const XalanDOMString&
229  getPrefix() const;
230 
231  virtual const XalanDOMString&
232  getLocalName() const;
233 
234  virtual bool
235  isIndexed() const;
236 
237  virtual IndexType
238  getIndex() const;
239 
240  virtual XalanElement*
241  getDocumentElement() const;
242 
243  virtual XalanElement*
244  getElementById(const XalanDOMString& elementId) const;
245 
246 
247  // Interfaces not inherited from XalanDocument...
248 
249  static bool
251  {
252  return s_poolAllTextNodes;
253  }
254 
255  static void
257  {
258  s_poolAllTextNodes = fPool;
259  }
260 
261 
263  createElementNode(
264  const XalanDOMChar* name,
265  const AttributeListType& attrs,
266  XalanNode* theParentNode = 0,
267  XalanNode* thePreviousSibling = 0,
268  XalanNode* theNextSibling = 0,
269  bool fAddXMLNamespaceAttribute = false);
270 
272  createElementNode(
273  const XalanDOMChar* uri,
274  const XalanDOMChar* localname,
275  const XalanDOMChar* qname,
276  const AttributesType& attrs,
277  XalanNode* theParentNode = 0,
278  XalanNode* thePreviousSibling = 0,
279  XalanNode* theNextSibling = 0,
280  bool fAddXMLNamespaceAttribute = false);
281 
283  createElementNode(
284  const XalanDOMChar* tagName,
285  const AttributeListType& attrs,
286  const PrefixResolver& thePrefixResolver,
287  XalanNode* theParentNode = 0,
288  XalanNode* thePreviousSibling = 0,
289  XalanNode* theNextSibling = 0,
290  bool fAddXMLNamespaceAttribute = false);
291 
293  createElementNode(
294  const XalanDOMChar* name,
295  const AttributesType& attrs,
296  XalanNode* theParentNode = 0,
297  XalanNode* thePreviousSibling = 0,
298  XalanNode* theNextSibling = 0,
299  bool fAddXMLNamespaceAttribute = false);
300 
302  createCommentNode(
303  const XalanDOMChar* data,
305  XalanNode* theParentNode = 0,
306  XalanNode* thePreviousSibling = 0,
307  XalanNode* theNextSibling = 0);
308 
310  createProcessingInstructionNode(
311  const XalanDOMChar* target,
312  const XalanDOMChar* data,
313  XalanNode* theParentNode = 0,
314  XalanNode* thePreviousSibling = 0,
315  XalanNode* theNextSibling = 0);
316 
318  createTextNode(
319  const XalanDOMChar* chars,
321  XalanNode* theParentNode = 0,
322  XalanNode* thePreviousSibling = 0,
323  XalanNode* theNextSibling = 0);
324 
326  createTextIWSNode(
327  const XalanDOMChar* chars,
329  XalanNode* theParentNode = 0,
330  XalanNode* thePreviousSibling = 0,
331  XalanNode* theNextSibling = 0);
332 
333  void
334  unparsedEntityDeclaration(
335  const XalanDOMChar* name,
336  const XalanDOMChar* publicId,
337  const XalanDOMChar* systemId,
338  const XalanDOMChar* notationName);
339 
340  const XalanDOMString&
341  getUnparsedEntityURI(const XalanDOMString& theName) const;
342 
343  // Child node setters...
344  void
345  appendChildNode(XalanSourceTreeComment* theChild);
346 
347  void
348  appendChildNode(XalanSourceTreeElement* theChild);
349 
350  void
351  appendChildNode(XalanSourceTreeProcessingInstruction* theChild);
352 
353 private:
354 
355  MemoryManager&
356  getMemoryManager()
357  {
358  return m_stringBuffer.getMemoryManager();
359  }
360 
361  // Helper functions...
362  XalanSourceTreeAttr*
363  createAttribute(
364  const XalanDOMChar* theName,
365  const XalanDOMChar* theValue,
366  XalanSourceTreeElement* theOwnerElement,
367  const PrefixResolver& thePrefixResolver);
368 
369  XalanSourceTreeAttr*
370  createAttribute(
371  const XalanDOMChar* theName,
372  const XalanDOMChar* theValue,
373  XalanSourceTreeElement* theOwnerElement);
374 
375  size_t
376  createAttributes(
377  XalanSourceTreeAttr** theAttributeVector,
378  const AttributeListType& attrs,
379  size_t theStartIndex,
380  XalanSourceTreeElement* theOwnerElement,
381  bool fCreateNamespaces,
382  const PrefixResolver* thePrefixResolver = 0);
383 
384  XalanSourceTreeElement*
385  createElementNode(
386  const XalanDOMChar* theTagName,
387  XalanSourceTreeAttr** theAttributeVector,
388  XalanSize_t theAttributeCount,
389  XalanNode* theParentNode,
390  XalanNode* thePreviousSibling,
391  XalanNode* theNextSibling,
392  const PrefixResolver& thePrefixResolver);
393 
394  size_t
395  createAttributes(
396  XalanSourceTreeAttr** theAttributeVector,
397  const AttributesType& theAttributes,
398  size_t theStartIndex,
399  XalanSourceTreeElement* theOwnerElement,
400  bool fCreateNamespaces);
401 
402  void
403  createAttributes(
404  const AttributesType& theAttributes,
405  XalanSourceTreeAttr** theAttributeVector,
406  XalanSourceTreeElement* theOwnerElement,
407  bool fAddXMLNamespaceAttribute);
408 
409  const XalanDOMString&
410  getTextNodeString(
411  const XalanDOMChar* chars,
413 
414  const XalanDOMString*
415  getNamespaceForPrefix(
416  const XalanDOMChar* theName,
417  const PrefixResolver& thePrefixResolver,
418  XalanDOMString& thePrefix,
419  bool fUseDefault,
420  const XalanDOMChar** theLocalName = 0);
421 
422  // Not implemented...
423  XalanSourceTreeDocument(const XalanSourceTreeDocument& theSource);
424 
425  XalanSourceTreeDocument&
426  operator=(const XalanSourceTreeDocument& theRHS);
427 
428  bool
429  operator==(const XalanSourceTreeDocument& theRHS) const;
430 
431 
432  // Data members...
433  XalanNode* m_firstChild;
434 
435  XalanSourceTreeElement* m_documentElement;
436 
437  XalanSourceTreeAttributeAllocator m_attributeAllocator;
438 
439  XalanSourceTreeAttributeNSAllocator m_attributeNSAllocator;
440 
441  XalanSourceTreeCommentAllocator m_commentAllocator;
442 
443  XalanSourceTreeElementAAllocator m_elementAAllocator;
444 
445  XalanSourceTreeElementANSAllocator m_elementANSAllocator;
446 
447  XalanSourceTreeElementNAAllocator m_elementNAAllocator;
448 
449  XalanSourceTreeElementNANSAllocator m_elementNANSAllocator;
450 
451  XalanSourceTreeProcessingInstructionAllocator m_piAllocator;
452 
453  XalanSourceTreeTextAllocator m_textAllocator;
454 
455  XalanSourceTreeTextIWSAllocator m_textIWSAllocator;
456 
457  XalanDOMStringPool m_namesStringPool;
458 
459  XalanDOMStringPool m_valuesStringPool;
460 
461  AttributesArrayAllocatorType m_attributesVector;
462 
463  IndexType m_nextIndexValue;
464 
465  const bool m_poolAllText;
466 
467  ElementByIDMapType m_elementsByID;
468 
469  UnparsedEntityURIMapType m_unparsedEntityURIs;
470 
471  XalanDOMStringAllocator m_nonPooledStrings;
472 
473  XalanDOMString m_stringBuffer;
474 
475  static const XalanDOMString& s_nameString;
476 
477  static bool s_poolAllTextNodes;
478 };
479 
480 
481 
482 }
483 
484 
485 
486 #endif // !defined(XALANSOURCETREEDOCUMENT_HEADER_GUARD_1357924680)
XalanSourceTreeTextAllocator.hpp
xalanc::XalanSourceTreeDocument::ElementByIDMapType
XalanMap< const XalanDOMChar *, XalanSourceTreeElement * > ElementByIDMapType
Definition: XalanSourceTreeDocument.hpp:86
XALAN_CPP_NAMESPACE
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
Definition: XalanVersion.hpp:76
xalanc::AttributeListType
xercesc::AttributeList AttributeListType
Definition: AttributeListImpl.hpp:41
xalanc::XalanNode
Definition: XalanNode.hpp:38
xalanc::XalanSourceTreeDocument::block_size_type
XalanDOMStringPool::block_size_type block_size_type
Definition: XalanSourceTreeDocument.hpp:123
xalanc::XalanNode::NodeType
NodeType
Definition: XalanNode.hpp:47
XalanDOMString.hpp
XalanSourceTreeAttributeAllocator.hpp
xalanc::XalanSourceTreeDocument::AttributesArrayAllocatorType
XalanArrayAllocator< XalanSourceTreeAttr * > AttributesArrayAllocatorType
Definition: XalanSourceTreeDocument.hpp:82
XalanSourceTreeTextIWSAllocator.hpp
xalanc::size_type
size_t size_type
Definition: XalanMap.hpp:46
xalanc::XalanDocument
Definition: XalanDocument.hpp:36
XalanSourceTreeElementANSAllocator.hpp
xalanc::operator==
bool operator==(const XalanVector< Type > &theLHS, const XalanVector< Type > &theRHS)
Definition: XalanVector.hpp:1118
xalanc::XalanSourceTreeDocument::UnparsedEntityURIMapType
XalanMap< XalanDOMString, XalanDOMString > UnparsedEntityURIMapType
Definition: XalanSourceTreeDocument.hpp:90
xalanc::XalanSourceTreeDocument::setPoolAllTextNodes
static void setPoolAllTextNodes(bool fPool)
Definition: XalanSourceTreeDocument.hpp:256
STLHelper.hpp
xalanc::XalanArrayAllocator< XalanSourceTreeAttr * >
xalanc::XalanNode::IndexType
unsigned long IndexType
Definition: XalanNode.hpp:64
XalanArrayAllocator.hpp
xalanc::XalanDOMStringPool::bucket_count_type
size_t bucket_count_type
Definition: XalanDOMStringPool.hpp:50
xalanc::XalanSourceTreeComment
Definition: XalanSourceTreeComment.hpp:47
XalanSourceTreeElementNAAllocator.hpp
xalanc::length
XalanDOMString::size_type length(const XalanDOMString &theString)
Get the length of a XalanDOMString.
Definition: DOMStringHelper.hpp:235
xalanc::XalanNodeList
Definition: XalanNodeList.hpp:36
xalanc::XalanSourceTreeDocument::allocator_size_type
XalanSourceTreeAttributeAllocator::size_type allocator_size_type
Definition: XalanSourceTreeDocument.hpp:122
XalanSourceTreeElementAAllocator.hpp
XalanSourceTreeDefinitions.hpp
xalanc::XalanSourceTreeDocument::getPoolAllTextNodes
static bool getPoolAllTextNodes()
Definition: XalanSourceTreeDocument.hpp:250
xalanc::XalanSourceTreeDocument::bucket_count_type
XalanDOMStringPool::bucket_count_type bucket_count_type
Definition: XalanSourceTreeDocument.hpp:124
XalanDOMStringAllocator.hpp
XalanDocument.hpp
xalanc::PrefixResolver
This class defines an interface for classes that resolve namespace prefixes to their URIs.
Definition: PrefixResolver.hpp:39
XalanDOMStringPool.hpp
xalanc::XalanMap
Xalan implementation of a hashtable.
Definition: XalanMap.hpp:186
XalanSourceTreeProcessingInstructionAllocator.hpp
XalanMap.hpp
xalanc::XalanSourceTreeAttributeAllocator::size_type
ArenaAllocatorType::size_type size_type
Definition: XalanSourceTreeAttributeAllocator.hpp:57
xalanc::XalanElement
Definition: XalanElement.hpp:44
xalanc::XalanNamedNodeMap
Definition: XalanNamedNodeMap.hpp:36
xalanc::XalanSourceTreeDocument::bucket_size_type
XalanDOMStringPool::bucket_size_type bucket_size_type
Definition: XalanSourceTreeDocument.hpp:125
xalanc::XalanSourceTreeText
Definition: XalanSourceTreeText.hpp:46
xalanc::XalanDOMString::size_type
XalanSize_t size_type
Definition: XalanDOMString.hpp:57
XALAN_XALANSOURCETREE_EXPORT
#define XALAN_XALANSOURCETREE_EXPORT
Definition: XalanSourceTreeDefinitions.hpp:35
xalanc::XalanSourceTreeElement
Definition: XalanSourceTreeElement.hpp:46
XalanSourceTreeAttributeNSAllocator.hpp
XalanSourceTreeElementNANSAllocator.hpp
xalanc::XalanDOMString
Definition: XalanDOMString.hpp:45
xalanc::XalanDOMStringPool::bucket_size_type
XalanDOMStringHashTable::bucket_size_type bucket_size_type
Definition: XalanDOMStringPool.hpp:51
xalanc::XalanSourceTreeDocument
Definition: XalanSourceTreeDocument.hpp:78
xalanc::XalanDOMStringPool::block_size_type
AllocatorType::size_type block_size_type
Definition: XalanDOMStringPool.hpp:49
XalanSourceTreeCommentAllocator.hpp
xalanc::AttributesType
xercesc::Attributes AttributesType
Definition: AttributesImpl.hpp:40
xalanc::XalanSourceTreeProcessingInstruction
Definition: XalanSourceTreeProcessingInstruction.hpp:47