xmlwrapp
Lightweight C++ XML parsing library
Classes | Public Types | Public Member Functions | List of all members
xml::attributes Class Reference

The xml::attributes class is used to access all the attributes of one xml::node. More...

#include <attributes.h>

Classes

class  attr
 The xml::attributes::attr class is used to hold information about one attribute. More...
 
class  const_iterator
 Const Iterator class for accessing attribute pairs. More...
 
class  iterator
 Iterator class for accessing attribute pairs. More...
 

Public Types

typedef std::size_t size_type
 size type More...
 

Public Member Functions

 attributes ()
 Create a new xml::attributes object with no attributes. More...
 
 attributes (const attributes &other)
 Copy construct a xml::attributes object. More...
 
attributesoperator= (const attributes &other)
 Copy the given xml::attributes object into this one. More...
 
void swap (attributes &other)
 Swap this xml::attributes object with another one. More...
 
iterator begin ()
 Get an iterator that points to the first attribute. More...
 
const_iterator begin () const
 Get a const_iterator that points to the first attribute. More...
 
iterator end ()
 Get an iterator that points one past the the last attribute. More...
 
const_iterator end () const
 Get a const_iterator that points one past the last attribute. More...
 
void insert (const char *name, const char *value)
 Add an attribute to the attributes list. More...
 
iterator find (const char *name)
 Find the attribute with the given name. More...
 
const_iterator find (const char *name) const
 Find the attribute with the given name. More...
 
iterator erase (iterator to_erase)
 Erase the attribute that is pointed to by the given iterator. More...
 
void erase (const char *name)
 Erase the attribute with the given name. More...
 
bool empty () const
 Find out if there are any attributes in this xml::attributes object. More...
 
size_type size () const
 Find out how many attributes there are in this xml::attributes object. More...
 

Detailed Description

The xml::attributes class is used to access all the attributes of one xml::node.

You can add, find and erase attributes by name, and for some member functions, use the provided iterator classes.

The iterator classes allow you to access one XML attribute. This is done using the xml::attributes::attr class interface.

Member Typedef Documentation

◆ size_type

typedef std::size_t xml::attributes::size_type

size type

Constructor & Destructor Documentation

◆ attributes() [1/2]

xml::attributes::attributes ( )

Create a new xml::attributes object with no attributes.

◆ attributes() [2/2]

xml::attributes::attributes ( const attributes other)

Copy construct a xml::attributes object.

Parameters
otherThe xml::attributes object to copy from.

Member Function Documentation

◆ begin() [1/2]

iterator xml::attributes::begin ( )

Get an iterator that points to the first attribute.

Returns
An iterator that points to the first attribute.
An iterator equal to end() if there are no attributes.
See also
xml::attributes::iterator
xml::attributes::attr

◆ begin() [2/2]

const_iterator xml::attributes::begin ( ) const

Get a const_iterator that points to the first attribute.

Returns
A const_iterator that points to the first attribute.
A const_iterator equal to end() if there are no attributes.
See also
xml::attributes::const_iterator
xml::attributes::attr

◆ empty()

bool xml::attributes::empty ( ) const

Find out if there are any attributes in this xml::attributes object.

Returns
True if there are no attributes.
False if there is at least one attribute.

◆ end() [1/2]

iterator xml::attributes::end ( )

Get an iterator that points one past the the last attribute.

Returns
An "end" iterator.

◆ end() [2/2]

const_iterator xml::attributes::end ( ) const

Get a const_iterator that points one past the last attribute.

Returns
An "end" const_iterator.

◆ erase() [1/2]

iterator xml::attributes::erase ( iterator  to_erase)

Erase the attribute that is pointed to by the given iterator.

This will invalidate any iterators for this attribute, as well as any pointers or references to it.

Parameters
to_eraseAn iterator that points to the attribute to erased.
Returns
An iterator that points to the attribute after the one to be erased.
See also
xml::attributes::iterator
xml::attributes::attr

◆ erase() [2/2]

void xml::attributes::erase ( const char *  name)

Erase the attribute with the given name.

This will invalidate any iterators that are pointing to that attribute, as well as any pointers or references to that attribute.

Parameters
nameThe name of the attribute to erase.

◆ find() [1/2]

iterator xml::attributes::find ( const char *  name)

Find the attribute with the given name.

If the attribute is not found on the current node, the DTD will be searched for a default value. This is, of course, if there was a DTD parsed with the XML document.

Parameters
nameThe name of the attribute to find.
Returns
An iterator that points to the attribute with the given name.
If the attribute was not found, find will return end().
See also
xml::attributes::iterator
xml::attributes::attr

◆ find() [2/2]

const_iterator xml::attributes::find ( const char *  name) const

Find the attribute with the given name.

If the attribute is not found on the current node, the DTD will be searched for a default value. This is, of course, if there was a DTD parsed with the XML document.

Parameters
nameThe name of the attribute to find.
Returns
A const_iterator that points to the attribute with the given name.
If the attribute was not found, find will return end().
See also
xml::attributes::const_iterator
xml::attributes::attr

◆ insert()

void xml::attributes::insert ( const char *  name,
const char *  value 
)

Add an attribute to the attributes list.

If there is another attribute with the same name, it will be replaced with this one.

Parameters
nameThe name of the attribute to add.
valueThe value of the attribute to add.

◆ operator=()

attributes& xml::attributes::operator= ( const attributes other)

Copy the given xml::attributes object into this one.

Parameters
otherThe xml::attributes object to copy from.
Returns
*this.

◆ size()

size_type xml::attributes::size ( ) const

Find out how many attributes there are in this xml::attributes object.

Returns
The number of attributes in this xml::attributes object.

◆ swap()

void xml::attributes::swap ( attributes other)

Swap this xml::attributes object with another one.

Parameters
otherThe other xml::attributes object to swap with.

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