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
56namespace XERCES_CPP_NAMESPACE
57{
58 class Attributes;
59 class AttributeList;
60}
61
62
63
64namespace XALAN_CPP_NAMESPACE {
65
66
67
68typedef xercesc::Attributes AttributesType;
69typedef xercesc::AttributeList AttributeListType;
70
71
72
73class PrefixResolver;
74class XalanSourceTreeAttr;
75
76
77
79{
80public:
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,
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&
197
198 virtual NodeType
199 getNodeType() const;
200
201 virtual XalanNode*
203
204 virtual const XalanNodeList*
206
207 virtual XalanNode*
209
210 virtual XalanNode*
212
213 virtual XalanNode*
215
216 virtual XalanNode*
218
219 virtual const XalanNamedNodeMap*
221
222 virtual XalanDocument*
224
225 virtual const XalanDOMString&
227
228 virtual const XalanDOMString&
229 getPrefix() const;
230
231 virtual const XalanDOMString&
233
234 virtual bool
235 isIndexed() const;
236
237 virtual IndexType
238 getIndex() const;
239
240 virtual XalanElement*
242
243 virtual XalanElement*
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,
269 bool fAddXMLNamespaceAttribute = false);
270
273 const XalanDOMChar* uri,
274 const XalanDOMChar* localname,
275 const XalanDOMChar* qname,
276 const AttributesType& attrs,
280 bool fAddXMLNamespaceAttribute = false);
281
284 const XalanDOMChar* tagName,
290 bool fAddXMLNamespaceAttribute = false);
291
294 const XalanDOMChar* name,
295 const AttributesType& attrs,
299 bool fAddXMLNamespaceAttribute = false);
300
303 const XalanDOMChar* data,
308
311 const XalanDOMChar* target,
312 const XalanDOMChar* data,
316
319 const XalanDOMChar* chars,
324
327 const XalanDOMChar* chars,
332
333 void
335 const XalanDOMChar* name,
336 const XalanDOMChar* publicId,
337 const XalanDOMChar* systemId,
339
340 const XalanDOMString&
342
343 // Child node setters...
344 void
346
347 void
349
350 void
352
353private:
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,
368
370 createAttribute(
371 const XalanDOMChar* theName,
372 const XalanDOMChar* theValue,
374
375 size_t
376 createAttributes(
379 size_t theStartIndex,
383
385 createElementNode(
393
394 size_t
395 createAttributes(
398 size_t theStartIndex,
400 bool fCreateNamespaces);
401
402 void
403 createAttributes(
408
409 const XalanDOMString&
410 getTextNodeString(
411 const XalanDOMChar* chars,
413
414 const XalanDOMString*
415 getNamespaceForPrefix(
416 const XalanDOMChar* theName,
419 bool fUseDefault,
420 const XalanDOMChar** theLocalName = 0);
421
422 // Not implemented...
424
426 operator=(const XalanSourceTreeDocument& theRHS);
427
428 bool
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.
AllocatorType::size_type block_size_type
Xalan implementation of a hashtable.
Definition XalanMap.hpp:187
virtual XalanNode * getFirstChild() const
Gets the first child of this node.
XalanSourceTreeText * createTextIWSNode(const XalanDOMChar *chars, XalanDOMString::size_type length, XalanNode *theParentNode=0, XalanNode *thePreviousSibling=0, XalanNode *theNextSibling=0)
virtual const XalanDOMString & getNodeValue() const
Gets the value of this node, depending on its type.
XalanSourceTreeText * createTextNode(const XalanDOMChar *chars, XalanDOMString::size_type length, XalanNode *theParentNode=0, XalanNode *thePreviousSibling=0, XalanNode *theNextSibling=0)
XalanArrayAllocator< XalanSourceTreeAttr * > AttributesArrayAllocatorType
virtual const XalanDOMString & getPrefix() const
Get the namespace prefix of this node, or null if it is unspecified.
void unparsedEntityDeclaration(const XalanDOMChar *name, const XalanDOMChar *publicId, const XalanDOMChar *systemId, const XalanDOMChar *notationName)
virtual XalanNode * getPreviousSibling() const
Gets the node immediately preceding this node.
XalanDOMStringPool::block_size_type block_size_type
virtual IndexType getIndex() const
Get the node's index.
virtual XalanDocument * getOwnerDocument() const
Gets the Document object associated with this node.
virtual XalanNode * getNextSibling() const
Gets the node immediately following this node.
void appendChildNode(XalanSourceTreeElement *theChild)
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.
XalanSourceTreeElement * createElementNode(const XalanDOMChar *tagName, const AttributeListType &attrs, const PrefixResolver &thePrefixResolver, XalanNode *theParentNode=0, XalanNode *thePreviousSibling=0, XalanNode *theNextSibling=0, bool fAddXMLNamespaceAttribute=false)
XalanSourceTreeComment * createCommentNode(const XalanDOMChar *data, XalanDOMString::size_type length, XalanNode *theParentNode=0, XalanNode *thePreviousSibling=0, XalanNode *theNextSibling=0)
XalanSourceTreeProcessingInstruction * createProcessingInstructionNode(const XalanDOMChar *target, const XalanDOMChar *data, XalanNode *theParentNode=0, XalanNode *thePreviousSibling=0, XalanNode *theNextSibling=0)
virtual const XalanDOMString & getNodeName() const
Gets the name of this node, depending on its type.
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.
virtual XalanElement * getElementById(const XalanDOMString &elementId) const
Returns the Element whose ID is given by elementId.
XalanDOMStringPool::bucket_count_type bucket_count_type
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)
XalanMap< XalanDOMString, XalanDOMString > UnparsedEntityURIMapType
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 bool isIndexed() const
Determine if the document is node-order indexed.
static void initialize(MemoryManager &theManager)
Perform static initialization.
void appendChildNode(XalanSourceTreeProcessingInstruction *theChild)
virtual const XalanNamedNodeMap * getAttributes() const
Gets a NamedNodeMap containing the attributes of this node (if it is an Element) or null otherwise.
const XalanDOMString & getUnparsedEntityURI(const XalanDOMString &theName) const
virtual XalanNode * getLastChild() const
Gets the last child of 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 XalanNodeList * getChildNodes() const
Gets a NodeList that contains all children of this node.
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)
XalanSourceTreeElement * createElementNode(const XalanDOMChar *name, const AttributesType &attrs, XalanNode *theParentNode=0, XalanNode *thePreviousSibling=0, XalanNode *theNextSibling=0, bool fAddXMLNamespaceAttribute=false)
XalanSourceTreeElement * createElementNode(const XalanDOMChar *name, const AttributeListType &attrs, XalanNode *theParentNode=0, XalanNode *thePreviousSibling=0, XalanNode *theNextSibling=0, bool fAddXMLNamespaceAttribute=false)
XalanMap< const XalanDOMChar *, XalanSourceTreeElement * > ElementByIDMapType
virtual XalanElement * getDocumentElement() const
Return a reference to the root element of the document.
virtual XalanNode * getParentNode() const
Gets the parent of this node.
XalanDOMStringPool::bucket_size_type bucket_size_type
virtual const XalanDOMString & getLocalName() const
Returns the local part of the qualified name of this node.
xercesc::Attributes AttributesType
xercesc::AttributeList AttributeListType
bool operator==(const XalanVector< Type > &theLHS, const XalanVector< Type > &theRHS)