YAGE  v0.1.1
Yet Another Game Engine
rapidxml.h File Reference
#include <cstdlib>
#include <cassert>
#include <new>
#include <exception>

Go to the source code of this file.

Classes

class  rapidxml::parse_error
 Parse error exception. This exception is thrown by the parser when an error occurs. Use what() function to get human-readable error message. Use where() function to get a pointer to position within source text where error was detected.

If throwing exceptions by the parser is undesirable, it can be disabled by defining RAPIDXML_NO_EXCEPTIONS macro before rapidxml.hpp is included. This will cause the parser to call rapidxml::parse_error_handler() function instead of throwing an exception. This function must be defined by the user.

This class derives from std::exception class. More...
 
class  rapidxml::xml_node< Ch >
 Class representing a node of XML document. Each node may have associated name and value strings, which are available through name() and value() functions. Interpretation of name and value depends on type of the node. Type of node can be determined by using type() function.

Note that after parse, both name and value of node, if any, will point interior of source text used for parsing. Thus, this text must persist in the memory for the lifetime of node. More...
 
class  rapidxml::xml_attribute< Ch >
 Class representing attribute node of XML document. Each attribute has name and value strings, which are available through name() and value() functions (inherited from xml_base). Note that after parse, both name and value of attribute will point to interior of source text used for parsing. Thus, this text must persist in memory for the lifetime of attribute. More...
 
class  rapidxml::xml_document< Ch >
 This class represents root of the DOM hierarchy. It is also an xml_node and a memory_pool through public inheritance. Use parse() function to build a DOM tree from a zero-terminated XML text string. parse() function allocates memory for nodes and attributes by using functions of xml_document, which are inherited from memory_pool. To access root node of the document, use the document itself, as if it was an xml_node. More...
 
class  rapidxml::memory_pool< 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. More...
 
struct  rapidxml::memory_pool< Ch >::header
 
class  rapidxml::xml_base< Ch >
 Base class for xml_node and xml_attribute implementing common functions: name(), name_size(), value(), value_size() and parent(). More...
 
class  rapidxml::xml_attribute< Ch >
 Class representing attribute node of XML document. Each attribute has name and value strings, which are available through name() and value() functions (inherited from xml_base). Note that after parse, both name and value of attribute will point to interior of source text used for parsing. Thus, this text must persist in memory for the lifetime of attribute. More...
 
class  rapidxml::xml_node< Ch >
 Class representing a node of XML document. Each node may have associated name and value strings, which are available through name() and value() functions. Interpretation of name and value depends on type of the node. Type of node can be determined by using type() function.

Note that after parse, both name and value of node, if any, will point interior of source text used for parsing. Thus, this text must persist in the memory for the lifetime of node. More...
 
class  rapidxml::xml_document< Ch >
 This class represents root of the DOM hierarchy. It is also an xml_node and a memory_pool through public inheritance. Use parse() function to build a DOM tree from a zero-terminated XML text string. parse() function allocates memory for nodes and attributes by using functions of xml_document, which are inherited from memory_pool. To access root node of the document, use the document itself, as if it was an xml_node. More...
 
struct  rapidxml::xml_document< Ch >::whitespace_pred
 
struct  rapidxml::xml_document< Ch >::node_name_pred
 
struct  rapidxml::xml_document< Ch >::attribute_name_pred
 
struct  rapidxml::xml_document< Ch >::text_pred
 
struct  rapidxml::xml_document< Ch >::text_pure_no_ws_pred
 
struct  rapidxml::xml_document< Ch >::text_pure_with_ws_pred
 
struct  rapidxml::xml_document< Ch >::attribute_value_pred< Quote >
 
struct  rapidxml::xml_document< Ch >::attribute_value_pure_pred< Quote >
 

Namespaces

 rapidxml
 

Macros

#define RAPIDXML_PARSE_ERROR(what, where)   throw parse_error(what, where)
 
#define RAPIDXML_STATIC_POOL_SIZE   (64 * 1024)
 
#define RAPIDXML_DYNAMIC_POOL_SIZE   (64 * 1024)
 
#define RAPIDXML_ALIGNMENT   sizeof(void *)
 

Enumerations

enum  rapidxml::node_type {
  rapidxml::node_document, rapidxml::node_element, rapidxml::node_data, rapidxml::node_cdata,
  rapidxml::node_comment, rapidxml::node_declaration, rapidxml::node_doctype, rapidxml::node_pi
}
 Enumeration listing all node types produced by the parser. Use xml_node::type() function to query node type. More...
 

Variables

const int rapidxml::parse_no_data_nodes = 0x1
 Parse flag instructing the parser to not create data nodes. Text of first data node will still be placed in value of parent element, unless rapidxml::parse_no_element_values flag is also specified. Can be combined with other flags by use of | operator.

See xml_document::parse() function. More...
 
const int rapidxml::parse_no_element_values = 0x2
 Parse flag instructing the parser to not use text of first data node as a value of parent element. Can be combined with other flags by use of | operator. Note that child data nodes of element node take precendence over its value when printing. That is, if element has one or more child data nodes and a value, the value will be ignored. Use rapidxml::parse_no_data_nodes flag to prevent creation of data nodes if you want to manipulate data using values of elements.

See xml_document::parse() function. More...
 
const int rapidxml::parse_no_string_terminators = 0x4
 Parse flag instructing the parser to not place zero terminators after strings in the source text. By default zero terminators are placed, modifying source text. Can be combined with other flags by use of | operator.

See xml_document::parse() function. More...
 
const int rapidxml::parse_no_entity_translation = 0x8
 Parse flag instructing the parser to not translate entities in the source text. By default entities are translated, modifying source text. Can be combined with other flags by use of | operator.

See xml_document::parse() function. More...
 
const int rapidxml::parse_no_utf8 = 0x10
 Parse flag instructing the parser to disable UTF-8 handling and assume plain 8 bit characters. By default, UTF-8 handling is enabled. Can be combined with other flags by use of | operator.

See xml_document::parse() function. More...
 
const int rapidxml::parse_declaration_node = 0x20
 Parse flag instructing the parser to create XML declaration node. By default, declaration node is not created. Can be combined with other flags by use of | operator.

See xml_document::parse() function. More...
 
const int rapidxml::parse_comment_nodes = 0x40
 Parse flag instructing the parser to create comments nodes. By default, comment nodes are not created. Can be combined with other flags by use of | operator.

See xml_document::parse() function. More...
 
const int rapidxml::parse_doctype_node = 0x80
 Parse flag instructing the parser to create DOCTYPE node. By default, doctype node is not created. Although W3C specification allows at most one DOCTYPE node, RapidXml will silently accept documents with more than one. Can be combined with other flags by use of | operator.

See xml_document::parse() function. More...
 
const int rapidxml::parse_pi_nodes = 0x100
 Parse flag instructing the parser to create PI nodes. By default, PI nodes are not created. Can be combined with other flags by use of | operator.

See xml_document::parse() function. More...
 
const int rapidxml::parse_validate_closing_tags = 0x200
 Parse flag instructing the parser to validate closing tag names. If not set, name inside closing tag is irrelevant to the parser. By default, closing tags are not validated. Can be combined with other flags by use of | operator.

See xml_document::parse() function. More...
 
const int rapidxml::parse_trim_whitespace = 0x400
 Parse flag instructing the parser to trim all leading and trailing whitespace of data nodes. By default, whitespace is not trimmed. This flag does not cause the parser to modify source text. Can be combined with other flags by use of | operator.

See xml_document::parse() function. More...
 
const int rapidxml::parse_normalize_whitespace = 0x800
 Parse flag instructing the parser to condense all whitespace runs of data nodes to a single space character. Trimming of leading and trailing whitespace of data is controlled by rapidxml::parse_trim_whitespace flag. By default, whitespace is not normalized. If this flag is specified, source text will be modified. Can be combined with other flags by use of | operator.

See xml_document::parse() function. More...
 
const int rapidxml::parse_default = 0
 Parse flags which represent default behaviour of the parser. This is always equal to 0, so that all other flags can be simply ored together. Normally there is no need to inconveniently disable flags by anding with their negated (~) values. This also means that meaning of each flag is a negation of the default setting. For example, if flag name is rapidxml::parse_no_utf8, it means that utf-8 is enabled by default, and using the flag will disable it.

See xml_document::parse() function. More...
 
const int rapidxml::parse_non_destructive = parse_no_string_terminators | parse_no_entity_translation
 A combination of parse flags that forbids any modifications of the source text. This also results in faster parsing. However, note that the following will occur: More...
 
const int rapidxml::parse_fastest = parse_non_destructive | parse_no_data_nodes
 A combination of parse flags resulting in fastest possible parsing, without sacrificing important data.

See xml_document::parse() function. More...
 
const int rapidxml::parse_full = parse_declaration_node | parse_comment_nodes | parse_doctype_node | parse_pi_nodes | parse_validate_closing_tags
 A combination of parse flags resulting in largest amount of data being extracted. This usually results in slowest parsing.

See xml_document::parse() function. More...
 

Macro Definition Documentation

◆ RAPIDXML_ALIGNMENT

#define RAPIDXML_ALIGNMENT   sizeof(void *)

◆ RAPIDXML_DYNAMIC_POOL_SIZE

#define RAPIDXML_DYNAMIC_POOL_SIZE   (64 * 1024)

◆ RAPIDXML_PARSE_ERROR

#define RAPIDXML_PARSE_ERROR (   what,
  where 
)    throw parse_error(what, where)

◆ RAPIDXML_STATIC_POOL_SIZE

#define RAPIDXML_STATIC_POOL_SIZE   (64 * 1024)