IN2OSM  1.0.1
xml_document< Ch >

#include <rapidxml.hpp>

Inheritance diagram for xml_document< Ch >:
Inheritance graph
Collaboration diagram for xml_document< Ch >:
Collaboration graph

Classes

struct  attribute_name_pred
 
struct  attribute_value_pred
 
struct  attribute_value_pure_pred
 
struct  node_name_pred
 
struct  text_pred
 
struct  text_pure_no_ws_pred
 
struct  text_pure_with_ws_pred
 
struct  whitespace_pred
 

Public Member Functions

 xml_document ()
 Constructs empty XML document. More...
 
template<int Flags>
void parse (Ch *text)
 
void clear ()
 
node_type type () const
 
void type (node_type type)
 
xml_document< Ch > * document () const
 
xml_node< Ch > * first_node (const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const
 
xml_node< Ch > * last_node (const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const
 
xml_node< Ch > * previous_sibling (const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const
 
xml_node< Ch > * next_sibling (const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const
 
xml_attribute< Ch > * first_attribute (const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const
 
xml_attribute< Ch > * last_attribute (const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const
 
void prepend_node (xml_node< Ch > *child)
 
void append_node (xml_node< Ch > *child)
 
void insert_node (xml_node< Ch > *where, xml_node< Ch > *child)
 
void remove_first_node ()
 
void remove_last_node ()
 
void remove_node (xml_node< Ch > *where)
 Removes specified child from the node. More...
 
void remove_all_nodes ()
 Removes all child nodes (but not attributes). More...
 
void prepend_attribute (xml_attribute< Ch > *attribute)
 
void append_attribute (xml_attribute< Ch > *attribute)
 
void insert_attribute (xml_attribute< Ch > *where, xml_attribute< Ch > *attribute)
 
void remove_first_attribute ()
 
void remove_last_attribute ()
 
void remove_attribute (xml_attribute< Ch > *where)
 
void remove_all_attributes ()
 Removes all attributes of node. More...
 
Ch * name () const
 
void name (const Ch *name, std::size_t size)
 
void name (const Ch *name)
 
std::size_t name_size () const
 
Ch * value () const
 
void value (const Ch *value, std::size_t size)
 
void value (const Ch *value)
 
std::size_t value_size () const
 
xml_node< Ch > * parent () const
 
xml_node< Ch > * 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)
 
xml_attribute< Ch > * allocate_attribute (const Ch *name=0, const Ch *value=0, std::size_t name_size=0, std::size_t value_size=0)
 
Ch * allocate_string (const Ch *source=0, std::size_t size=0)
 
xml_node< Ch > * clone_node (const xml_node< Ch > *source, xml_node< Ch > *result=0)
 
void set_allocator (alloc_func *af, free_func *ff)
 

Static Protected Member Functions

static Ch * nullstr ()
 

Protected Attributes

Ch * m_name
 
Ch * m_value
 
std::size_t m_name_size
 
std::size_t m_value_size
 
xml_node< Ch > * m_parent
 

Private Member Functions

template<int Flags>
void parse_bom (Ch *&text)
 
template<int Flags>
xml_node< Ch > * parse_xml_declaration (Ch *&text)
 
template<int Flags>
xml_node< Ch > * parse_comment (Ch *&text)
 
template<int Flags>
xml_node< Ch > * parse_doctype (Ch *&text)
 
template<int Flags>
xml_node< Ch > * parse_pi (Ch *&text)
 
template<int Flags>
Ch parse_and_append_data (xml_node< Ch > *node, Ch *&text, Ch *contents_start)
 
template<int Flags>
xml_node< Ch > * parse_cdata (Ch *&text)
 
template<int Flags>
xml_node< Ch > * parse_element (Ch *&text)
 
template<int Flags>
xml_node< Ch > * parse_node (Ch *&text)
 
template<int Flags>
void parse_node_contents (Ch *&text, xml_node< Ch > *node)
 
template<int Flags>
void parse_node_attributes (Ch *&text, xml_node< Ch > *node)
 

Static Private Member Functions

template<int Flags>
static void insert_coded_character (Ch *&text, unsigned long code)
 
template<class StopPred , int Flags>
static void skip (Ch *&text)
 
template<class StopPred , class StopPredPure , int Flags>
static Ch * skip_and_expand_character_refs (Ch *&text)
 

Detailed Description

template<class Ch = char>
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.

Parameters
ChCharacter type to use.

Definition at line 139 of file rapidxml.hpp.

Constructor & Destructor Documentation

◆ xml_document()

xml_document ( )
inline

Constructs empty XML document.

Definition at line 1364 of file rapidxml.hpp.

1365  : xml_node<Ch>(node_document)
1366  {
1367  }
A document node. Name and value are empty.
Definition: rapidxml.hpp:145

Member Function Documentation

◆ allocate_attribute()

xml_attribute<Ch>* allocate_attribute ( const Ch *  name = 0,
const Ch *  value = 0,
std::size_t  name_size = 0,
std::size_t  value_size = 0 
)
inlineinherited

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() function.

Parameters
nameName to assign to the attribute, or 0 to assign no name.
valueValue to assign to the attribute, or 0 to assign no value.
name_sizeSize of name to assign, or 0 to automatically calculate size from name string.
value_sizeSize of value to assign, or 0 to automatically calculate size from value string.
Returns
Pointer to allocated attribute. This pointer will never be NULL.

Definition at line 447 of file rapidxml.hpp.

449  {
450  void *memory = allocate_aligned(sizeof(xml_attribute<Ch>));
451  xml_attribute<Ch> *attribute = new(memory) xml_attribute<Ch>;
452  if (name)
453  {
454  if (name_size > 0)
455  attribute->name(name, name_size);
456  else
457  attribute->name(name);
458  }
459  if (value)
460  {
461  if (value_size > 0)
462  attribute->value(value, value_size);
463  else
464  attribute->value(value);
465  }
466  return attribute;
467  }
void * allocate_aligned(std::size_t size)
Definition: rapidxml.hpp:599
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1282
Here is the call graph for this function:
Here is the caller graph for this function:

◆ allocate_node()

xml_node<Ch>* 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 
)
inlineinherited

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() function.

Parameters
typeType of node to create.
nameName to assign to the node, or 0 to assign no name.
valueValue to assign to the node, or 0 to assign no value.
name_sizeSize of name to assign, or 0 to automatically calculate size from name string.
value_sizeSize of value to assign, or 0 to automatically calculate size from value string.
Returns
Pointer to allocated node. This pointer will never be NULL.

Definition at line 415 of file rapidxml.hpp.

418  {
419  void *memory = allocate_aligned(sizeof(xml_node<Ch>));
420  xml_node<Ch> *node = new(memory) xml_node<Ch>(type);
421  if (name)
422  {
423  if (name_size > 0)
424  node->name(name, name_size);
425  else
426  node->name(name);
427  }
428  if (value)
429  {
430  if (value_size > 0)
431  node->value(value, value_size);
432  else
433  node->value(value);
434  }
435  return node;
436  }
void * allocate_aligned(std::size_t size)
Definition: rapidxml.hpp:599
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1282
Here is the call graph for this function:
Here is the caller graph for this function:

◆ allocate_string()

Ch* allocate_string ( const Ch *  source = 0,
std::size_t  size = 0 
)
inlineinherited

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() function.

Parameters
sourceString to initialize the allocated memory with, or 0 to not initialize it.
sizeNumber 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.

Definition at line 476 of file rapidxml.hpp.

477  {
478  assert(source || size); // Either source or size (or both) must be specified
479  if (size == 0)
480  size = internal::measure(source) + 1;
481  Ch *result = static_cast<Ch *>(allocate_aligned(size * sizeof(Ch)));
482  if (source)
483  for (std::size_t i = 0; i < size; ++i)
484  result[i] = source[i];
485  return result;
486  }
const CharType(& source)[N]
Definition: pointer.h:1204
void * allocate_aligned(std::size_t size)
Definition: rapidxml.hpp:599
Here is the caller graph for this function:

◆ append_attribute()

void append_attribute ( xml_attribute< Ch > *  attribute)
inlineinherited

Appends a new attribute to the node.

Parameters
attributeAttribute to append.

Definition at line 1217 of file rapidxml.hpp.

1218  {
1219  assert(attribute && !attribute->parent());
1220  if (first_attribute())
1221  {
1222  attribute->m_prev_attribute = m_last_attribute;
1223  m_last_attribute->m_next_attribute = attribute;
1224  }
1225  else
1226  {
1227  attribute->m_prev_attribute = 0;
1228  m_first_attribute = attribute;
1229  }
1230  m_last_attribute = attribute;
1231  attribute->m_parent = this;
1232  attribute->m_next_attribute = 0;
1233  }
xml_attribute< Ch > * m_last_attribute
Definition: rapidxml.hpp:1341
xml_attribute< Ch > * m_first_attribute
Definition: rapidxml.hpp:1340
xml_attribute< Ch > * first_attribute(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const
Definition: rapidxml.hpp:1025
Here is the call graph for this function:
Here is the caller graph for this function:

◆ append_node()

void append_node ( xml_node< Ch > *  child)
inlineinherited

Appends a new child node. The appended child becomes the last child.

Parameters
childNode to append.

Definition at line 1097 of file rapidxml.hpp.

1098  {
1099  assert(child && !child->parent() && child->type() != node_document);
1100  if (first_node())
1101  {
1102  child->m_prev_sibling = m_last_node;
1103  m_last_node->m_next_sibling = child;
1104  }
1105  else
1106  {
1107  child->m_prev_sibling = 0;
1108  m_first_node = child;
1109  }
1110  m_last_node = child;
1111  child->m_parent = this;
1112  child->m_next_sibling = 0;
1113  }
xml_node< Ch > * m_first_node
Definition: rapidxml.hpp:1338
xml_node< Ch > * m_last_node
Definition: rapidxml.hpp:1339
A document node. Name and value are empty.
Definition: rapidxml.hpp:145
xml_node< Ch > * first_node(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const
Definition: rapidxml.hpp:936
Here is the call graph for this function:
Here is the caller graph for this function:

◆ clear()

void clear ( )
inline

Clears the document by deleting all nodes and clearing the memory pool. All nodes owned by document pool are destroyed.

Definition at line 1415 of file rapidxml.hpp.

1416  {
1417  this->remove_all_nodes();
1418  this->remove_all_attributes();
1420  }
void remove_all_attributes()
Removes all attributes of node.
Definition: rapidxml.hpp:1309
void remove_all_nodes()
Removes all child nodes (but not attributes).
Definition: rapidxml.hpp:1188
Here is the call graph for this function:
Here is the caller graph for this function:

◆ clone_node()

xml_node<Ch>* clone_node ( const xml_node< Ch > *  source,
xml_node< Ch > *  result = 0 
)
inlineinherited

Clones an xml_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.

Parameters
sourceNode to clone.
resultNode to put results in, or 0 to automatically allocate result node
Returns
Pointer to cloned node. This pointer will never be NULL.

Definition at line 497 of file rapidxml.hpp.

498  {
499  // Prepare result node
500  if (result)
501  {
502  result->remove_all_attributes();
503  result->remove_all_nodes();
504  result->type(source->type());
505  }
506  else
507  result = allocate_node(source->type());
508 
509  // Clone name and value
510  result->name(source->name(), source->name_size());
511  result->value(source->value(), source->value_size());
512 
513  // Clone child nodes and attributes
514  for (xml_node<Ch> *child = source->first_node(); child; child = child->next_sibling())
515  result->append_node(clone_node(child));
516  for (xml_attribute<Ch> *attr = source->first_attribute(); attr; attr = attr->next_attribute())
517  result->append_attribute(allocate_attribute(attr->name(), attr->value(), attr->name_size(), attr->value_size()));
518 
519  return result;
520  }
xml_node< Ch > * 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)
Definition: rapidxml.hpp:415
const CharType(& source)[N]
Definition: pointer.h:1204
xml_node< Ch > * clone_node(const xml_node< Ch > *source, xml_node< Ch > *result=0)
Definition: rapidxml.hpp:497
xml_attribute< Ch > * allocate_attribute(const Ch *name=0, const Ch *value=0, std::size_t name_size=0, std::size_t value_size=0)
Definition: rapidxml.hpp:447
Here is the call graph for this function:

◆ document()

xml_document<Ch>* document ( ) const
inlineinherited

Gets document of which node is a child.

Returns
Pointer to document that contains this node, or 0 if there is no parent document.

Definition at line 923 of file rapidxml.hpp.

924  {
925  xml_node<Ch> *node = const_cast<xml_node<Ch> *>(this);
926  while (node->parent())
927  node = node->parent();
928  return node->type() == node_document ? static_cast<xml_document<Ch> *>(node) : 0;
929  }
A document node. Name and value are empty.
Definition: rapidxml.hpp:145
Here is the call graph for this function:

◆ first_attribute()

xml_attribute<Ch>* first_attribute ( const Ch *  name = 0,
std::size_t  name_size = 0,
bool  case_sensitive = true 
) const
inlineinherited

Gets first attribute of node, optionally matching attribute name.

Parameters
nameName 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_sizeSize of name, in characters, or 0 to have size calculated automatically from string
case_sensitiveShould 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.

Definition at line 1025 of file rapidxml.hpp.

1026  {
1027  if (name)
1028  {
1029  if (name_size == 0)
1030  name_size = internal::measure(name);
1031  for (xml_attribute<Ch> *attribute = m_first_attribute; attribute; attribute = attribute->m_next_attribute)
1032  if (internal::compare(attribute->name(), attribute->name_size(), name, name_size, case_sensitive))
1033  return attribute;
1034  return 0;
1035  }
1036  else
1037  return m_first_attribute;
1038  }
xml_attribute< Ch > * m_first_attribute
Definition: rapidxml.hpp:1340
Ch * name() const
Definition: rapidxml.hpp:673
std::size_t name_size() const
Definition: rapidxml.hpp:681
Here is the caller graph for this function:

◆ first_node()

xml_node<Ch>* first_node ( const Ch *  name = 0,
std::size_t  name_size = 0,
bool  case_sensitive = true 
) const
inlineinherited

Gets first child node, optionally matching node name.

Parameters
nameName of child to find, or 0 to return first child regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero
name_sizeSize of name, in characters, or 0 to have size calculated automatically from string
case_sensitiveShould name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters
Returns
Pointer to found child, or 0 if not found.

Definition at line 936 of file rapidxml.hpp.

937  {
938  if (name)
939  {
940  if (name_size == 0)
941  name_size = internal::measure(name);
942  for (xml_node<Ch> *child = m_first_node; child; child = child->next_sibling())
943  if (internal::compare(child->name(), child->name_size(), name, name_size, case_sensitive))
944  return child;
945  return 0;
946  }
947  else
948  return m_first_node;
949  }
xml_node< Ch > * m_first_node
Definition: rapidxml.hpp:1338
Ch * name() const
Definition: rapidxml.hpp:673
std::size_t name_size() const
Definition: rapidxml.hpp:681
Here is the call graph for this function:
Here is the caller graph for this function:

◆ insert_attribute()

void insert_attribute ( xml_attribute< Ch > *  where,
xml_attribute< Ch > *  attribute 
)
inlineinherited

Inserts a new attribute at specified place inside the node. All attributes after and including the specified attribute are moved one position back.

Parameters
wherePlace where to insert the attribute, or 0 to insert at the back.
attributeAttribute to insert.

Definition at line 1239 of file rapidxml.hpp.

1240  {
1241  assert(!where || where->parent() == this);
1242  assert(attribute && !attribute->parent());
1243  if (where == m_first_attribute)
1244  prepend_attribute(attribute);
1245  else if (where == 0)
1246  append_attribute(attribute);
1247  else
1248  {
1249  attribute->m_prev_attribute = where->m_prev_attribute;
1250  attribute->m_next_attribute = where;
1251  where->m_prev_attribute->m_next_attribute = attribute;
1252  where->m_prev_attribute = attribute;
1253  attribute->m_parent = this;
1254  }
1255  }
void append_attribute(xml_attribute< Ch > *attribute)
Definition: rapidxml.hpp:1217
void prepend_attribute(xml_attribute< Ch > *attribute)
Definition: rapidxml.hpp:1197
xml_attribute< Ch > * m_first_attribute
Definition: rapidxml.hpp:1340
Here is the call graph for this function:

◆ insert_coded_character()

static void insert_coded_character ( Ch *&  text,
unsigned long  code 
)
inlinestaticprivate

Definition at line 1511 of file rapidxml.hpp.

1512  {
1513  if (Flags & parse_no_utf8)
1514  {
1515  // Insert 8-bit ASCII character
1516  // Todo: possibly verify that code is less than 256 and use replacement char otherwise?
1517  text[0] = static_cast<unsigned char>(code);
1518  text += 1;
1519  }
1520  else
1521  {
1522  // Insert UTF8 sequence
1523  if (code < 0x80) // 1 byte sequence
1524  {
1525  text[0] = static_cast<unsigned char>(code);
1526  text += 1;
1527  }
1528  else if (code < 0x800) // 2 byte sequence
1529  {
1530  text[1] = static_cast<unsigned char>((code | 0x80) & 0xBF); code >>= 6;
1531  text[0] = static_cast<unsigned char>(code | 0xC0);
1532  text += 2;
1533  }
1534  else if (code < 0x10000) // 3 byte sequence
1535  {
1536  text[2] = static_cast<unsigned char>((code | 0x80) & 0xBF); code >>= 6;
1537  text[1] = static_cast<unsigned char>((code | 0x80) & 0xBF); code >>= 6;
1538  text[0] = static_cast<unsigned char>(code | 0xE0);
1539  text += 3;
1540  }
1541  else if (code < 0x110000) // 4 byte sequence
1542  {
1543  text[3] = static_cast<unsigned char>((code | 0x80) & 0xBF); code >>= 6;
1544  text[2] = static_cast<unsigned char>((code | 0x80) & 0xBF); code >>= 6;
1545  text[1] = static_cast<unsigned char>((code | 0x80) & 0xBF); code >>= 6;
1546  text[0] = static_cast<unsigned char>(code | 0xF0);
1547  text += 4;
1548  }
1549  else // Invalid, only codes up to 0x10FFFF are allowed in Unicode
1550  {
1551  RAPIDXML_PARSE_ERROR("invalid numeric character entity", text);
1552  }
1553  }
1554  }
#define RAPIDXML_PARSE_ERROR(what, where)
Definition: rapidxml.hpp:55
const int parse_no_utf8
Definition: rapidxml.hpp:193

◆ insert_node()

void insert_node ( xml_node< Ch > *  where,
xml_node< Ch > *  child 
)
inlineinherited

Inserts a new child node at specified place inside the node. All children after and including the specified node are moved one position back.

Parameters
wherePlace where to insert the child, or 0 to insert at the back.
childNode to insert.

Definition at line 1119 of file rapidxml.hpp.

1120  {
1121  assert(!where || where->parent() == this);
1122  assert(child && !child->parent() && child->type() != node_document);
1123  if (where == m_first_node)
1124  prepend_node(child);
1125  else if (where == 0)
1126  append_node(child);
1127  else
1128  {
1129  child->m_prev_sibling = where->m_prev_sibling;
1130  child->m_next_sibling = where;
1131  where->m_prev_sibling->m_next_sibling = child;
1132  where->m_prev_sibling = child;
1133  child->m_parent = this;
1134  }
1135  }
xml_node< Ch > * m_first_node
Definition: rapidxml.hpp:1338
void prepend_node(xml_node< Ch > *child)
Definition: rapidxml.hpp:1076
void append_node(xml_node< Ch > *child)
Definition: rapidxml.hpp:1097
A document node. Name and value are empty.
Definition: rapidxml.hpp:145
Here is the call graph for this function:

◆ last_attribute()

xml_attribute<Ch>* last_attribute ( const Ch *  name = 0,
std::size_t  name_size = 0,
bool  case_sensitive = true 
) const
inlineinherited

Gets last attribute of node, optionally matching attribute name.

Parameters
nameName of attribute to find, or 0 to return last attribute regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero
name_sizeSize of name, in characters, or 0 to have size calculated automatically from string
case_sensitiveShould 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.

Definition at line 1045 of file rapidxml.hpp.

1046  {
1047  if (name)
1048  {
1049  if (name_size == 0)
1050  name_size = internal::measure(name);
1051  for (xml_attribute<Ch> *attribute = m_last_attribute; attribute; attribute = attribute->m_prev_attribute)
1052  if (internal::compare(attribute->name(), attribute->name_size(), name, name_size, case_sensitive))
1053  return attribute;
1054  return 0;
1055  }
1056  else
1057  return m_first_attribute ? m_last_attribute : 0;
1058  }
xml_attribute< Ch > * m_last_attribute
Definition: rapidxml.hpp:1341
xml_attribute< Ch > * m_first_attribute
Definition: rapidxml.hpp:1340
Ch * name() const
Definition: rapidxml.hpp:673
std::size_t name_size() const
Definition: rapidxml.hpp:681

◆ last_node()

xml_node<Ch>* last_node ( const Ch *  name = 0,
std::size_t  name_size = 0,
bool  case_sensitive = true 
) const
inlineinherited

Gets last child node, optionally matching node name. Behaviour is undefined if node has no children. Use first_node() to test if node has children.

Parameters
nameName of child to find, or 0 to return last child regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero
name_sizeSize of name, in characters, or 0 to have size calculated automatically from string
case_sensitiveShould name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters
Returns
Pointer to found child, or 0 if not found.

Definition at line 958 of file rapidxml.hpp.

959  {
960  assert(m_first_node); // Cannot query for last child if node has no children
961  if (name)
962  {
963  if (name_size == 0)
964  name_size = internal::measure(name);
965  for (xml_node<Ch> *child = m_last_node; child; child = child->previous_sibling())
966  if (internal::compare(child->name(), child->name_size(), name, name_size, case_sensitive))
967  return child;
968  return 0;
969  }
970  else
971  return m_last_node;
972  }
xml_node< Ch > * m_first_node
Definition: rapidxml.hpp:1338
xml_node< Ch > * m_last_node
Definition: rapidxml.hpp:1339
Ch * name() const
Definition: rapidxml.hpp:673
std::size_t name_size() const
Definition: rapidxml.hpp:681
Here is the call graph for this function:

◆ name() [1/3]

Ch* name ( ) const
inlineinherited

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 option was selected during parse.

Use name_size() function to determine length of the name.

Returns
Name of node, or empty string if node has no name.

Definition at line 673 of file rapidxml.hpp.

674  {
675  return m_name ? m_name : nullstr();
676  }
static Ch * nullstr()
Definition: rapidxml.hpp:778
Here is the caller graph for this function:

◆ name() [2/3]

void name ( const Ch *  name,
std::size_t  size 
)
inlineinherited

Sets name of node to a non zero-terminated string. See ownership_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 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 *) function to have the length automatically calculated (string must be zero terminated).

Parameters
nameName of node to set. Does not have to be zero terminated.
sizeSize of name, in characters. This does not include zero terminator, if one is present.

Definition at line 721 of file rapidxml.hpp.

722  {
723  m_name = const_cast<Ch *>(name);
724  m_name_size = size;
725  }
std::size_t m_name_size
Definition: rapidxml.hpp:786
Ch * name() const
Definition: rapidxml.hpp:673

◆ name() [3/3]

void name ( const Ch *  name)
inlineinherited

Sets name of node to a zero-terminated string. See also ownership_of_strings and xml_node::name(const Ch *, std::size_t).

Parameters
nameName of node to set. Must be zero terminated.

Definition at line 730 of file rapidxml.hpp.

731  {
732  this->name(name, internal::measure(name));
733  }
Ch * name() const
Definition: rapidxml.hpp:673

◆ name_size()

std::size_t name_size ( ) const
inlineinherited

Gets size of node name, not including terminator character. This function works correctly irrespective of whether name is or is not zero terminated.

Returns
Size of node name, in characters.

Definition at line 681 of file rapidxml.hpp.

682  {
683  return m_name ? m_name_size : 0;
684  }
std::size_t m_name_size
Definition: rapidxml.hpp:786
Here is the caller graph for this function:

◆ next_sibling()

xml_node<Ch>* next_sibling ( const Ch *  name = 0,
std::size_t  name_size = 0,
bool  case_sensitive = true 
) const
inlineinherited

Gets next sibling node, optionally matching node name. Behaviour is undefined if node has no parent. Use parent() to test if node has a parent.

Parameters
nameName 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_sizeSize of name, in characters, or 0 to have size calculated automatically from string
case_sensitiveShould name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters
Returns
Pointer to found sibling, or 0 if not found.

Definition at line 1004 of file rapidxml.hpp.

1005  {
1006  assert(this->m_parent); // Cannot query for siblings if node has no parent
1007  if (name)
1008  {
1009  if (name_size == 0)
1010  name_size = internal::measure(name);
1011  for (xml_node<Ch> *sibling = m_next_sibling; sibling; sibling = sibling->m_next_sibling)
1012  if (internal::compare(sibling->name(), sibling->name_size(), name, name_size, case_sensitive))
1013  return sibling;
1014  return 0;
1015  }
1016  else
1017  return m_next_sibling;
1018  }
xml_node< Ch > * m_parent
Definition: rapidxml.hpp:788
xml_node< Ch > * m_next_sibling
Definition: rapidxml.hpp:1343
Ch * name() const
Definition: rapidxml.hpp:673
std::size_t name_size() const
Definition: rapidxml.hpp:681
Here is the caller graph for this function:

◆ nullstr()

static Ch* nullstr ( )
inlinestaticprotectedinherited

Definition at line 778 of file rapidxml.hpp.

779  {
780  static Ch zero = Ch('\0');
781  return &zero;
782  }

◆ parent()

xml_node<Ch>* parent ( ) const
inlineinherited

Gets node parent.

Returns
Pointer to parent node, or 0 if there is no parent.

Definition at line 770 of file rapidxml.hpp.

771  {
772  return m_parent;
773  }
xml_node< Ch > * m_parent
Definition: rapidxml.hpp:788
Here is the caller graph for this function:

◆ parse()

void parse ( Ch *  text)
inline

Parses zero-terminated XML string according to given flags. Passed string will be modified by the parser, unless rapidxml::parse_non_destructive flag is used. The string must persist for the lifetime of the document. In case of error, rapidxml::parse_error exception will be thrown.

If you want to parse contents of a file, you must first load the file into the memory, and pass pointer to its beginning. Make sure that data is zero-terminated.

Document can be parsed into multiple times. Each new call to parse removes previous nodes and attributes (if any), but does not clear memory pool.

Parameters
textXML data to parse; pointer is non-const to denote fact that this data may be modified by the parser.

Definition at line 1381 of file rapidxml.hpp.

1382  {
1383  assert(text);
1384 
1385  // Remove current contents
1386  this->remove_all_nodes();
1387  this->remove_all_attributes();
1388 
1389  // Parse BOM, if any
1390  parse_bom<Flags>(text);
1391 
1392  // Parse children
1393  while (1)
1394  {
1395  // Skip whitespace before node
1396  skip<whitespace_pred, Flags>(text);
1397  if (*text == 0)
1398  break;
1399 
1400  // Parse and append new child
1401  if (*text == Ch('<'))
1402  {
1403  ++text; // Skip '<'
1404  if (xml_node<Ch> *node = parse_node<Flags>(text))
1405  this->append_node(node);
1406  }
1407  else
1408  RAPIDXML_PARSE_ERROR("expected <", text);
1409  }
1410 
1411  }
void remove_all_attributes()
Removes all attributes of node.
Definition: rapidxml.hpp:1309
#define RAPIDXML_PARSE_ERROR(what, where)
Definition: rapidxml.hpp:55
void append_node(xml_node< Ch > *child)
Definition: rapidxml.hpp:1097
void remove_all_nodes()
Removes all child nodes (but not attributes).
Definition: rapidxml.hpp:1188
Here is the caller graph for this function:

◆ parse_and_append_data()

Ch parse_and_append_data ( xml_node< Ch > *  node,
Ch *&  text,
Ch *  contents_start 
)
inlineprivate

Definition at line 1940 of file rapidxml.hpp.

1941  {
1942  // Backup to contents start if whitespace trimming is disabled
1943  if (!(Flags & parse_trim_whitespace))
1944  text = contents_start;
1945 
1946  // Skip until end of data
1947  Ch *value = text, *end;
1948  if (Flags & parse_normalize_whitespace)
1949  end = skip_and_expand_character_refs<text_pred, text_pure_with_ws_pred, Flags>(text);
1950  else
1951  end = skip_and_expand_character_refs<text_pred, text_pure_no_ws_pred, Flags>(text);
1952 
1953  // Trim trailing whitespace if flag is set; leading was already trimmed by whitespace skip after >
1954  if (Flags & parse_trim_whitespace)
1955  {
1956  if (Flags & parse_normalize_whitespace)
1957  {
1958  // Whitespace is already condensed to single space characters by skipping function, so just trim 1 char off the end
1959  if (*(end - 1) == Ch(' '))
1960  --end;
1961  }
1962  else
1963  {
1964  // Backup until non-whitespace character is found
1965  while (whitespace_pred::test(*(end - 1)))
1966  --end;
1967  }
1968  }
1969 
1970  // If characters are still left between end and value (this test is only necessary if normalization is enabled)
1971  // Create new data node
1972  if (!(Flags & parse_no_data_nodes))
1973  {
1974  xml_node<Ch> *data = this->allocate_node(node_data);
1975  data->value(value, end - value);
1976  node->append_node(data);
1977  }
1978 
1979  // Add data to parent node if no data exists yet
1980  if (!(Flags & parse_no_element_values))
1981  if (*node->value() == Ch('\0'))
1982  node->value(value, end - value);
1983 
1984  // Place zero terminator after value
1985  if (!(Flags & parse_no_string_terminators))
1986  {
1987  Ch ch = *text;
1988  *end = Ch('\0');
1989  return ch; // Return character that ends data; this is required because zero terminator overwritten it
1990  }
1991 
1992  // Return character that ends data
1993  return *text;
1994  }
const int parse_no_string_terminators
Definition: rapidxml.hpp:179
xml_node< Ch > * 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)
Definition: rapidxml.hpp:415
Ch * value() const
Definition: rapidxml.hpp:692
const int parse_trim_whitespace
Definition: rapidxml.hpp:238
const int parse_no_data_nodes
Definition: rapidxml.hpp:163
A data node. Name is empty. Value contains data text.
Definition: rapidxml.hpp:147
static unsigned char test(Ch ch)
Definition: rapidxml.hpp:1430
const int parse_no_element_values
Definition: rapidxml.hpp:172
const int parse_normalize_whitespace
Definition: rapidxml.hpp:247
Here is the call graph for this function:

◆ parse_bom()

void parse_bom ( Ch *&  text)
inlineprivate

Definition at line 1725 of file rapidxml.hpp.

1726  {
1727  // UTF-8?
1728  if (static_cast<unsigned char>(text[0]) == 0xEF &&
1729  static_cast<unsigned char>(text[1]) == 0xBB &&
1730  static_cast<unsigned char>(text[2]) == 0xBF)
1731  {
1732  text += 3; // Skup utf-8 bom
1733  }
1734  }

◆ parse_cdata()

xml_node<Ch>* parse_cdata ( Ch *&  text)
inlineprivate

Definition at line 1998 of file rapidxml.hpp.

1999  {
2000  // If CDATA is disabled
2001  if (Flags & parse_no_data_nodes)
2002  {
2003  // Skip until end of cdata
2004  while (text[0] != Ch(']') || text[1] != Ch(']') || text[2] != Ch('>'))
2005  {
2006  if (!text[0])
2007  RAPIDXML_PARSE_ERROR("unexpected end of data", text);
2008  ++text;
2009  }
2010  text += 3; // Skip ]]>
2011  return 0; // Do not produce CDATA node
2012  }
2013 
2014  // Skip until end of cdata
2015  Ch *value = text;
2016  while (text[0] != Ch(']') || text[1] != Ch(']') || text[2] != Ch('>'))
2017  {
2018  if (!text[0])
2019  RAPIDXML_PARSE_ERROR("unexpected end of data", text);
2020  ++text;
2021  }
2022 
2023  // Create new cdata node
2024  xml_node<Ch> *cdata = this->allocate_node(node_cdata);
2025  cdata->value(value, text - value);
2026 
2027  // Place zero terminator after value
2028  if (!(Flags & parse_no_string_terminators))
2029  *text = Ch('\0');
2030 
2031  text += 3; // Skip ]]>
2032  return cdata;
2033  }
const int parse_no_string_terminators
Definition: rapidxml.hpp:179
xml_node< Ch > * 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)
Definition: rapidxml.hpp:415
Ch * value() const
Definition: rapidxml.hpp:692
#define RAPIDXML_PARSE_ERROR(what, where)
Definition: rapidxml.hpp:55
const int parse_no_data_nodes
Definition: rapidxml.hpp:163
A CDATA node. Name is empty. Value contains data text.
Definition: rapidxml.hpp:148
Here is the call graph for this function:

◆ parse_comment()

xml_node<Ch>* parse_comment ( Ch *&  text)
inlineprivate

Definition at line 1773 of file rapidxml.hpp.

1774  {
1775  // If parsing of comments is disabled
1776  if (!(Flags & parse_comment_nodes))
1777  {
1778  // Skip until end of comment
1779  while (text[0] != Ch('-') || text[1] != Ch('-') || text[2] != Ch('>'))
1780  {
1781  if (!text[0])
1782  RAPIDXML_PARSE_ERROR("unexpected end of data", text);
1783  ++text;
1784  }
1785  text += 3; // Skip '-->'
1786  return 0; // Do not produce comment node
1787  }
1788 
1789  // Remember value start
1790  Ch *value = text;
1791 
1792  // Skip until end of comment
1793  while (text[0] != Ch('-') || text[1] != Ch('-') || text[2] != Ch('>'))
1794  {
1795  if (!text[0])
1796  RAPIDXML_PARSE_ERROR("unexpected end of data", text);
1797  ++text;
1798  }
1799 
1800  // Create comment node
1801  xml_node<Ch> *comment = this->allocate_node(node_comment);
1802  comment->value(value, text - value);
1803 
1804  // Place zero terminator after comment value
1805  if (!(Flags & parse_no_string_terminators))
1806  *text = Ch('\0');
1807 
1808  text += 3; // Skip '-->'
1809  return comment;
1810  }
const int parse_no_string_terminators
Definition: rapidxml.hpp:179
xml_node< Ch > * 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)
Definition: rapidxml.hpp:415
Ch * value() const
Definition: rapidxml.hpp:692
#define RAPIDXML_PARSE_ERROR(what, where)
Definition: rapidxml.hpp:55
const int parse_comment_nodes
Definition: rapidxml.hpp:207
A comment node. Name is empty. Value contains comment text.
Definition: rapidxml.hpp:149
Here is the call graph for this function:

◆ parse_doctype()

xml_node<Ch>* parse_doctype ( Ch *&  text)
inlineprivate

Definition at line 1814 of file rapidxml.hpp.

1815  {
1816  // Remember value start
1817  Ch *value = text;
1818 
1819  // Skip to >
1820  while (*text != Ch('>'))
1821  {
1822  // Determine character type
1823  switch (*text)
1824  {
1825 
1826  // If '[' encountered, scan for matching ending ']' using naive algorithm with depth
1827  // This works for all W3C test files except for 2 most wicked
1828  case Ch('['):
1829  {
1830  ++text; // Skip '['
1831  int depth = 1;
1832  while (depth > 0)
1833  {
1834  switch (*text)
1835  {
1836  case Ch('['): ++depth; break;
1837  case Ch(']'): --depth; break;
1838  case 0: RAPIDXML_PARSE_ERROR("unexpected end of data", text);
1839  }
1840  ++text;
1841  }
1842  break;
1843  }
1844 
1845  // Error on end of text
1846  case Ch('\0'):
1847  RAPIDXML_PARSE_ERROR("unexpected end of data", text);
1848 
1849  // Other character, skip it
1850  default:
1851  ++text;
1852 
1853  }
1854  }
1855 
1856  // If DOCTYPE nodes enabled
1857  if (Flags & parse_doctype_node)
1858  {
1859  // Create a new doctype node
1860  xml_node<Ch> *doctype = this->allocate_node(node_doctype);
1861  doctype->value(value, text - value);
1862 
1863  // Place zero terminator after value
1864  if (!(Flags & parse_no_string_terminators))
1865  *text = Ch('\0');
1866 
1867  text += 1; // skip '>'
1868  return doctype;
1869  }
1870  else
1871  {
1872  text += 1; // skip '>'
1873  return 0;
1874  }
1875 
1876  }
const int parse_no_string_terminators
Definition: rapidxml.hpp:179
xml_node< Ch > * 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)
Definition: rapidxml.hpp:415
Ch * value() const
Definition: rapidxml.hpp:692
#define RAPIDXML_PARSE_ERROR(what, where)
Definition: rapidxml.hpp:55
const int parse_doctype_node
Definition: rapidxml.hpp:215
A DOCTYPE node. Name is empty. Value contains DOCTYPE text.
Definition: rapidxml.hpp:151
Here is the call graph for this function:

◆ parse_element()

xml_node<Ch>* parse_element ( Ch *&  text)
inlineprivate

Definition at line 2037 of file rapidxml.hpp.

2038  {
2039  // Create element node
2040  xml_node<Ch> *element = this->allocate_node(node_element);
2041 
2042  // Extract element name
2043  Ch *name = text;
2044  skip<node_name_pred, Flags>(text);
2045  if (text == name)
2046  RAPIDXML_PARSE_ERROR("expected element name", text);
2047  element->name(name, text - name);
2048 
2049  // Skip whitespace between element name and attributes or >
2050  skip<whitespace_pred, Flags>(text);
2051 
2052  // Parse attributes, if any
2053  parse_node_attributes<Flags>(text, element);
2054 
2055  // Determine ending type
2056  if (*text == Ch('>'))
2057  {
2058  ++text;
2059  parse_node_contents<Flags>(text, element);
2060  }
2061  else if (*text == Ch('/'))
2062  {
2063  ++text;
2064  if (*text != Ch('>'))
2065  RAPIDXML_PARSE_ERROR("expected >", text);
2066  ++text;
2067  }
2068  else
2069  RAPIDXML_PARSE_ERROR("expected >", text);
2070 
2071  // Place zero terminator after name
2072  if (!(Flags & parse_no_string_terminators))
2073  element->name()[element->name_size()] = Ch('\0');
2074 
2075  // Return parsed element
2076  return element;
2077  }
const int parse_no_string_terminators
Definition: rapidxml.hpp:179
xml_node< Ch > * 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)
Definition: rapidxml.hpp:415
#define RAPIDXML_PARSE_ERROR(what, where)
Definition: rapidxml.hpp:55
An element node. Name contains element name. Value contains text of first data node.
Definition: rapidxml.hpp:146
Ch * name() const
Definition: rapidxml.hpp:673
Here is the call graph for this function:

◆ parse_node()

xml_node<Ch>* parse_node ( Ch *&  text)
inlineprivate

Definition at line 2081 of file rapidxml.hpp.

2082  {
2083  // Parse proper node type
2084  switch (text[0])
2085  {
2086 
2087  // <...
2088  default:
2089  // Parse and append element node
2090  return parse_element<Flags>(text);
2091 
2092  // <?...
2093  case Ch('?'):
2094  ++text; // Skip ?
2095  if ((text[0] == Ch('x') || text[0] == Ch('X')) &&
2096  (text[1] == Ch('m') || text[1] == Ch('M')) &&
2097  (text[2] == Ch('l') || text[2] == Ch('L')) &&
2098  whitespace_pred::test(text[3]))
2099  {
2100  // '<?xml ' - xml declaration
2101  text += 4; // Skip 'xml '
2102  return parse_xml_declaration<Flags>(text);
2103  }
2104  else
2105  {
2106  // Parse PI
2107  return parse_pi<Flags>(text);
2108  }
2109 
2110  // <!...
2111  case Ch('!'):
2112 
2113  // Parse proper subset of <! node
2114  switch (text[1])
2115  {
2116 
2117  // <!-
2118  case Ch('-'):
2119  if (text[2] == Ch('-'))
2120  {
2121  // '<!--' - xml comment
2122  text += 3; // Skip '!--'
2123  return parse_comment<Flags>(text);
2124  }
2125  break;
2126 
2127  // <![
2128  case Ch('['):
2129  if (text[2] == Ch('C') && text[3] == Ch('D') && text[4] == Ch('A') &&
2130  text[5] == Ch('T') && text[6] == Ch('A') && text[7] == Ch('['))
2131  {
2132  // '<![CDATA[' - cdata
2133  text += 8; // Skip '![CDATA['
2134  return parse_cdata<Flags>(text);
2135  }
2136  break;
2137 
2138  // <!D
2139  case Ch('D'):
2140  if (text[2] == Ch('O') && text[3] == Ch('C') && text[4] == Ch('T') &&
2141  text[5] == Ch('Y') && text[6] == Ch('P') && text[7] == Ch('E') &&
2142  whitespace_pred::test(text[8]))
2143  {
2144  // '<!DOCTYPE ' - doctype
2145  text += 9; // skip '!DOCTYPE '
2146  return parse_doctype<Flags>(text);
2147  }
2148 
2149  } // switch
2150 
2151  // Attempt to skip other, unrecognized node types starting with <!
2152  ++text; // Skip !
2153  while (*text != Ch('>'))
2154  {
2155  if (*text == 0)
2156  RAPIDXML_PARSE_ERROR("unexpected end of data", text);
2157  ++text;
2158  }
2159  ++text; // Skip '>'
2160  return 0; // No node recognized
2161 
2162  }
2163  }
#define RAPIDXML_PARSE_ERROR(what, where)
Definition: rapidxml.hpp:55
static unsigned char test(Ch ch)
Definition: rapidxml.hpp:1430

◆ parse_node_attributes()

void parse_node_attributes ( Ch *&  text,
xml_node< Ch > *  node 
)
inlineprivate

Definition at line 2237 of file rapidxml.hpp.

2238  {
2239  // For all attributes
2240  while (attribute_name_pred::test(*text))
2241  {
2242  // Extract attribute name
2243  Ch *name = text;
2244  ++text; // Skip first character of attribute name
2245  skip<attribute_name_pred, Flags>(text);
2246  if (text == name)
2247  RAPIDXML_PARSE_ERROR("expected attribute name", name);
2248 
2249  // Create new attribute
2250  xml_attribute<Ch> *attribute = this->allocate_attribute();
2251  attribute->name(name, text - name);
2252  node->append_attribute(attribute);
2253 
2254  // Skip whitespace after attribute name
2255  skip<whitespace_pred, Flags>(text);
2256 
2257  // Skip =
2258  if (*text != Ch('='))
2259  RAPIDXML_PARSE_ERROR("expected =", text);
2260  ++text;
2261 
2262  // Add terminating zero after name
2263  if (!(Flags & parse_no_string_terminators))
2264  attribute->name()[attribute->name_size()] = 0;
2265 
2266  // Skip whitespace after =
2267  skip<whitespace_pred, Flags>(text);
2268 
2269  // Skip quote and remember if it was ' or "
2270  Ch quote = *text;
2271  if (quote != Ch('\'') && quote != Ch('"'))
2272  RAPIDXML_PARSE_ERROR("expected ' or \"", text);
2273  ++text;
2274 
2275  // Extract attribute value and expand char refs in it
2276  Ch *value = text, *end;
2277  const int AttFlags = Flags & ~parse_normalize_whitespace; // No whitespace normalization in attributes
2278  if (quote == Ch('\''))
2279  end = skip_and_expand_character_refs<attribute_value_pred<Ch('\'')>, attribute_value_pure_pred<Ch('\'')>, AttFlags>(text);
2280  else
2281  end = skip_and_expand_character_refs<attribute_value_pred<Ch('"')>, attribute_value_pure_pred<Ch('"')>, AttFlags>(text);
2282 
2283  // Set attribute value
2284  attribute->value(value, end - value);
2285 
2286  // Make sure that end quote is present
2287  if (*text != quote)
2288  RAPIDXML_PARSE_ERROR("expected ' or \"", text);
2289  ++text; // Skip quote
2290 
2291  // Add terminating zero after value
2292  if (!(Flags & parse_no_string_terminators))
2293  attribute->value()[attribute->value_size()] = 0;
2294 
2295  // Skip whitespace after attribute value
2296  skip<whitespace_pred, Flags>(text);
2297  }
2298  }
const int parse_no_string_terminators
Definition: rapidxml.hpp:179
Ch * value() const
Definition: rapidxml.hpp:692
#define RAPIDXML_PARSE_ERROR(what, where)
Definition: rapidxml.hpp:55
static Ch * skip_and_expand_character_refs(Ch *&text)
Definition: rapidxml.hpp:1570
static unsigned char test(Ch ch)
Definition: rapidxml.hpp:1448
const int parse_normalize_whitespace
Definition: rapidxml.hpp:247
xml_attribute< Ch > * allocate_attribute(const Ch *name=0, const Ch *value=0, std::size_t name_size=0, std::size_t value_size=0)
Definition: rapidxml.hpp:447
Ch * name() const
Definition: rapidxml.hpp:673
Here is the call graph for this function:

◆ parse_node_contents()

void parse_node_contents ( Ch *&  text,
xml_node< Ch > *  node 
)
inlineprivate

Definition at line 2167 of file rapidxml.hpp.

2168  {
2169  // For all children and text
2170  while (1)
2171  {
2172  // Skip whitespace between > and node contents
2173  Ch *contents_start = text; // Store start of node contents before whitespace is skipped
2174  skip<whitespace_pred, Flags>(text);
2175  Ch next_char = *text;
2176 
2177  // After data nodes, instead of continuing the loop, control jumps here.
2178  // This is because zero termination inside parse_and_append_data() function
2179  // would wreak havoc with the above code.
2180  // Also, skipping whitespace after data nodes is unnecessary.
2181  after_data_node:
2182 
2183  // Determine what comes next: node closing, child node, data node, or 0?
2184  switch (next_char)
2185  {
2186 
2187  // Node closing or child node
2188  case Ch('<'):
2189  if (text[1] == Ch('/'))
2190  {
2191  // Node closing
2192  text += 2; // Skip '</'
2193  if (Flags & parse_validate_closing_tags)
2194  {
2195  // Skip and validate closing tag name
2196  Ch *closing_name = text;
2197  skip<node_name_pred, Flags>(text);
2198  if (!internal::compare(node->name(), node->name_size(), closing_name, text - closing_name, true))
2199  RAPIDXML_PARSE_ERROR("invalid closing tag name", text);
2200  }
2201  else
2202  {
2203  // No validation, just skip name
2204  skip<node_name_pred, Flags>(text);
2205  }
2206  // Skip remaining whitespace after node name
2207  skip<whitespace_pred, Flags>(text);
2208  if (*text != Ch('>'))
2209  RAPIDXML_PARSE_ERROR("expected >", text);
2210  ++text; // Skip '>'
2211  return; // Node closed, finished parsing contents
2212  }
2213  else
2214  {
2215  // Child node
2216  ++text; // Skip '<'
2217  if (xml_node<Ch> *child = parse_node<Flags>(text))
2218  node->append_node(child);
2219  }
2220  break;
2221 
2222  // End of data - error
2223  case Ch('\0'):
2224  RAPIDXML_PARSE_ERROR("unexpected end of data", text);
2225 
2226  // Data node
2227  default:
2228  next_char = parse_and_append_data<Flags>(node, text, contents_start);
2229  goto after_data_node; // Bypass regular processing after data nodes
2230 
2231  }
2232  }
2233  }
#define RAPIDXML_PARSE_ERROR(what, where)
Definition: rapidxml.hpp:55
const int parse_validate_closing_tags
Definition: rapidxml.hpp:230
Here is the call graph for this function:

◆ parse_pi()

xml_node<Ch>* parse_pi ( Ch *&  text)
inlineprivate

Definition at line 1880 of file rapidxml.hpp.

1881  {
1882  // If creation of PI nodes is enabled
1883  if (Flags & parse_pi_nodes)
1884  {
1885  // Create pi node
1886  xml_node<Ch> *pi = this->allocate_node(node_pi);
1887 
1888  // Extract PI target name
1889  Ch *name = text;
1890  skip<node_name_pred, Flags>(text);
1891  if (text == name)
1892  RAPIDXML_PARSE_ERROR("expected PI target", text);
1893  pi->name(name, text - name);
1894 
1895  // Skip whitespace between pi target and pi
1896  skip<whitespace_pred, Flags>(text);
1897 
1898  // Remember start of pi
1899  Ch *value = text;
1900 
1901  // Skip to '?>'
1902  while (text[0] != Ch('?') || text[1] != Ch('>'))
1903  {
1904  if (*text == Ch('\0'))
1905  RAPIDXML_PARSE_ERROR("unexpected end of data", text);
1906  ++text;
1907  }
1908 
1909  // Set pi value (verbatim, no entity expansion or whitespace normalization)
1910  pi->value(value, text - value);
1911 
1912  // Place zero terminator after name and value
1913  if (!(Flags & parse_no_string_terminators))
1914  {
1915  pi->name()[pi->name_size()] = Ch('\0');
1916  pi->value()[pi->value_size()] = Ch('\0');
1917  }
1918 
1919  text += 2; // Skip '?>'
1920  return pi;
1921  }
1922  else
1923  {
1924  // Skip to '?>'
1925  while (text[0] != Ch('?') || text[1] != Ch('>'))
1926  {
1927  if (*text == Ch('\0'))
1928  RAPIDXML_PARSE_ERROR("unexpected end of data", text);
1929  ++text;
1930  }
1931  text += 2; // Skip '?>'
1932  return 0;
1933  }
1934  }
const int parse_no_string_terminators
Definition: rapidxml.hpp:179
xml_node< Ch > * 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)
Definition: rapidxml.hpp:415
Ch * value() const
Definition: rapidxml.hpp:692
#define RAPIDXML_PARSE_ERROR(what, where)
Definition: rapidxml.hpp:55
A PI node. Name contains target. Value contains instructions.
Definition: rapidxml.hpp:152
const int parse_pi_nodes
Definition: rapidxml.hpp:222
Ch * name() const
Definition: rapidxml.hpp:673
Here is the call graph for this function:

◆ parse_xml_declaration()

xml_node<Ch>* parse_xml_declaration ( Ch *&  text)
inlineprivate

Definition at line 1738 of file rapidxml.hpp.

1739  {
1740  // If parsing of declaration is disabled
1741  if (!(Flags & parse_declaration_node))
1742  {
1743  // Skip until end of declaration
1744  while (text[0] != Ch('?') || text[1] != Ch('>'))
1745  {
1746  if (!text[0])
1747  RAPIDXML_PARSE_ERROR("unexpected end of data", text);
1748  ++text;
1749  }
1750  text += 2; // Skip '?>'
1751  return 0;
1752  }
1753 
1754  // Create declaration
1755  xml_node<Ch> *declaration = this->allocate_node(node_declaration);
1756 
1757  // Skip whitespace before attributes or ?>
1758  skip<whitespace_pred, Flags>(text);
1759 
1760  // Parse declaration attributes
1761  parse_node_attributes<Flags>(text, declaration);
1762 
1763  // Skip ?>
1764  if (text[0] != Ch('?') || text[1] != Ch('>'))
1765  RAPIDXML_PARSE_ERROR("expected ?>", text);
1766  text += 2;
1767 
1768  return declaration;
1769  }
xml_node< Ch > * 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)
Definition: rapidxml.hpp:415
#define RAPIDXML_PARSE_ERROR(what, where)
Definition: rapidxml.hpp:55
A declaration node. Name and value are empty. Declaration parameters (version, encoding and standalon...
Definition: rapidxml.hpp:150
const int parse_declaration_node
Definition: rapidxml.hpp:200

◆ prepend_attribute()

void prepend_attribute ( xml_attribute< Ch > *  attribute)
inlineinherited

Prepends a new attribute to the node.

Parameters
attributeAttribute to prepend.

Definition at line 1197 of file rapidxml.hpp.

1198  {
1199  assert(attribute && !attribute->parent());
1200  if (first_attribute())
1201  {
1202  attribute->m_next_attribute = m_first_attribute;
1203  m_first_attribute->m_prev_attribute = attribute;
1204  }
1205  else
1206  {
1207  attribute->m_next_attribute = 0;
1208  m_last_attribute = attribute;
1209  }
1210  m_first_attribute = attribute;
1211  attribute->m_parent = this;
1212  attribute->m_prev_attribute = 0;
1213  }
xml_attribute< Ch > * m_last_attribute
Definition: rapidxml.hpp:1341
xml_attribute< Ch > * m_first_attribute
Definition: rapidxml.hpp:1340
xml_attribute< Ch > * first_attribute(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const
Definition: rapidxml.hpp:1025
Here is the call graph for this function:

◆ prepend_node()

void prepend_node ( xml_node< Ch > *  child)
inlineinherited

Prepends a new child node. The prepended child becomes the first child, and all existing children are moved one position back.

Parameters
childNode to prepend.

Definition at line 1076 of file rapidxml.hpp.

1077  {
1078  assert(child && !child->parent() && child->type() != node_document);
1079  if (first_node())
1080  {
1081  child->m_next_sibling = m_first_node;
1082  m_first_node->m_prev_sibling = child;
1083  }
1084  else
1085  {
1086  child->m_next_sibling = 0;
1087  m_last_node = child;
1088  }
1089  m_first_node = child;
1090  child->m_parent = this;
1091  child->m_prev_sibling = 0;
1092  }
xml_node< Ch > * m_first_node
Definition: rapidxml.hpp:1338
xml_node< Ch > * m_last_node
Definition: rapidxml.hpp:1339
A document node. Name and value are empty.
Definition: rapidxml.hpp:145
xml_node< Ch > * first_node(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const
Definition: rapidxml.hpp:936
Here is the call graph for this function:

◆ previous_sibling()

xml_node<Ch>* previous_sibling ( const Ch *  name = 0,
std::size_t  name_size = 0,
bool  case_sensitive = true 
) const
inlineinherited

Gets previous sibling node, optionally matching node name. Behaviour is undefined if node has no parent. Use parent() to test if node has a parent.

Parameters
nameName of sibling to find, or 0 to return previous sibling regardless of its name; this string doesn't have to be zero-terminated if name_size is non-zero
name_sizeSize of name, in characters, or 0 to have size calculated automatically from string
case_sensitiveShould name comparison be case-sensitive; non case-sensitive comparison works properly only for ASCII characters
Returns
Pointer to found sibling, or 0 if not found.

Definition at line 981 of file rapidxml.hpp.

982  {
983  assert(this->m_parent); // Cannot query for siblings if node has no parent
984  if (name)
985  {
986  if (name_size == 0)
987  name_size = internal::measure(name);
988  for (xml_node<Ch> *sibling = m_prev_sibling; sibling; sibling = sibling->m_prev_sibling)
989  if (internal::compare(sibling->name(), sibling->name_size(), name, name_size, case_sensitive))
990  return sibling;
991  return 0;
992  }
993  else
994  return m_prev_sibling;
995  }
xml_node< Ch > * m_parent
Definition: rapidxml.hpp:788
xml_node< Ch > * m_prev_sibling
Definition: rapidxml.hpp:1342
Ch * name() const
Definition: rapidxml.hpp:673
std::size_t name_size() const
Definition: rapidxml.hpp:681
Here is the caller graph for this function:

◆ remove_all_attributes()

void remove_all_attributes ( )
inlineinherited

Removes all attributes of node.

Definition at line 1309 of file rapidxml.hpp.

1310  {
1311  for (xml_attribute<Ch> *attribute = first_attribute(); attribute; attribute = attribute->m_next_attribute)
1312  attribute->m_parent = 0;
1313  m_first_attribute = 0;
1314  }
xml_attribute< Ch > * m_first_attribute
Definition: rapidxml.hpp:1340
xml_attribute< Ch > * first_attribute(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const
Definition: rapidxml.hpp:1025

◆ remove_all_nodes()

void remove_all_nodes ( )
inlineinherited

Removes all child nodes (but not attributes).

Definition at line 1188 of file rapidxml.hpp.

1189  {
1190  for (xml_node<Ch> *node = first_node(); node; node = node->m_next_sibling)
1191  node->m_parent = 0;
1192  m_first_node = 0;
1193  }
xml_node< Ch > * m_first_node
Definition: rapidxml.hpp:1338
xml_node< Ch > * first_node(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const
Definition: rapidxml.hpp:936

◆ remove_attribute()

void remove_attribute ( xml_attribute< Ch > *  where)
inlineinherited

Removes specified attribute from node.

Parameters
wherePointer to attribute to be removed.

Definition at line 1293 of file rapidxml.hpp.

1294  {
1295  assert(first_attribute() && where->parent() == this);
1296  if (where == m_first_attribute)
1298  else if (where == m_last_attribute)
1300  else
1301  {
1302  where->m_prev_attribute->m_next_attribute = where->m_next_attribute;
1303  where->m_next_attribute->m_prev_attribute = where->m_prev_attribute;
1304  where->m_parent = 0;
1305  }
1306  }
void remove_first_attribute()
Definition: rapidxml.hpp:1260
xml_attribute< Ch > * m_last_attribute
Definition: rapidxml.hpp:1341
void remove_last_attribute()
Definition: rapidxml.hpp:1277
xml_attribute< Ch > * m_first_attribute
Definition: rapidxml.hpp:1340
xml_attribute< Ch > * first_attribute(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const
Definition: rapidxml.hpp:1025
Here is the call graph for this function:

◆ remove_first_attribute()

void remove_first_attribute ( )
inlineinherited

Removes first attribute of the node. If node has no attributes, behaviour is undefined. Use first_attribute() to test if node has attributes.

Definition at line 1260 of file rapidxml.hpp.

1261  {
1262  assert(first_attribute());
1263  xml_attribute<Ch> *attribute = m_first_attribute;
1264  if (attribute->m_next_attribute)
1265  {
1266  attribute->m_next_attribute->m_prev_attribute = 0;
1267  }
1268  else
1269  m_last_attribute = 0;
1270  attribute->m_parent = 0;
1271  m_first_attribute = attribute->m_next_attribute;
1272  }
xml_attribute< Ch > * m_last_attribute
Definition: rapidxml.hpp:1341
xml_attribute< Ch > * m_first_attribute
Definition: rapidxml.hpp:1340
xml_attribute< Ch > * first_attribute(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const
Definition: rapidxml.hpp:1025

◆ remove_first_node()

void remove_first_node ( )
inlineinherited

Removes first child node. If node has no children, behaviour is undefined. Use first_node() to test if node has children.

Definition at line 1140 of file rapidxml.hpp.

1141  {
1142  assert(first_node());
1143  xml_node<Ch> *child = m_first_node;
1144  m_first_node = child->m_next_sibling;
1145  if (child->m_next_sibling)
1146  child->m_next_sibling->m_prev_sibling = 0;
1147  else
1148  m_last_node = 0;
1149  child->m_parent = 0;
1150  }
xml_node< Ch > * m_first_node
Definition: rapidxml.hpp:1338
xml_node< Ch > * m_last_node
Definition: rapidxml.hpp:1339
xml_node< Ch > * first_node(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const
Definition: rapidxml.hpp:936

◆ remove_last_attribute()

void remove_last_attribute ( )
inlineinherited

Removes last attribute of the node. If node has no attributes, behaviour is undefined. Use first_attribute() to test if node has attributes.

Definition at line 1277 of file rapidxml.hpp.

1278  {
1279  assert(first_attribute());
1280  xml_attribute<Ch> *attribute = m_last_attribute;
1281  if (attribute->m_prev_attribute)
1282  {
1283  attribute->m_prev_attribute->m_next_attribute = 0;
1284  m_last_attribute = attribute->m_prev_attribute;
1285  }
1286  else
1287  m_first_attribute = 0;
1288  attribute->m_parent = 0;
1289  }
xml_attribute< Ch > * m_last_attribute
Definition: rapidxml.hpp:1341
xml_attribute< Ch > * m_first_attribute
Definition: rapidxml.hpp:1340
xml_attribute< Ch > * first_attribute(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const
Definition: rapidxml.hpp:1025

◆ remove_last_node()

void remove_last_node ( )
inlineinherited

Removes last child of the node. If node has no children, behaviour is undefined. Use first_node() to test if node has children.

Definition at line 1155 of file rapidxml.hpp.

1156  {
1157  assert(first_node());
1158  xml_node<Ch> *child = m_last_node;
1159  if (child->m_prev_sibling)
1160  {
1161  m_last_node = child->m_prev_sibling;
1162  child->m_prev_sibling->m_next_sibling = 0;
1163  }
1164  else
1165  m_first_node = 0;
1166  child->m_parent = 0;
1167  }
xml_node< Ch > * m_first_node
Definition: rapidxml.hpp:1338
xml_node< Ch > * m_last_node
Definition: rapidxml.hpp:1339
xml_node< Ch > * first_node(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const
Definition: rapidxml.hpp:936

◆ remove_node()

void remove_node ( xml_node< Ch > *  where)
inlineinherited

Removes specified child from the node.

Definition at line 1171 of file rapidxml.hpp.

1172  {
1173  assert(where && where->parent() == this);
1174  assert(first_node());
1175  if (where == m_first_node)
1177  else if (where == m_last_node)
1178  remove_last_node();
1179  else
1180  {
1181  where->m_prev_sibling->m_next_sibling = where->m_next_sibling;
1182  where->m_next_sibling->m_prev_sibling = where->m_prev_sibling;
1183  where->m_parent = 0;
1184  }
1185  }
void remove_first_node()
Definition: rapidxml.hpp:1140
xml_node< Ch > * m_first_node
Definition: rapidxml.hpp:1338
xml_node< Ch > * m_last_node
Definition: rapidxml.hpp:1339
xml_node< Ch > * first_node(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const
Definition: rapidxml.hpp:936
Here is the call graph for this function:

◆ set_allocator()

void set_allocator ( alloc_func *  af,
free_func *  ff 
)
inlineinherited

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
afAllocation function, or 0 to restore default function
ffFree function, or 0 to restore default function

Definition at line 552 of file rapidxml.hpp.

553  {
554  assert(m_begin == m_static_memory && m_ptr == align(m_begin)); // Verify that no memory is allocated yet
555  m_alloc_func = af;
556  m_free_func = ff;
557  }
char m_static_memory[RAPIDXML_STATIC_POOL_SIZE]
Definition: rapidxml.hpp:636
char * align(char *ptr)
Definition: rapidxml.hpp:573
alloc_func * m_alloc_func
Definition: rapidxml.hpp:637
free_func * m_free_func
Definition: rapidxml.hpp:638

◆ skip()

static void skip ( Ch *&  text)
inlinestaticprivate

Definition at line 1558 of file rapidxml.hpp.

1559  {
1560  Ch *tmp = text;
1561  while (StopPred::test(*tmp))
1562  ++tmp;
1563  text = tmp;
1564  }

◆ skip_and_expand_character_refs()

static Ch* skip_and_expand_character_refs ( Ch *&  text)
inlinestaticprivate

Definition at line 1570 of file rapidxml.hpp.

1571  {
1572  // If entity translation, whitespace condense and whitespace trimming is disabled, use plain skip
1573  if (Flags & parse_no_entity_translation &&
1574  !(Flags & parse_normalize_whitespace) &&
1575  !(Flags & parse_trim_whitespace))
1576  {
1577  skip<StopPred, Flags>(text);
1578  return text;
1579  }
1580 
1581  // Use simple skip until first modification is detected
1582  skip<StopPredPure, Flags>(text);
1583 
1584  // Use translation skip
1585  Ch *src = text;
1586  Ch *dest = src;
1587  while (StopPred::test(*src))
1588  {
1589  // If entity translation is enabled
1590  if (!(Flags & parse_no_entity_translation))
1591  {
1592  // Test if replacement is needed
1593  if (src[0] == Ch('&'))
1594  {
1595  switch (src[1])
1596  {
1597 
1598  // &amp; &apos;
1599  case Ch('a'):
1600  if (src[2] == Ch('m') && src[3] == Ch('p') && src[4] == Ch(';'))
1601  {
1602  *dest = Ch('&');
1603  ++dest;
1604  src += 5;
1605  continue;
1606  }
1607  if (src[2] == Ch('p') && src[3] == Ch('o') && src[4] == Ch('s') && src[5] == Ch(';'))
1608  {
1609  *dest = Ch('\'');
1610  ++dest;
1611  src += 6;
1612  continue;
1613  }
1614  break;
1615 
1616  // &quot;
1617  case Ch('q'):
1618  if (src[2] == Ch('u') && src[3] == Ch('o') && src[4] == Ch('t') && src[5] == Ch(';'))
1619  {
1620  *dest = Ch('"');
1621  ++dest;
1622  src += 6;
1623  continue;
1624  }
1625  break;
1626 
1627  // &gt;
1628  case Ch('g'):
1629  if (src[2] == Ch('t') && src[3] == Ch(';'))
1630  {
1631  *dest = Ch('>');
1632  ++dest;
1633  src += 4;
1634  continue;
1635  }
1636  break;
1637 
1638  // &lt;
1639  case Ch('l'):
1640  if (src[2] == Ch('t') && src[3] == Ch(';'))
1641  {
1642  *dest = Ch('<');
1643  ++dest;
1644  src += 4;
1645  continue;
1646  }
1647  break;
1648 
1649  // &#...; - assumes ASCII
1650  case Ch('#'):
1651  if (src[2] == Ch('x'))
1652  {
1653  unsigned long code = 0;
1654  src += 3; // Skip &#x
1655  while (1)
1656  {
1657  unsigned char digit = internal::lookup_tables<0>::lookup_digits[static_cast<unsigned char>(*src)];
1658  if (digit == 0xFF)
1659  break;
1660  code = code * 16 + digit;
1661  ++src;
1662  }
1663  insert_coded_character<Flags>(dest, code); // Put character in output
1664  }
1665  else
1666  {
1667  unsigned long code = 0;
1668  src += 2; // Skip &#
1669  while (1)
1670  {
1671  unsigned char digit = internal::lookup_tables<0>::lookup_digits[static_cast<unsigned char>(*src)];
1672  if (digit == 0xFF)
1673  break;
1674  code = code * 10 + digit;
1675  ++src;
1676  }
1677  insert_coded_character<Flags>(dest, code); // Put character in output
1678  }
1679  if (*src == Ch(';'))
1680  ++src;
1681  else
1682  RAPIDXML_PARSE_ERROR("expected ;", src);
1683  continue;
1684 
1685  // Something else
1686  default:
1687  // Ignore, just copy '&' verbatim
1688  break;
1689 
1690  }
1691  }
1692  }
1693 
1694  // If whitespace condensing is enabled
1695  if (Flags & parse_normalize_whitespace)
1696  {
1697  // Test if condensing is needed
1698  if (whitespace_pred::test(*src))
1699  {
1700  *dest = Ch(' '); ++dest; // Put single space in dest
1701  ++src; // Skip first whitespace char
1702  // Skip remaining whitespace chars
1703  while (whitespace_pred::test(*src))
1704  ++src;
1705  continue;
1706  }
1707  }
1708 
1709  // No replacement, only copy character
1710  *dest++ = *src++;
1711 
1712  }
1713 
1714  // Return new end
1715  text = src;
1716  return dest;
1717 
1718  }
const int parse_trim_whitespace
Definition: rapidxml.hpp:238
#define RAPIDXML_PARSE_ERROR(what, where)
Definition: rapidxml.hpp:55
static unsigned char test(Ch ch)
Definition: rapidxml.hpp:1430
const int parse_no_entity_translation
Definition: rapidxml.hpp:186
const int parse_normalize_whitespace
Definition: rapidxml.hpp:247

◆ type() [1/2]

node_type type ( ) const
inlineinherited

Gets type of node.

Returns
Type of node.

Definition at line 913 of file rapidxml.hpp.

914  {
915  return m_type;
916  }
Here is the caller graph for this function:

◆ type() [2/2]

void type ( node_type  type)
inlineinherited

Sets type of node.

Parameters
typeType of node to set.

Definition at line 1065 of file rapidxml.hpp.

1066  {
1067  m_type = type;
1068  }
node_type type() const
Definition: rapidxml.hpp:913

◆ value() [1/3]

Ch* value ( ) const
inlineinherited

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 option was selected during parse.

Use value_size() function to determine length of the value.

Returns
Value of node, or empty string if node has no value.

Definition at line 692 of file rapidxml.hpp.

693  {
694  return m_value ? m_value : nullstr();
695  }
static Ch * nullstr()
Definition: rapidxml.hpp:778
Here is the caller graph for this function:

◆ value() [2/3]

void value ( const Ch *  value,
std::size_t  size 
)
inlineinherited

Sets value of node to a non zero-terminated string. See ownership_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 of the document to allocate the string - on destruction of the document the string will be automatically freed.

Size of value must be specified separately, because it does not have to be zero terminated. Use value(const Ch *) function to have the length automatically calculated (string must be zero terminated).

If an element has a child node of type node_data, it will take precedence over element value when printing. If you want to manipulate data of elements using values, use parser flag rapidxml::parse_no_data_nodes to prevent creation of data nodes by the parser.

Parameters
valuevalue of node to set. Does not have to be zero terminated.
sizeSize of value, in characters. This does not include zero terminator, if one is present.

Definition at line 751 of file rapidxml.hpp.

752  {
753  m_value = const_cast<Ch *>(value);
754  m_value_size = size;
755  }
Ch * value() const
Definition: rapidxml.hpp:692
std::size_t m_value_size
Definition: rapidxml.hpp:787

◆ value() [3/3]

void value ( const Ch *  value)
inlineinherited

Sets value of node to a zero-terminated string. See also ownership_of_strings and xml_node::value(const Ch *, std::size_t).

Parameters
valueVame of node to set. Must be zero terminated.

Definition at line 760 of file rapidxml.hpp.

761  {
762  this->value(value, internal::measure(value));
763  }
Ch * value() const
Definition: rapidxml.hpp:692

◆ value_size()

std::size_t value_size ( ) const
inlineinherited

Gets size of node value, not including terminator character. This function works correctly irrespective of whether value is or is not zero terminated.

Returns
Size of node value, in characters.

Definition at line 700 of file rapidxml.hpp.

701  {
702  return m_value ? m_value_size : 0;
703  }
std::size_t m_value_size
Definition: rapidxml.hpp:787
Here is the caller graph for this function:

Member Data Documentation

◆ m_name

Ch* m_name
protectedinherited

Definition at line 784 of file rapidxml.hpp.

◆ m_name_size

std::size_t m_name_size
protectedinherited

Definition at line 786 of file rapidxml.hpp.

◆ m_parent

xml_node<Ch>* m_parent
protectedinherited

Definition at line 788 of file rapidxml.hpp.

◆ m_value

Ch* m_value
protectedinherited

Definition at line 785 of file rapidxml.hpp.

◆ m_value_size

std::size_t m_value_size
protectedinherited

Definition at line 787 of file rapidxml.hpp.


The documentation for this class was generated from the following file: