### Get First Attribute Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Retrieves the first attribute of the current node. Optionally filters by name and case sensitivity. ```cpp xml_attribute* first_attribute(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const; ``` -------------------------------- ### Getting Parse Error Description Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Retrieves a human-readable, null-terminated string describing the parse error. ```cpp virtual const char* what() const; ``` -------------------------------- ### Get Next Attribute by Name in RapidXml Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Retrieves the next attribute, optionally matching a specific attribute name. The name comparison can be case-sensitive or case-insensitive (ASCII only). ```C++ xml_attribute* next_attribute(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const; ``` -------------------------------- ### Get Next Sibling Node Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Retrieves the next sibling of the current node. Optionally filters by name and case sensitivity. ```cpp xml_node* next_sibling(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const; ``` -------------------------------- ### Get Last Attribute Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Retrieves the last attribute of the current node. Optionally filters by name and case sensitivity. ```cpp xml_attribute* last_attribute(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const; ``` -------------------------------- ### xml_attribute::document Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Gets a pointer to the `xml_document` that contains this attribute. ```APIDOC ## function xml_attribute::document ### Description Gets document of which attribute is a child. ### Returns Pointer to document that contains this attribute, or 0 if there is no parent document. ``` -------------------------------- ### Get Node Name Size in RapidXml Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Gets the size of the node's name, excluding any terminator character. This function is reliable regardless of whether the name is zero-terminated. ```C++ std::size_t name_size() const; ``` -------------------------------- ### parse_error::what Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Gets a human-readable description of the parse error. ```APIDOC ## function parse_error::what ### Description Gets human readable description of error. ### Returns Pointer to null terminated description of the error. ``` -------------------------------- ### Get Node Value Size in RapidXml Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Gets the size of the node's value, excluding any terminator character. This function is reliable regardless of whether the value is zero-terminated. ```C++ std::size_t value_size() const; ``` -------------------------------- ### Get Node Value in RapidXml Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Retrieves the value of an XML node. The value may not be zero-terminated if the `parse_no_string_terminators` option was used during parsing. Use `value_size()` to get the length. ```C++ Ch* value() const; ``` -------------------------------- ### Get Node Name in RapidXml Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Retrieves the name of an XML node. The name may not be zero-terminated if the `parse_no_string_terminators` option was used during parsing. Use `name_size()` to get the length. ```C++ Ch* name() const; ``` -------------------------------- ### Get Parent Node Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Retrieves a pointer to the parent node of the current node. Returns a null pointer if the node has no parent (e.g., the root node). ```cpp xml_node* parent() const; ``` -------------------------------- ### xml_attribute::previous_attribute Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Gets the previous attribute, optionally matching a specific attribute name. The name comparison can be case-sensitive or case-insensitive (for ASCII characters only). ```APIDOC ## function xml_attribute::previous_attribute ### Description Gets previous attribute, optionally matching attribute name. ### Parameters * **name** (const Ch *) - Name of attribute to find, or 0 to return previous attribute regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero * **name_size** (std::size_t) - Size of name, in characters, or 0 to have size calculated automatically from string * **case_sensitive** (bool) - Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters ### Returns Pointer to found attribute, or 0 if not found. ``` -------------------------------- ### Getting Attribute's Parent Document Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Retrieves a pointer to the xml_document that owns this attribute. Returns 0 if the attribute is not part of a document. ```cpp xml_document* document() const; ``` -------------------------------- ### parse_error::where Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Gets a pointer to the character data within the source text where the parse error occurred. ```APIDOC ## function parse_error::where ### Description Gets pointer to character data where error happened. Ch should be the same as char type of `xml_document` that produced the error. ### Returns Pointer to location within the parsed string where error occured. ``` -------------------------------- ### Getting Parse Error Location Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Retrieves a pointer to the character in the source text where the parse error occurred. The character type Ch should match the type used by the xml_document. ```cpp Ch* where() const; ``` -------------------------------- ### xml_base::name_size() Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Gets the size of the node's name in characters, excluding any terminator character. This function accurately reports the name length regardless of whether the name string is zero-terminated. ```APIDOC ## xml_base::name_size ### Description Gets size of node name, not including terminator character. This function works correctly irrespective of whether name is or is not zero terminated. ### Synopsis `std::size_t name_size() const;` ### Returns Size of node name, in characters. ``` -------------------------------- ### xml_base::name() Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Retrieves the name of an XML node. The interpretation of the name depends on the node type. The returned name may not be zero-terminated if the `parse_no_string_terminators` option was used during parsing. Use `name_size()` to get the length of the name. ```APIDOC ## xml_base::name ### Description Gets name of the node. Interpretation of name depends on type of node. Note that name will not be zero-terminated if [rapidxml::parse_no_string_terminators](#namespacerapidxml_9cae3801e70437cbc410c24bf6be691c_19cae3801e70437cbc410c24bf6be691c) option was selected during parse. Use [name_size()](#classrapidxml_1_1xml__base_0dae694c8f7e4d89f1003e2f3a15a43c_10dae694c8f7e4d89f1003e2f3a15a43c) function to determine length of the name. ### Synopsis `Ch* name() const;` ### Returns Name of node, or empty string if node has no name. ``` -------------------------------- ### Initialize XML Document Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Constructs an empty XML document object. This object serves as the root of the DOM hierarchy and also provides memory management capabilities. ```cpp xml_document(); ``` -------------------------------- ### rapidxml::print (Output Stream) Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Prints an XML node or document to a specified output stream. Allows customization through flags. ```APIDOC ## rapidxml::print (Output Stream) ### Description Prints XML to the given output stream. You can pass `xml_document` to print the entire document. ### Synopsis `std::basic_ostream& rapidxml::print(std::basic_ostream< Ch > &out, const xml_node< Ch > &node, int flags=0);` ### Parameters * **out** (std::basic_ostream &) - Output stream to print to. * **node** (const xml_node< Ch > &) - Node to be printed. Pass `xml_document` to print the entire document. * **flags** (int) - Flags controlling how XML is printed. ### Returns Output stream. ``` -------------------------------- ### C++: Enable DOCTYPE Node Creation Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html This flag instructs the parser to create a DOCTYPE node. By default, the DOCTYPE node is not created. RapidXml accepts multiple DOCTYPE nodes, though the W3C specification allows only one. Can be combined with other flags. ```cpp const int parse_doctype_node = 0x80; ``` -------------------------------- ### xml_document::xml_document Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Constructs an empty XML document. This is the entry point for creating and managing an XML DOM hierarchy. ```APIDOC ## constructor xml_document::xml_document ### Description Constructs empty XML document. ``` -------------------------------- ### Printing XML to a String Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Shows how to serialize the XML DOM tree into a `std::string` using `print()` with a `std::back_inserter`. This is useful for obtaining the XML as a string variable. ```cpp std::string s; print(std::back_inserter(s), doc, 0); ``` -------------------------------- ### Printing XML to Standard Output Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Illustrates printing the XML DOM tree to a stream using either the overloaded `operator<<` or the `print()` function. The `print()` function allows specifying printing flags. ```cpp using namespace rapidxml; xml_document<> doc; // character type defaults to char // ... some code to fill the document // Print to stream using operator << std::cout << doc; // Print to stream using print function, specifying printing flags print(std::cout, doc, 0); // 0 means default printing flags ``` -------------------------------- ### Printing XML to a Memory Buffer Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Demonstrates printing the XML DOM tree into a pre-allocated character buffer. Ensure the buffer is large enough to hold the XML output. The `print()` function returns a pointer to the character after the last printed character, which can be used to null-terminate the buffer. ```cpp char buffer[4096]; // You are responsible for making the buffer large enough! char *end = print(buffer, doc, 0); // end contains pointer to character after last printed character *end = 0; // Add string terminator after XML ``` -------------------------------- ### Accessing DOM Tree Nodes and Attributes Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Demonstrates how to navigate and retrieve information from the parsed XML DOM tree using methods of xml_node and xml_attribute classes. Access node names, values, and attributes. ```cpp cout << "Name of my first node is: " << doc.first_node()->name() << "\n"; xml_node<> *node = doc.first_node("foobar"); cout << "Node foobar has value " << node->value() << "\n"; for (xml_attribute<> *attr = node->first_attribute(); attr; attr = attr->next_attribute()) { cout << "Node foobar has attribute " << attr->name() << " "; cout << "with value " << attr->value() << "\n"; } ``` -------------------------------- ### rapidxml::print (Output Iterator) Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Prints an XML node or document to a specified output iterator. Allows customization through flags. ```APIDOC ## rapidxml::print (Output Iterator) ### Description Prints XML to the given output iterator. You can pass `xml_document` to print the entire document. ### Synopsis `OutIt rapidxml::print(OutIt out, const xml_node< Ch > &node, int flags=0);` ### Parameters * **out** (OutIt) - Output iterator to print to. * **node** (const xml_node< Ch > &) - Node to be printed. Pass `xml_document` to print the entire document. * **flags** (int) - Flags controlling how XML is printed. ### Returns Output iterator pointing to the position immediately after the last character of the printed text. ``` -------------------------------- ### Parsing XML with RapidXml Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Parses a zero-terminated string into an XML DOM tree. Ensure RapidXml namespace is in scope or names are fully qualified. Parse flags can be specified as compile-time constants. ```cpp using namespace rapidxml; xml_document<> doc; // character type defaults to char doc.parse<0>(text); // 0 means default parse flags ``` -------------------------------- ### Print XML Node to Output Stream Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Prints an XML node to a standard output stream. This overload is convenient for printing to std::cout or std::ofstream. ```cpp std::basic_ostream& rapidxml::print(std::basic_ostream< Ch > &out, const xml_node< Ch > &node, int flags=0); ``` -------------------------------- ### xml_node Constructor Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Constructs an empty xml_node with a specified type. It is recommended to use the memory_pool of the document for node allocation. ```APIDOC ## xml_node::xml_node ### Description Constructs an empty node with the specified type. Consider using [memory_pool](#classrapidxml_1_1memory__pool) of appropriate document to allocate nodes manually. ### Parameters * **type** (node_type) - Type of node to construct. ``` -------------------------------- ### Prepend Child Node Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Inserts a new node at the beginning of the current node's children list. ```cpp void prepend_node(xml_node< Ch > *child); ``` -------------------------------- ### RapidXml Parse Flag: Fastest Parsing Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html This combination of flags results in the fastest possible parsing without sacrificing important data. It includes the non-destructive parsing behavior and disables data nodes. ```cpp const int parse_fastest = parse_non_destructive | parse_no_data_nodes; ``` -------------------------------- ### Prepend Attribute Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Inserts a new attribute at the beginning of the current node's attribute list. ```cpp void prepend_attribute(xml_attribute< Ch > *attribute); ``` -------------------------------- ### C++: Enable Declaration Node Creation Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html This flag instructs the parser to create an XML declaration node. By default, the declaration node is not created. Can be combined with other flags. ```cpp const int parse_declaration_node = 0x20; ``` -------------------------------- ### xml_base::value_size() Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Gets the size of the node's value in characters, excluding any terminator character. This function accurately reports the value length regardless of whether the value string is zero-terminated. ```APIDOC ## xml_base::value_size ### Description Gets size of node value, not including terminator character. This function works correctly irrespective of whether value is or is not zero terminated. ### Synopsis `std::size_t value_size() const;` ### Returns Size of node value, in characters. ``` -------------------------------- ### rapidxml::memory_pool Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Manages memory allocation for XML nodes and strings, providing methods to allocate and clone nodes, allocate strings, clear the pool, and set custom allocators. ```APIDOC ## Class: rapidxml::memory_pool ### Description Manages memory allocation for XML nodes and strings. It allows for efficient allocation and deallocation of memory required for parsing and manipulating XML structures. ### Methods - **memory_pool()**: Constructor for the memory pool. - **~memory_pool()**: Destructor for the memory pool. - **allocate_node(node_type type, const Ch *name=0, const Ch *value=0, std::size_t name_size=0, std::size_t value_size=0)**: Allocates a new XML node with the specified type, name, and value. - **allocate_attribute(const Ch *name=0, const Ch *value=0, std::size_t name_size=0, std::size_t value_size=0)**: Allocates a new XML attribute with the specified name and value. - **allocate_string(const Ch *source=0, std::size_t size=0)**: Allocates a string with the given content and size. - **clone_node(const xml_node< Ch > *source, xml_node< Ch > *result=0)**: Clones an existing XML node. - **clear()**: Clears the memory pool, freeing all allocated memory. - **set_allocator(alloc_func *af, free_func *ff)**: Sets custom memory allocation and deallocation functions. ``` -------------------------------- ### C++: Enable PI Node Creation Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Use this flag to instruct the parser to create PI (Processing Instruction) nodes. By default, PI nodes are not created. Can be combined with other flags. ```cpp const int parse_pi_nodes = 0x100; ``` -------------------------------- ### xml_base::value() Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Retrieves the value of an XML node. The interpretation of the value depends on the node type. Similar to `name()`, the value may not be zero-terminated if `parse_no_string_terminators` was used. Use `value_size()` to get the length of the value. ```APIDOC ## xml_base::value ### Description Gets value of node. Interpretation of value depends on type of node. Note that value will not be zero-terminated if [rapidxml::parse_no_string_terminators](#namespacerapidxml_9cae3801e70437cbc410c24bf6be691c_19cae3801e70437cbc410c24bf6be691c) option was selected during parse. Use [value_size()](#classrapidxml_1_1xml__base_aed5ae791b7164c1ee5e649198cbb3db_1aed5ae791b7164c1ee5e649198cbb3db) function to determine length of the value. ### Synopsis `Ch* value() const;` ### Returns Value of node, or empty string if node has no value. ``` -------------------------------- ### C++: Enable Comment Node Creation Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Use this flag to instruct the parser to create comment nodes. By default, comment nodes are not created. Can be combined with other flags. ```cpp const int parse_comment_nodes = 0x40; ``` -------------------------------- ### Setting Custom Memory Allocators Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Allows users to define custom memory allocation and deallocation functions for the memory pool. This function should only be called when no memory is currently allocated from the pool. The allocation function must not return an invalid pointer on failure. ```cpp void set_allocator(alloc_func *af, free_func *ff); ``` -------------------------------- ### Print XML Node to Output Iterator Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Prints an XML node to a specified output iterator. Use this for custom output destinations. ```cpp OutIt rapidxml::print(OutIt out, const xml_node< Ch > &node, int flags=0); ``` -------------------------------- ### XML Attribute Constructor Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Constructs an empty xml_attribute. For manual allocation, consider using the memory_pool associated with an xml_document. ```cpp xml_attribute(); ``` -------------------------------- ### rapidxml::operator<< Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Prints formatted XML to an output stream using default printing flags. This is a convenience operator that calls the `print()` function. ```APIDOC ## rapidxml::operator<< ### Description Prints formatted XML to the given output stream. Uses default printing flags. Use the [print()](#namespacerapidxml_b94d570fc4c4ab2423813cd0243326b1_1b94d570fc4c4ab2423813cd0243326b1) function to customize the printing process. ### Synopsis `std::basic_ostream& rapidxml::operator<<(std::basic_ostream< Ch > &out, const xml_node< Ch > &node);` ### Parameters * **out** (std::basic_ostream &) - Output stream to print to. * **node** (const xml_node< Ch > &) - Node to be printed. ### Returns Output stream. ``` -------------------------------- ### xml_node::prepend_node Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Prepends a new child node to the current node, making it the first child. ```APIDOC ## xml_node::prepend_node ### Description Prepends a new child node. The prepended child becomes the first child, and all existing children are moved one position back. ### Parameters - **child** (xml_node< Ch > *) - The node to prepend as a child. ``` -------------------------------- ### Node Navigation and Access Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Provides methods to access the document, first/last node, and previous/next siblings of an XML node. It also allows access to the first/last attribute of a node. ```APIDOC ## Node Navigation and Access ### Description Methods for navigating and accessing related nodes and attributes within an XML structure. ### Methods - `document() const` - Returns a reference to the document the node belongs to. - `first_node(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const` - Returns the first child node, optionally matching a name and case sensitivity. - `last_node(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const` - Returns the last child node, optionally matching a name and case sensitivity. - `previous_sibling(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const` - Returns the previous sibling node, optionally matching a name and case sensitivity. - `next_sibling(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const` - Returns the next sibling node, optionally matching a name and case sensitivity. - `first_attribute(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const` - Returns the first attribute, optionally matching a name and case sensitivity. - `last_attribute(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const` - Returns the last attribute, optionally matching a name and case sensitivity. ``` -------------------------------- ### Set Node Name with Size in RapidXml Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Sets the name of a node using a non-zero-terminated string and its size. The node does not own the string; manual memory management or using a `memory_pool` is required. ```C++ void name(const Ch *name, std::size_t size); ``` -------------------------------- ### Modifying DOM Tree: Allocating Node Name Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Demonstrates allocating a node name from the document's memory pool using `allocate_string()` to ensure proper lifetime management. This is crucial when assigning dynamically generated names or values to nodes. ```cpp xml_document<> doc; char *node_name = doc.allocate_string(name); // Allocate string and copy name into it xml_node<> *node = doc.allocate_node(node_element, node_name); // Set node name to node_name ``` -------------------------------- ### Parse Error Constructor Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Constructs a parse_error exception object with a description of the error and a pointer to its location in the source text. ```cpp parse_error(const char *what, void *where); ``` -------------------------------- ### Formatted XML Output Operator Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Overloads the << operator for std::basic_ostream to print formatted XML. Uses default printing flags. ```cpp std::basic_ostream& rapidxml::operator<<(std::basic_ostream< Ch > &out, const xml_node< Ch > &node); ``` -------------------------------- ### RapidXml Parse Flag: Default Behavior Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html This constant represents the default behavior of the parser, which is equivalent to 0. It allows other flags to be combined using the bitwise OR operator. The meaning of each flag is a negation of the default setting. ```cpp const int parse_default = 0; ``` -------------------------------- ### Finding Previous Attribute Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Navigates to the previous attribute node. Optionally searches for an attribute with a specific name, with control over case sensitivity. The name string does not need to be null-terminated if its size is provided. ```cpp xml_attribute* previous_attribute(const Ch *name = 0, std::size_t name_size = 0, bool case_sensitive = true) const; ``` -------------------------------- ### Modifying DOM Tree: Creating an HTML Link Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Shows how to modify the DOM tree by adding nodes and attributes. Nodes and attributes do not own their text, so allocate strings from the document's memory pool for proper lifetime management when assigning new names or values. ```cpp xml_document<> doc; xml_node<> *node = doc.allocate_node(node_element, "a", "Google"); doc.append_node(node); xml_attribute<> *attr = doc.allocate_attribute("href", "google.com"); node->append_attribute(attr); ``` -------------------------------- ### xml_node::prepend_attribute Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Prepends a new attribute to the current node. ```APIDOC ## xml_node::prepend_attribute ### Description Prepends a new attribute to the node. ### Parameters - **attribute** (xml_attribute< Ch > *) - The attribute to prepend. ``` -------------------------------- ### xml_base::name(const Ch *name, std::size_t size) Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Sets the name of an XML node to a non zero-terminated string. The user is responsible for managing the lifetime of the provided string. It is recommended to use the document's `memory_pool` for allocation to ensure automatic memory management. ```APIDOC ## xml_base::name ### Description Sets name of node to a non zero-terminated string. See [Ownership Of Strings](#namespacerapidxml_1ownership_of_strings) . Note that node does not own its name or value, it only stores a pointer to it. It will not delete or otherwise free the pointer on destruction. It is reponsibility of the user to properly manage lifetime of the string. The easiest way to achieve it is to use [memory_pool](#classrapidxml_1_1memory__pool) of the document to allocate the string - on destruction of the document the string will be automatically freed. Size of name must be specified separately, because name does not have to be zero terminated. Use [name(const Ch extit{ })](#classrapidxml_1_1xml__base_e099c291e104a0d277307fe71f5e0f9e_1e099c291e104a0d277307fe71f5e0f9e) function to have the length automatically calculated (string must be zero terminated). ### Synopsis `void name(const Ch *name, std::size_t size);` ### Parameters #### name Name of node to set. Does not have to be zero terminated. #### size Size of name, in characters. This does not include zero terminator, if one is present. ``` -------------------------------- ### xml_base::value (with size) Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Sets the value of an XML node to a non-zero-terminated string of a specified size. The node does not own the string, so the user must manage its lifetime. Using `memory_pool` is recommended for automatic memory management. ```APIDOC ## function xml_base::value ### Description Sets value of node to a non zero-terminated string. ### Parameters - **value** (const Ch *) - The string to set as the node's value. Does not have to be zero terminated. - **size** (std::size_t) - The size of the value string in characters. ``` -------------------------------- ### rapidxml::xml_document Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Represents an XML document, providing methods for parsing XML text, clearing the document, and accessing the root node. ```APIDOC ## Class: rapidxml::xml_document ### Description Represents an XML document. It provides functionality to parse XML text, manage the document's nodes, and access the root element. ### Methods - **xml_document()**: Constructor for the XML document. - **parse(Ch *text)**: Parses the given XML text. - **clear()**: Clears the document, freeing all associated memory. ``` -------------------------------- ### memory_pool::allocate_node Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Allocates a new XML node from the memory pool. It can optionally assign a name and value to the node. If memory allocation fails, it throws std::bad_alloc or calls a parse error handler if exceptions are disabled. ```APIDOC ## function memory_pool::allocate_node ### Description Allocates a new node from the pool, and optionally assigns name and value to it. If the allocation request cannot be accomodated, this function will throw `std::bad_alloc`. If exceptions are disabled by defining RAPIDXML_NO_EXCEPTIONS, this function will call [rapidxml::parse_error_handler()](#namespacerapidxml_ff5d67f74437199d316d2b2660653ae1_1ff5d67f74437199d316d2b2660653ae1) function. ### Synopsis `xml_node* allocate_node(node_type type, const Ch *name=0, const Ch *value=0, std::size_t name_size=0, std::size_t value_size=0);` ### Parameters - **type** (node_type) - Type of node to create. - **name** (const Ch *) - Name to assign to the node, or 0 to assign no name. - **value** (const Ch *) - Value to assign to the node, or 0 to assign no value. - **name_size** (std::size_t) - Size of name to assign, or 0 to automatically calculate size from name string. - **value_size** (std::size_t) - Size of value to assign, or 0 to automatically calculate size from value string. ### Returns Pointer to allocated node. This pointer will never be NULL. ``` -------------------------------- ### RapidXml Parse Flag: Full Parsing Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html This combination of flags extracts the largest amount of data, typically resulting in the slowest parsing. It includes flags for declaration nodes, comment nodes, doctype nodes, PI nodes, and validating closing tags. ```cpp const int parse_full = parse_declaration_node | parse_comment_nodes | parse_doctype_node | parse_pi_nodes | parse_validate_closing_tags; ``` -------------------------------- ### RapidXml Parse Flag: Normalize Whitespace Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Use this flag to instruct the parser to condense all whitespace runs of data nodes to a single space character. Trimming of leading and trailing whitespace is controlled by parse_trim_whitespace. Whitespace is not normalized by default. If this flag is specified, source text will be modified. Can be combined with other flags. ```cpp const int parse_normalize_whitespace = 0x800; ``` -------------------------------- ### RapidXml Parse Flag: Trim Whitespace Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Use this flag to instruct the parser to trim all leading and trailing whitespace of data nodes. Whitespace is not trimmed by default. This flag does not modify the source text. Can be combined with other flags. ```cpp const int parse_trim_whitespace = 0x400; ``` -------------------------------- ### RapidXml Parse Flag: Non-Destructive Parsing Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html This combination of flags forbids any modifications of the source text, resulting in faster parsing. Node names and values will not be zero-terminated, and entities will not be translated. Whitespace will not be normalized. ```cpp const int parse_non_destructive = parse_no_string_terminators | parse_no_entity_translation; ``` -------------------------------- ### Set Node Value (with size) Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Sets the value of an XML node to a string of a specified size. The string does not need to be zero-terminated. The node only stores a pointer; manage the string's lifetime externally, preferably using the document's memory pool. ```cpp void value(const Ch *value, std::size_t size); ``` -------------------------------- ### Parse XML String Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Parses a zero-terminated XML string into a DOM tree. The input string may be modified unless `parse_non_destructive` is used. The string must remain valid for the document's lifetime. Errors during parsing will throw a `rapidxml::parse_error` exception. ```cpp void parse(Ch *text); ``` -------------------------------- ### xml_node::type Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Sets the type of the current XML node. ```APIDOC ## xml_node::type ### Description Sets type of node. ### Parameters - **type** (node_type) - The type of node to set. ``` -------------------------------- ### xml_node::first_node Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Retrieves the first child node, optionally filtering by name and case sensitivity. ```APIDOC ## xml_node::first_node ### Description Gets first child node, optionally matching node name. ### Parameters * **name** (const Ch *) - Optional name of child to find. If 0, returns the first child regardless of its name. This string does not have to be zero-terminated if name_size is non-zero. * **name_size** (std::size_t) - Optional size of name in characters. If 0, size is calculated automatically. * **case_sensitive** (bool) - Optional. Should name comparison be case-sensitive. Non case-sensitive comparison works properly only for ASCII characters. Defaults to true. ### Returns * **xml_node* - Pointer to the found child, or 0 if not found. ``` -------------------------------- ### rapidxml::xml_base Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Base class for XML nodes and attributes, providing common functionalities like accessing name and value. ```APIDOC ## Class: rapidxml::xml_base ### Description Base class for `xml_node` and `xml_attribute`, providing common functionalities such as accessing the name and value of an XML element or attribute. ### Methods - **xml_base()**: Constructor for the XML base class. - **name() const**: Returns the name of the XML node or attribute. - **name_size() const**: Returns the size of the name. - **value() const**: Returns the value of the XML node or attribute. - **value_size() const**: Returns the size of the value. - **name(const Ch *name, std::size_t size)**: Sets the name of the node/attribute. - **name(const Ch *name)**: Sets the name of the node/attribute. - **value(const Ch *value, std::size_t size)**: Sets the value of the node/attribute. - **value(const Ch *value)**: Sets the value of the node/attribute. - **parent() const**: Returns a pointer to the parent node. ``` -------------------------------- ### C++: Disable UTF-8 Handling Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Use this flag to disable UTF-8 handling and assume plain 8-bit characters. By default, UTF-8 handling is enabled. Can be combined with other flags. ```cpp const int parse_no_utf8 = 0x10; ``` -------------------------------- ### Set Node Type Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Sets the type of the current node. ```cpp void type(node_type type); ``` -------------------------------- ### xml_document::parse Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Parses a zero-terminated XML string into a DOM tree. The input string may be modified unless `parse_non_destructive` flag is used. The string must remain valid for the lifetime of the document. Errors during parsing will throw a `rapidxml::parse_error` exception. ```APIDOC ## function xml_document::parse ### Description Parses zero-terminated XML string according to given flags. The passed string may be modified by the parser. ### Parameters - **text** (Ch *) - XML data to parse. Pointer is non-const to denote that data may be modified. ``` -------------------------------- ### xml_base::parent Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Retrieves a pointer to the parent node of the current node. Returns `nullptr` if the node has no parent (e.g., it's the root node). ```APIDOC ## function xml_base::parent ### Description Gets node parent. ### Returns - (xml_node*) - Pointer to parent node, or 0 if there is no parent. ``` -------------------------------- ### RapidXml Parse Error Exception Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html The parse_error exception is thrown when the RapidXml parser encounters an error. Users can retrieve an error message using what() and the error location using where(). Exception throwing can be disabled by defining RAPIDXML_NO_EXCEPTIONS. ```cpp class rapidxml::parse_error ``` -------------------------------- ### Set Node Name Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Sets the name of an XML node to a zero-terminated string. Ensure the string persists for the node's lifetime. ```cpp void name(const Ch *name); ``` -------------------------------- ### memory_pool::clone_node Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Clones an XML node, including its hierarchy of child nodes and attributes, using memory from this pool. The names and values of the cloned nodes are shared with the source. An optional result node can be provided to replace its contents. ```APIDOC ## function memory_pool::clone_node ### Description Clones an [xml_node](#classrapidxml_1_1xml__node) and its hierarchy of child nodes and attributes. Nodes and attributes are allocated from this memory pool. Names and values are not cloned, they are shared between the clone and the source. Result node can be optionally specified as a second parameter, in which case its contents will be replaced with cloned source node. This is useful when you want to clone entire document. ### Synopsis `xml_node* clone_node(const xml_node< Ch > *source, xml_node< Ch > *result=0);` ### Parameters - **source** (const xml_node< Ch > *) - Node to clone. - **result** (xml_node< Ch > *) - Node to put results in, or 0 to automatically allocate result node ### Returns Pointer to cloned node. This pointer will never be NULL. ``` -------------------------------- ### rapidxml::xml_node Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Represents a node in the XML tree, supporting various node types and providing methods for navigation and manipulation. ```APIDOC ## Class: rapidxml::xml_node ### Description Represents a node within an XML document. This class supports different node types (e.g., element, text, comment) and provides methods for navigating the XML tree and accessing node properties. ### Methods - **xml_node(node_type type)**: Constructor for an XML node, specifying its type. ``` -------------------------------- ### memory_pool::allocate_string Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Allocates a character array of a specified size from the pool. It can optionally copy a source string into the allocated memory. Allocation failures are handled similarly to node and attribute allocation. ```APIDOC ## function memory_pool::allocate_string ### Description Allocates a char array of given size from the pool, and optionally copies a given string to it. If the allocation request cannot be accomodated, this function will throw `std::bad_alloc`. If exceptions are disabled by defining RAPIDXML_NO_EXCEPTIONS, this function will call [rapidxml::parse_error_handler()](#namespacerapidxml_ff5d67f74437199d316d2b2660653ae1_1ff5d67f74437199d316d2b2660653ae1) function. ### Synopsis `Ch* allocate_string(const Ch *source=0, std::size_t size=0);` ### Parameters - **source** (const Ch *) - String to initialize the allocated memory with, or 0 to not initialize it. - **size** (std::size_t) - Number of characters to allocate, or zero to calculate it automatically from source string length; if size is 0, source string must be specified and null terminated. ### Returns Pointer to allocated char array. This pointer will never be NULL. ``` -------------------------------- ### xml_attribute::xml_attribute Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Constructs an empty XML attribute. It is recommended to use the memory pool of the appropriate `xml_document` if allocating attributes manually. ```APIDOC ## constructor xml_attribute::xml_attribute ### Description Constructs an empty attribute with the specified type. Consider using `memory_pool` of appropriate `xml_document` if allocating attributes manually. ``` -------------------------------- ### RapidXml Print Flag: No Indenting Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html This printer flag instructs the printer to suppress the indenting of XML output. See the print() function for more details. ```cpp const int print_no_indenting = 0x1; ``` -------------------------------- ### xml_base::value (zero-terminated) Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Sets the value of an XML node to a zero-terminated string. Similar to the other `value` function, the node does not own the string, and the user is responsible for managing its lifetime. ```APIDOC ## function xml_base::value ### Description Sets value of node to a zero-terminated string. ### Parameters - **value** (const Ch *) - The zero-terminated string to set as the node's value. ``` -------------------------------- ### Insert Child Node Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Inserts a new node at a specific position within the current node's children list. ```cpp void insert_node(xml_node< Ch > *where, xml_node< Ch > *child); ``` -------------------------------- ### RapidXml Parse Flag: Validate Closing Tags Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Use this flag to instruct the parser to validate closing tag names. If not set, the name inside the closing tag is irrelevant. By default, closing tags are not validated. Can be combined with other flags. ```cpp const int parse_validate_closing_tags = 0x200; ``` -------------------------------- ### Custom Parse Error Handler Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Defines a user-provided function to handle parsing errors when exceptions are disabled. This function must not return. ```cpp void rapidxml::parse_error_handler(const char *what, void *where) { std::cout << "Parse error: " << what << "\n"; std::abort(); } ``` -------------------------------- ### xml_node::document Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Retrieves a pointer to the XML document that this node belongs to. ```APIDOC ## xml_node::document ### Description Gets document of which node is a child. ### Returns * **xml_document* - Pointer to document that contains this node, or 0 if there is no parent document. ``` -------------------------------- ### xml_node::append_attribute Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Appends a new attribute to the current node. ```APIDOC ## xml_node::append_attribute ### Description Appends a new attribute to the node. ### Parameters - **attribute** (xml_attribute< Ch > *) - The attribute to append. ``` -------------------------------- ### xml_node::type Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Retrieves the type of the XML node. ```APIDOC ## xml_node::type ### Description Gets type of node. ### Returns * **node_type** - Type of node. ``` -------------------------------- ### RapidXml XML Attribute Node Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Represents an attribute node within an XML document. Attribute names and values point to the source text, which must persist for the lifetime of the attribute. ```cpp template class xml_attribute ``` -------------------------------- ### xml_node::next_sibling Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Retrieves the next sibling node of the current node. It can optionally filter siblings by name and specify case sensitivity for the name comparison. ```APIDOC ## xml_node::next_sibling ### Description Gets next sibling node, optionally matching node name. Behaviour is undefined if node has no parent. Use [parent()](#classrapidxml_1_1xml__base_798e8df7ea53ade4d9f0701017dce80e_1798e8df7ea53ade4d9f0701017dce80e) to test if node has a parent. ### Parameters - **name** (const Ch *) - Optional - Name of sibling to find, or 0 to return next sibling regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero. - **name_size** (std::size_t) - Optional - Size of name, in characters, or 0 to have size calculated automatically from string. - **case_sensitive** (bool) - Optional - Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters. ### Returns - **xml_node*** - Pointer to found sibling, or 0 if not found. ``` -------------------------------- ### Remove First Child Node Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Removes the first child node from the current node. Behavior is undefined if the node has no children. ```cpp void remove_first_node(); ``` -------------------------------- ### Set Node Value (zero-terminated) Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Sets the value of an XML node to a zero-terminated string. The node only stores a pointer; manage the string's lifetime externally, preferably using the document's memory pool. ```cpp void value(const Ch *value); ``` -------------------------------- ### xml_base::name Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Sets the name of an XML node to a zero-terminated string. This function is part of the `xml_base` class and is used for node name manipulation. ```APIDOC ## function xml_base::name ### Description Sets name of node to a zero-terminated string. ### Parameters - **name** (const Ch *) - The zero-terminated string to set as the node's name. ``` -------------------------------- ### memory_pool::allocate_attribute Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Allocates a new XML attribute from the memory pool. It can optionally assign a name and value to the attribute. Similar to allocate_node, it handles allocation failures by throwing std::bad_alloc or calling a parse error handler. ```APIDOC ## function memory_pool::allocate_attribute ### Description Allocates a new attribute from the pool, and optionally assigns name and value to it. If the allocation request cannot be accomodated, this function will throw `std::bad_alloc`. If exceptions are disabled by defining RAPIDXML_NO_EXCEPTIONS, this function will call [rapidxml::parse_error_handler()](#namespacerapidxml_ff5d67f74437199d316d2b2660653ae1_1ff5d67f74437199d316d2b2660653ae1) function. ### Synopsis `xml_attribute* allocate_attribute(const Ch *name=0, const Ch *value=0, std::size_t name_size=0, std::size_t value_size=0);` ### Parameters - **name** (const Ch *) - Name to assign to the attribute, or 0 to assign no name. - **value** (const Ch *) - Value to assign to the attribute, or 0 to assign no value. - **name_size** (std::size_t) - Size of name to assign, or 0 to automatically calculate size from name string. - **value_size** (std::size_t) - Size of value to assign, or 0 to automatically calculate size from value string. ### Returns Pointer to allocated attribute. This pointer will never be NULL. ``` -------------------------------- ### xml_node::first_attribute Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Retrieves the first attribute of the current node. It can optionally filter attributes by name and specify case sensitivity for the name comparison. ```APIDOC ## xml_node::first_attribute ### Description Gets first attribute of node, optionally matching attribute name. ### Parameters - **name** (const Ch *) - Optional - Name of attribute to find, or 0 to return first attribute regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero. - **name_size** (std::size_t) - Optional - Size of name, in characters, or 0 to have size calculated automatically from string. - **case_sensitive** (bool) - Optional - Should name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters. ### Returns - **xml_attribute*** - Pointer to found attribute, or 0 if not found. ``` -------------------------------- ### memory_pool::set_allocator Source: https://github.com/cartotype/cartotype-public/blob/master/src/main/library/rapidxml-1.13/manual.html Sets or resets the user-defined memory allocation functions for the pool. This function should be called before any memory is allocated from the pool. It allows customization of memory management by providing custom allocation and free functions. ```APIDOC ## memory_pool::set_allocator ### Description Sets or resets the user-defined memory allocation functions for the pool. This can only be called when no memory is allocated from the pool yet, otherwise results are undefined. Allocation function must not return invalid pointer on failure. It should either throw, stop the program, or use `longjmp()` function to pass control to other place of program. If it returns invalid pointer, results are undefined. User defined allocation functions must have the following forms: `void *allocate(std::size_t size);` `void free(void *pointer);` ### Parameters * **af** (alloc_func *) - Allocation function, or 0 to restore default function * **ff** (free_func *) - Free function, or 0 to restore default function ```