Main Page   Namespace List   Compound List   File List   Namespace Members   Compound Members   File Members   Examples  

DataXML::DataObject Class Reference

XML-streamable data object. More...

#include <DataObject.h>

Collaboration diagram for DataXML::DataObject:

Collaboration graph
[legend]
List of all members.

Public Methods

 DataObject ()
 data object must have non-empty names, use setName(). More...

 DataObject (std::string name)
 name must be non-empty. More...

name handling
std::string name () const
void setName (std::string name)
shortcuts for attribute handling
bool appendAttribute (std::string attr_name, std::string attr_val)
 append new attribute at end, false if name already exists. More...

void setAttribute (std::string attr_name, std::string attr_val)
 modify exisiting attribute or append new at end. More...

void removeAttribute (std::string attr_name)
 remove attribute. More...

std::string getAttributeValue (std::string attr_name) const
 return "" if not found. More...

shortcuts for children handling
void appendChild (const DataObject &elem)
 append child objects at end (vector::push_back()). More...

DataObject* getChild (std::string child_name)
 get the first child with given name return 0 if not found. More...

const DataObject* getChild (std::string child_name) const
 get the first child with given name return 0 if not found. More...

DataObject* firstChild ()
 return 0 if no childern. More...

const DataObject* firstChild () const
DataObject* lastChild ()
 return 0 if no children. More...

const DataObject* lastChild () const
shortcuts for text handling
void appendChildText (std::string text)
 append PCDATA text as a child object. More...

std::string getText () const
 get PCDATA, if 'this' is not text object return "". More...

direct manipulation of childern tree via STL vector
std::vector<DataObject>& children ()
const std::vector<DataObject>& children () const
direct manipulation of attributes via STL map
std::map<std::string,std::string>& attributes ()
const std::map<std::string,
std::string>& 
attributes () const

Static Public Methods

const DataObject& the_void_object ()

Private Attributes

std::string m_name
std::map<std::string,std::string> m_attr
std::vector<DataObject> m_child

Detailed Description

Data object provides an abstraction of simple data model (the tree of children and parents). The data object: DataObject represents XML element. In some cases it may also represent a markup-free text. DataObject::getText() may be used to check if data object represents text ("" means that it represents the element). TextDataObject() pseudo-constructor creates a text data object. You may also use the shortcut DataObject::appendChildText(). It makes no sense to modify attributes of text objects.

By-value object containment is supported. Reference semantics (pointer associations) are not yet supported.

Typically you create an instance of DataObject out of your own objects. Then you use it as a high-level interface to render to/from XML.

[To implement reference semantics we need to intorduce larger units (groups of objects) for which referential integrity is guaranteed. Maybe ref integrity domain could be a root data object. Optional object identifiers must also be provided.]

Examples:

dxml_copy_example.cpp, dxml_read_example.cpp, and dxml_write_example.cpp.

Definition at line 61 of file DataObject.h.


Constructor & Destructor Documentation

DataXML::DataObject::DataObject ( )
 

DataXML::DataObject::DataObject ( std::string name )
 


Member Function Documentation

bool DataXML::DataObject::appendAttribute ( std::string attr_name,
std::string attr_val )
 

void DataXML::DataObject::appendChild ( const DataObject & elem )
 

Examples:
dxml_write_example.cpp.

Referenced by main().

void DataXML::DataObject::appendChildText ( std::string text )
 

Examples:
dxml_write_example.cpp.

Referenced by main().

const std::map< std::string, std::string > & DataXML::DataObject::attributes<std::string,std::string> ( ) const
 

std::map< std::string, std::string > & DataXML::DataObject::attributes ( )
 

const std::vector< DataObject > & DataXML::DataObject::children<DataObject> ( ) const
 

std::vector< DataObject > & DataXML::DataObject::children ( )
 

Examples:
dxml_read_example.cpp.

Referenced by main().

const DataObject * DataXML::DataObject::firstChild ( ) const
 

DataObject * DataXML::DataObject::firstChild ( )
 

std::string DataXML::DataObject::getAttributeValue ( std::string attr_name ) const
 

Examples:
dxml_read_example.cpp.

Referenced by main().

const DataObject * DataXML::DataObject::getChild ( std::string child_name ) const
 

DataObject * DataXML::DataObject::getChild ( std::string child_name )
 

Examples:
dxml_read_example.cpp.

Referenced by main().

std::string DataXML::DataObject::getText ( ) const
 

const DataObject * DataXML::DataObject::lastChild ( ) const
 

DataObject * DataXML::DataObject::lastChild ( )
 

std::string DataXML::DataObject::name ( ) const
 

Examples:
dxml_read_example.cpp.

Referenced by main().

void DataXML::DataObject::removeAttribute ( std::string attr_name )
 

void DataXML::DataObject::setAttribute ( std::string attr_name,
std::string attr_val )
 

Examples:
dxml_write_example.cpp.

Referenced by main().

void DataXML::DataObject::setName ( std::string name )
 

Examples:
dxml_write_example.cpp.

Referenced by main().

const DataObject & DataXML::DataObject::the_void_object ( ) [static]
 


Member Data Documentation

std::map< std::string, std::string > DataXML::DataObject::m_attr<std::string,std::string> [private]
 

Definition at line 149 of file DataObject.h.

std::vector< DataObject > DataXML::DataObject::m_child<DataObject> [private]
 

Definition at line 150 of file DataObject.h.

std::string DataXML::DataObject::m_name [private]
 

Definition at line 147 of file DataObject.h.


The documentation for this class was generated from the following file:
Generated at Tue Jan 28 15:35:29 2003 for DataXML by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001