attributes Class Reference
[XML helpers]

#include <attributes.hpp>

List of all members.


Detailed Description

A simple class to contain attributes of a tag.

This class can read and write attributes for an XML tag. This class contain :

  • a map ((uri,name),value)
  • a map (uri, short_cut)

the short_cut for the default uri is an empty string.

Definition at line 134 of file attributes.hpp.

Public Types

typedef xstring attribute_type
typedef map_type::const_iterator const_iterator
typedef map_type::iterator iterator
typedef map_uri_type::const_iterator const_ns_iterator
typedef map_uri_type::iterator ns_iterator

Public Member Functions

 attributes ()
 attributes (attributes const &rhs)
 ~attributes ()
void swap (attributes &rhs) throw ()
 Exchange the contents of this object and the right-hand-side one.

attributesoperator= (attributes const &rhs)
 Assignment operator based on swap.

void clear ()
 delete all members.

size_t size () const
 number of attributes

attributesoperator+= (attributes const &rhs)
 add attributes.

const_ns_iterator find_namespace (xstring const &short_ns) const
 Find a namespace (uri) for a given short cut.

const_ns_iterator find_short_namespace (xstring const &uri) const
 Find a short cut for a full namespace (uri).

std::pair< ns_iterator, bool > insert_namespace (xstring const &short_ns, xstring const &uri)
 Insert a namespace mapping.

const_ns_iterator find_namespace () const
 Find the default namespace.

void set_namespace (xstring const &uri)
 Set the default namespace.

std::pair< iterator, bool > insert (xstring const &namespace_name, xstring const &name, xstring const &value)
 Insert an attribute.

void set (xstring const &namespace_name, xstring const &name, xstring const &value)
 Set an attribute.

const_iterator find (xstring const &namespace_name, xstring const &name) const
 Get an attribute.

xostreamwrite (xostream &xos) const
 PutTo operator.

xistreamread (xistream &xis)
 GetFrom operator.

iterator
iterator begin ()
const_iterator begin () const
iterator end ()
const_iterator end () const
ns_iterator ns_begin ()
const_ns_iterator ns_begin () const
ns_iterator ns_end ()
const_ns_iterator ns_end () const


Member Typedef Documentation

typedef xstring attributes::attribute_type
 

Definition at line 136 of file attributes.hpp.

typedef map_type::const_iterator attributes::const_iterator
 

Definition at line 149 of file attributes.hpp.

Referenced by begin(), end(), operator+=(), and write().

typedef map_uri_type::const_iterator attributes::const_ns_iterator
 

Definition at line 152 of file attributes.hpp.

Referenced by find(), find_namespace(), insert(), ns_begin(), ns_end(), operator+=(), read(), and write().

typedef map_type::iterator attributes::iterator
 

Definition at line 150 of file attributes.hpp.

Referenced by begin(), end(), and read().

typedef map_uri_type::iterator attributes::ns_iterator
 

Definition at line 153 of file attributes.hpp.

Referenced by ns_begin(), and ns_end().


Constructor & Destructor Documentation

attributes::attributes  ) 
 

Definition at line 117 of file attributes.cpp.

attributes::attributes attributes const &  rhs  ) 
 

Definition at line 123 of file attributes.cpp.

attributes::~attributes  ) 
 

Definition at line 131 of file attributes.cpp.


Member Function Documentation

const_iterator attributes::begin  )  const [inline]
 

Definition at line 194 of file attributes.hpp.

References const_iterator.

iterator attributes::begin  )  [inline]
 

Definition at line 193 of file attributes.hpp.

References iterator.

Referenced by operator+=(), and write().

void attributes::clear  ) 
 

delete all members.

Definition at line 148 of file attributes.cpp.

Referenced by read().

const_iterator attributes::end  )  const [inline]
 

Definition at line 197 of file attributes.hpp.

References const_iterator.

iterator attributes::end  )  [inline]
 

Definition at line 196 of file attributes.hpp.

References iterator.

Referenced by operator+=(), and write().

attributes::const_iterator attributes::find xstring const &  namespace_name,
xstring const &  name
const
 

Get an attribute.

Parameters:
namespace_name  Can be the uri or a short cut
name  The name of the attribute

Definition at line 237 of file attributes.cpp.

References const_ns_iterator, find_namespace(), ns_end(), and xstring.

const_ns_iterator attributes::find_namespace  )  const [inline]
 

Find the default namespace.

Definition at line 228 of file attributes.hpp.

References const_ns_iterator.

Referenced by find(), insert(), insert_namespace(), and read().

attributes::const_ns_iterator attributes::find_namespace xstring const &  short_ns  )  const
 

Find a namespace (uri) for a given short cut.

Definition at line 177 of file attributes.cpp.

References xstring.

attributes::const_ns_iterator attributes::find_short_namespace xstring const &  uri  )  const
 

Find a short cut for a full namespace (uri).

Definition at line 184 of file attributes.cpp.

References xstring.

Referenced by insert_namespace(), and write().

std::pair< attributes::iterator, bool > attributes::insert xstring const &  namespace_name,
xstring const &  name,
xstring const &  value
 

Insert an attribute.

If the attribute does not exist, it set the value

Parameters:
namespace_name  Can be the uri or a short cut
name  The name of the attribute
value  To be completed: Should be a variant.

Definition at line 214 of file attributes.cpp.

References _(), const_ns_iterator, find_namespace(), is_ncname(), ns_end(), qname(), XIMOL_AS_ERROR, XIMOL_THROW, and xstring.

Referenced by operator+=(), read(), and set().

std::pair< attributes::ns_iterator, bool > attributes::insert_namespace xstring const &  short_ns,
xstring const &  uri
 

Insert a namespace mapping.

Definition at line 192 of file attributes.cpp.

References _(), find_namespace(), find_short_namespace(), is_ncname(), XIMOL_AS_ERROR, XIMOL_THROW, and xstring.

Referenced by operator+=(), and read().

const_ns_iterator attributes::ns_begin  )  const [inline]
 

Definition at line 201 of file attributes.hpp.

References const_ns_iterator.

ns_iterator attributes::ns_begin  )  [inline]
 

Definition at line 200 of file attributes.hpp.

References ns_iterator.

Referenced by operator+=(), and write().

const_ns_iterator attributes::ns_end  )  const [inline]
 

Definition at line 204 of file attributes.hpp.

References const_ns_iterator.

ns_iterator attributes::ns_end  )  [inline]
 

Definition at line 203 of file attributes.hpp.

References ns_iterator.

Referenced by find(), insert(), operator+=(), read(), and write().

attributes & attributes::operator+= attributes const &  rhs  ) 
 

add attributes.

This function add all the attributes and namespace. All value of the argument will replace the value of the cuurent object.

Definition at line 156 of file attributes.cpp.

References begin(), const_iterator, const_ns_iterator, end(), insert(), insert_namespace(), ns_begin(), and ns_end().

attributes& attributes::operator= attributes const &  rhs  )  [inline]
 

Assignment operator based on swap.

Definition at line 176 of file attributes.hpp.

References attributes.

xistream & attributes::read xistream xis  ) 
 

GetFrom operator.

Definition at line 288 of file attributes.cpp.

References clear(), const_ns_iterator, xistream::context, find_namespace(), xistream::get(), insert(), insert_namespace(), is_first_char_ncname(), iterator, ns_end(), xistream::putback(), read_attribute(), read_optionnal_space(), xchar_t, XIMOL_PARSER_USING_NAMESPACE, and xstring.

Referenced by operator>>().

void attributes::set xstring const &  namespace_name,
xstring const &  name,
xstring const &  value
 

Set an attribute.

Parameters:
namespace_name  Can be the uri or a short cut
name  The name of the attribute
value  To be completed: Should be a variant.

Definition at line 229 of file attributes.cpp.

References insert(), and xstring.

void attributes::set_namespace xstring const &  uri  )  [inline]
 

Set the default namespace.

Definition at line 231 of file attributes.hpp.

References xstring.

size_t attributes::size  )  const [inline]
 

number of attributes

Definition at line 188 of file attributes.hpp.

void attributes::swap attributes rhs  )  throw ()
 

Exchange the contents of this object and the right-hand-side one.

This is also a root of exception safety.

Definition at line 140 of file attributes.cpp.

xostream & attributes::write xostream xos  )  const
 

PutTo operator.

Definition at line 249 of file attributes.cpp.

References begin(), const_iterator, const_ns_iterator, xostream::context, end(), find_short_namespace(), ns_begin(), ns_end(), write_att_value(), write_attribute(), write_eq(), write_ns_att_name(), write_space(), XIMOL_PARSER_USING_NAMESPACE, and xstring.

Referenced by operator<<().


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


Donate to the XiMoL project SourceForge.net Logo If you have any questions about XiMoL, you could write to tournois@users.sourceforge.net.