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
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 
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*
215 
216  virtual XalanNode*
217  getNextSibling() const;
218 
219  virtual const XalanNamedNodeMap*
220  getAttributes() const;
221 
222  virtual XalanDocument*
224 
225  virtual const XalanDOMString&
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*
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 
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 
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 
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 
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 
303  const XalanDOMChar* data,
305  XalanNode* theParentNode = 0,
306  XalanNode* thePreviousSibling = 0,
307  XalanNode* theNextSibling = 0);
308 
311  const XalanDOMChar* target,
312  const XalanDOMChar* data,
313  XalanNode* theParentNode = 0,
314  XalanNode* thePreviousSibling = 0,
315  XalanNode* theNextSibling = 0);
316 
319  const XalanDOMChar* chars,
321  XalanNode* theParentNode = 0,
322  XalanNode* thePreviousSibling = 0,
323  XalanNode* theNextSibling = 0);
324 
327  const XalanDOMChar* chars,
329  XalanNode* theParentNode = 0,
330  XalanNode* thePreviousSibling = 0,
331  XalanNode* theNextSibling = 0);
332 
333  void
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
346 
347  void
349 
350  void
352 
353 private:
354 
355  MemoryManager&
356  getMemoryManager()
357  {
358  return m_stringBuffer.getMemoryManager();
359  }
360 
361  // Helper functions...
363  createAttribute(
364  const XalanDOMChar* theName,
365  const XalanDOMChar* theValue,
366  XalanSourceTreeElement* theOwnerElement,
367  const PrefixResolver& thePrefixResolver);
368 
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 
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...
424 
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 
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)
#define XALAN_XALANSOURCETREE_EXPORT
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
This class defines an interface for classes that resolve namespace prefixes to their URIs.
XalanDOMStringHashTable::bucket_size_type bucket_size_type
AllocatorType::size_type block_size_type
Xalan implementation of a hashtable.
Definition: XalanMap.hpp:187
unsigned long IndexType
Definition: XalanNode.hpp:64
XalanSourceTreeElement * createElementNode(const XalanDOMChar *uri, const XalanDOMChar *localname, const XalanDOMChar *qname, const AttributesType &attrs, XalanNode *theParentNode=0, XalanNode *thePreviousSibling=0, XalanNode *theNextSibling=0, bool fAddXMLNamespaceAttribute=false)
virtual XalanElement * getElementById(const XalanDOMString &elementId) const
Returns the Element whose ID is given by elementId.
virtual const XalanDOMString & getNodeValue() const
Gets the value of this node, depending on its type.
virtual const XalanDOMString & getNodeName() const
Gets the name of this node, depending on its type.
static XalanSourceTreeDocument * create(MemoryManager &theManager, bool fPoolAllText=s_poolAllTextNodes, block_size_type theNamesStringPoolBlockSize=eDefaultNamesStringPoolBlockSize, bucket_count_type theNamesStringPoolBucketCount=eDefaultNamesStringPoolBucketCount, bucket_size_type theNamesStringPoolBucketSize=eDefaultNamesStringPoolBucketSize, block_size_type theValuesStringPoolBlockSize=eDefaultValuesStringPoolBlockSize, bucket_count_type theValuesStringPoolBucketCount=eDefaultValuesStringPoolBucketCount, bucket_size_type theValuesStringPoolBucketSize=eDefaultValuesStringPoolBucketSize)
virtual XalanElement * getDocumentElement() const
Return a reference to the root element of the document.
virtual XalanNode * getParentNode() const
Gets the parent of this node.
XalanArrayAllocator< XalanSourceTreeAttr * > AttributesArrayAllocatorType
virtual XalanDocument * getOwnerDocument() const
Gets the Document object associated with this node.
virtual const XalanNamedNodeMap * getAttributes() const
Gets a NamedNodeMap containing the attributes of this node (if it is an Element) or null otherwise.
void unparsedEntityDeclaration(const XalanDOMChar *name, const XalanDOMChar *publicId, const XalanDOMChar *systemId, const XalanDOMChar *notationName)
virtual const XalanNodeList * getChildNodes() const
Gets a NodeList that contains all children of this node.
virtual XalanNode * getFirstChild() const
Gets the first child of this node.
XalanSourceTreeComment * createCommentNode(const XalanDOMChar *data, XalanDOMString::size_type length, XalanNode *theParentNode=0, XalanNode *thePreviousSibling=0, XalanNode *theNextSibling=0)
XalanDOMStringPool::block_size_type block_size_type
XalanSourceTreeElement * createElementNode(const XalanDOMChar *tagName, const AttributeListType &attrs, const PrefixResolver &thePrefixResolver, XalanNode *theParentNode=0, XalanNode *thePreviousSibling=0, XalanNode *theNextSibling=0, bool fAddXMLNamespaceAttribute=false)
virtual IndexType getIndex() const
Get the node's index.
XalanSourceTreeElement * createElementNode(const XalanDOMChar *name, const AttributeListType &attrs, XalanNode *theParentNode=0, XalanNode *thePreviousSibling=0, XalanNode *theNextSibling=0, bool fAddXMLNamespaceAttribute=false)
void appendChildNode(XalanSourceTreeElement *theChild)
virtual const XalanDOMString & getLocalName() const
Returns the local part of the qualified name of this node.
XalanSourceTreeDocument(MemoryManager &theManager, bool fPoolAllText=s_poolAllTextNodes, block_size_type theNamesStringPoolBlockSize=eDefaultNamesStringPoolBlockSize, bucket_count_type theNamesStringPoolBucketCount=eDefaultNamesStringPoolBucketCount, bucket_size_type theNamesStringPoolBucketSize=eDefaultNamesStringPoolBucketSize, block_size_type theValuesStringPoolBlockSize=eDefaultValuesStringPoolBlockSize, bucket_count_type theValuesStringPoolBucketCount=eDefaultValuesStringPoolBucketCount, bucket_size_type theValuesStringPoolBucketSize=eDefaultValuesStringPoolBucketSize)
Constructor for XalanSourceTreeDocument.
virtual XalanNode * getPreviousSibling() const
Gets the node immediately preceding this node.
XalanSourceTreeText * createTextIWSNode(const XalanDOMChar *chars, XalanDOMString::size_type length, XalanNode *theParentNode=0, XalanNode *thePreviousSibling=0, XalanNode *theNextSibling=0)
XalanSourceTreeDocument(MemoryManager &theManager, allocator_size_type theAttributeBlockSize, allocator_size_type theAttributeNSBlockSize, allocator_size_type theCommentBlockSize, allocator_size_type theElementBlockSize, allocator_size_type theElementNSBlockSize, allocator_size_type thePIBlockSize, allocator_size_type theTextBlockSize, allocator_size_type theTextIWSBlockSize, bool fPoolAllText=s_poolAllTextNodes)
Constructor for XalanSourceTreeDocument.
XalanDOMStringPool::bucket_count_type bucket_count_type
XalanSourceTreeText * createTextNode(const XalanDOMChar *chars, XalanDOMString::size_type length, XalanNode *theParentNode=0, XalanNode *thePreviousSibling=0, XalanNode *theNextSibling=0)
XalanMap< XalanDOMString, XalanDOMString > UnparsedEntityURIMapType
virtual bool isIndexed() const
Determine if the document is node-order indexed.
XalanSourceTreeElement * createElementNode(const XalanDOMChar *name, const AttributesType &attrs, XalanNode *theParentNode=0, XalanNode *thePreviousSibling=0, XalanNode *theNextSibling=0, bool fAddXMLNamespaceAttribute=false)
static void initialize(MemoryManager &theManager)
Perform static initialization.
virtual const XalanDOMString & getPrefix() const
Get the namespace prefix of this node, or null if it is unspecified.
void appendChildNode(XalanSourceTreeProcessingInstruction *theChild)
virtual XalanNode * getNextSibling() const
Gets the node immediately following this node.
static void terminate()
Perform static shut down.
virtual NodeType getNodeType() const
An enum value representing the type of the underlying object.
virtual const XalanDOMString & getNamespaceURI() const
Get the namespace URI of this node, or null if it is unspecified.
XalanSourceTreeAttributeAllocator::size_type allocator_size_type
void appendChildNode(XalanSourceTreeComment *theChild)
XalanSourceTreeProcessingInstruction * createProcessingInstructionNode(const XalanDOMChar *target, const XalanDOMChar *data, XalanNode *theParentNode=0, XalanNode *thePreviousSibling=0, XalanNode *theNextSibling=0)
const XalanDOMString & getUnparsedEntityURI(const XalanDOMString &theName) const
XalanMap< const XalanDOMChar *, XalanSourceTreeElement * > ElementByIDMapType
virtual XalanNode * getLastChild() const
Gets the last child of this node.
XalanDOMStringPool::bucket_size_type bucket_size_type
XalanDOMString::size_type length(const XalanDOMString &theString)
Get the length of a XalanDOMString.
xercesc::Attributes AttributesType
xercesc::AttributeList AttributeListType
bool operator==(const XalanVector< Type > &theLHS, const XalanVector< Type > &theRHS)