IN2OSM  1.0.1
xml_attribute< Ch >

#include <rapidxml.hpp>

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

Public Member Functions

 xml_attribute ()
 
xml_document< Ch > * document () const
 
xml_attribute< Ch > * previous_attribute (const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const
 
xml_attribute< Ch > * next_attribute (const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const
 
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
 

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 Attributes

xml_attribute< Ch > * m_prev_attribute
 
xml_attribute< Ch > * m_next_attribute
 

Friends

class xml_node< Ch >
 

Detailed Description

template<class Ch = char>
class rapidxml::xml_attribute< Ch >

Class representing attribute node of XML document. Each attribute has name and value strings, which are available through name() and value() functions (inherited from xml_base). Note that after parse, both name and value of attribute will point to interior of source text used for parsing. Thus, this text must persist in memory for the lifetime of attribute.

Parameters
ChCharacter type to use.

Definition at line 138 of file rapidxml.hpp.

Constructor & Destructor Documentation

◆ xml_attribute()

xml_attribute ( )
inline

Constructs an empty attribute with the specified type. Consider using memory_pool of appropriate xml_document if allocating attributes manually.

Definition at line 810 of file rapidxml.hpp.

811  {
812  }

Member Function Documentation

◆ document()

xml_document<Ch>* document ( ) const
inline

Gets document of which attribute is a child.

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

Definition at line 819 of file rapidxml.hpp.

820  {
821  if (xml_node<Ch> *node = this->parent())
822  {
823  while (node->parent())
824  node = node->parent();
825  return node->type() == node_document ? static_cast<xml_document<Ch> *>(node) : 0;
826  }
827  else
828  return 0;
829  }
A document node. Name and value are empty.
Definition: rapidxml.hpp:145
xml_node< Ch > * parent() const
Definition: rapidxml.hpp:770
friend class xml_node< Ch >
Definition: rapidxml.hpp:801

◆ 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_attribute()

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

Gets next attribute, optionally matching attribute name.

Parameters
nameName of attribute to find, or 0 to return next 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 856 of file rapidxml.hpp.

857  {
858  if (name)
859  {
860  if (name_size == 0)
861  name_size = internal::measure(name);
862  for (xml_attribute<Ch> *attribute = m_next_attribute; attribute; attribute = attribute->m_next_attribute)
863  if (internal::compare(attribute->name(), attribute->name_size(), name, name_size, case_sensitive))
864  return attribute;
865  return 0;
866  }
867  else
868  return this->m_parent ? m_next_attribute : 0;
869  }
xml_node< Ch > * m_parent
Definition: rapidxml.hpp:788
xml_attribute< Ch > * m_next_attribute
Definition: rapidxml.hpp:874
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:

◆ previous_attribute()

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

Gets previous attribute, optionally matching attribute name.

Parameters
nameName 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_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 836 of file rapidxml.hpp.

837  {
838  if (name)
839  {
840  if (name_size == 0)
841  name_size = internal::measure(name);
842  for (xml_attribute<Ch> *attribute = m_prev_attribute; attribute; attribute = attribute->m_prev_attribute)
843  if (internal::compare(attribute->name(), attribute->name_size(), name, name_size, case_sensitive))
844  return attribute;
845  return 0;
846  }
847  else
848  return this->m_parent ? m_prev_attribute : 0;
849  }
xml_node< Ch > * m_parent
Definition: rapidxml.hpp:788
xml_attribute< Ch > * m_prev_attribute
Definition: rapidxml.hpp:873
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:

◆ 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:

Friends And Related Function Documentation

◆ xml_node< Ch >

friend class xml_node< Ch >
friend

Definition at line 801 of file rapidxml.hpp.

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_next_attribute

xml_attribute<Ch>* m_next_attribute
private

Definition at line 874 of file rapidxml.hpp.

◆ m_parent

xml_node<Ch>* m_parent
protectedinherited

Definition at line 788 of file rapidxml.hpp.

◆ m_prev_attribute

xml_attribute<Ch>* m_prev_attribute
private

Definition at line 873 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: