Plus  - Minimal XML for C++ (Version 0.9.2) Giancarlo Niccolai
Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

MXML::Attribute Class Reference

Encapsulates an XML attribute. More...

#include <mxml_attribute.h>

Inheritance diagram for MXML::Attribute:

Inheritance graph
[legend]
Collaboration diagram for MXML::Attribute:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Attribute (std::istream &in, int style=0, int line=1, int pos=0)
 Deserializes an attribute Reads an attribute from an XML file at current position.

 Attribute (const std::string &name, const std::string &value)
 Attribute (Attribute &src)
const std::string name () const
 Returns current name of the attribute.

const std::string value () const
 Returns the value stored in the attribute.

void name (const std::string &new_name)
 Change name of the attribute.

void value (const std::string &new_value)
 Change value of the attribute.

virtual void write (std::ostream &out, const int style) const
 Writes the attribute on a stream.


Private Attributes

std::string m_name
 Name of the attribute.

std::string m_value
 Value of the attribute.


Detailed Description

Encapsulates an XML attribute.

This class represents the node attributes: <node_name attrib_name="attrib value">. The class has support for serializationa and de-serialization.


Constructor & Destructor Documentation

MXML::Attribute::Attribute std::istream &  in,
int  style = 0,
int  line = 1,
int  pos = 0
 

Deserializes an attribute Reads an attribute from an XML file at current position.

In case of error Throws an MXML::IOError or MXML::MalformedError.

Parameters:
in the input sream
style style bits; see MXML::Document::setStyle()
line the current line in the stream
pos the current position in line
Exceptions:
MXML::MalformedError if the attribute is invalid
MXML::IOError in case of hard errors on the stream

MXML::Attribute::Attribute const std::string &  name,
const std::string &  value
[inline]
 

MXML::Attribute::Attribute Attribute src  )  [inline]
 


Member Function Documentation

void MXML::Attribute::name const std::string &  new_name  )  [inline]
 

Change name of the attribute.

Todo:
check validity of the name and throw a malformed error if wrong.

const std::string MXML::Attribute::name  )  const [inline]
 

Returns current name of the attribute.

void MXML::Attribute::value const std::string &  new_value  )  [inline]
 

Change value of the attribute.

Todo:
check validity of the name and throw a malformed error if wrong.

const std::string MXML::Attribute::value  )  const [inline]
 

Returns the value stored in the attribute.

Parsing the value or transforming it to a proper type (i.e. integer) is left to the caller.

void MXML::Attribute::write std::ostream &  out,
const int  style
const [virtual]
 

Writes the attribute on a stream.

This function is usually called by MXML::Document::write(), or by the << operator (in class MXML::Element), use the latter only for debug.

Parameters:
stream the stream where the object will be written
style the style of the serialization

Implements MXML::Element.


Member Data Documentation

std::string MXML::Attribute::m_name [private]
 

Name of the attribute.

std::string MXML::Attribute::m_value [private]
 

Value of the attribute.


The documentation for this class was generated from the following files:
Generated on Sun Apr 11 02:08:21 2004 for Mxml Plus by doxygen 1.3.5