rapidxml
|
Inherited by xml_document< Ch >.
This class is used by the parser to create new nodes and attributes, without overheads of dynamic memory allocation. In most cases, you will not need to use this class directly. However, if you need to create nodes manually or modify names/values of nodes, you are encouraged to use memory_pool of relevant xml_document to allocate the memory. Not only is this faster than allocating them by using new
operator, but also their lifetime will be tied to the lifetime of document, possibly simplyfing memory management.
Call allocate_node() or allocate_attribute() functions to obtain new nodes or attributes from the pool. You can also call allocate_string() function to allocate strings. Such strings can then be used as names or values of nodes without worrying about their lifetime. Note that there is no free()
function -- all allocations are freed at once when clear() function is called, or when the pool is destroyed.
It is also possible to create a standalone memory_pool, and use it to allocate nodes, whose lifetime will not be tied to any document.
Pool maintains RAPIDXML_STATIC_POOL_SIZE
bytes of statically allocated memory. Until static memory is exhausted, no dynamic memory allocations are done. When static memory is exhausted, pool allocates additional blocks of memory of size RAPIDXML_DYNAMIC_POOL_SIZE
each, by using global new[]
and delete[]
operators. This behaviour can be changed by setting custom allocation routines. Use set_allocator() function to set them.
Allocations for nodes, attributes and strings are aligned at RAPIDXML_ALIGNMENT
bytes. This value defaults to the size of pointer on target architecture.
To obtain absolutely top performance from the parser, it is important that all nodes are allocated from a single, contiguous block of memory. Otherwise, cache misses when jumping between two (or more) disjoint blocks of memory can slow down parsing quite considerably. If required, you can tweak RAPIDXML_STATIC_POOL_SIZE
, RAPIDXML_DYNAMIC_POOL_SIZE
and RAPIDXML_ALIGNMENT
to obtain best wasted memory to performance compromise. To do it, define their values before rapidxml.hpp file is included.
Ch | Character type of created nodes. |