S3FC project page S3FC home page

Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

s3_xml_config Class Reference

Create a tree of s3_config_node s from an XML file. More...

#include <s3_xml_config.h>

Inheritance diagram for s3_xml_config:

Inheritance graph
[legend]
Collaboration diagram for s3_xml_config:

Collaboration graph
[legend]
List of all members.

Public Methods

 s3_xml_config (const std::string &n_config_file, bool create_file=false) throw (s3_generic_exception)
 This constructor takes a single parameter which specify the XML file to parse. More...

 ~s3_xml_config ()
 Free all allocated objects. More...

s3_config_nodeget_rootnode () const
 Return the root node. More...

void refresh ()
 Refresh the configuration tree by reading the configuration file. More...

void set_config_file (const std::string &n_config_file)
 Set the configuration filename to the supplied argument. More...


Static Public Methods

void write_node (const std::string &filename, const s3_config_node &node)
 Save the configuration tree, rooted at node, as an XML file, named filename. More...

void write_node (std::ostream &os, const s3_config_node &node, unsigned int depth=0)
 Write the specified node, in XML format, to the supplied ostream, at the specified depth. More...

void write_spaces (std::ostream &os, unsigned int n)

Protected Methods

void dump_DOM_tree (const DOM_Node &domdoc) const
 Dump the parsed DOM tree to cerr. More...


Static Protected Methods

DOM_Document parse (const std::string &filename) throw (s3_generic_exception, s3_xml_exception)
 Parse an XML file into a DOM tree. More...

s3_config_nodebuild_tree (const DOM_Node &doc)
 Recursively build an s3_config_node tree from the supplied DOM document. More...

std::string get_name (const DOM_Node &node)
 Return the name of the DOM node as a string. More...

std::string get_value (const DOM_Node &node)
 Return the value of the DOM node as a string. More...

std::map< std::string, std::string > get_attributes (const DOM_Node &node)
 Return the attributes of the DOM node as a hash of strings. More...

std::vector< s3_config_node * > get_children (const DOM_Node &node)
 Return a list of pointers to orphaned child nodes. More...

std::string domstr_to_string (const DOMString &dstr)
 Convert the DOMString to a string. More...


Protected Attributes

std::string config_file
 The name of the XML config file to parse. More...

DOM_Document doc
 The DOM document tree of the parsed XML file. More...

s3_config_noderootnode
 The rootnode. More...


Friends

class error_handler

Detailed Description

Create a tree of s3_config_node s from an XML file.

Definition at line 70 of file s3_xml_config.h.


Constructor & Destructor Documentation

s3_xml_config::s3_xml_config const std::string &    n_config_file,
bool    create_file = false
throw (s3_generic_exception)
 

This constructor takes a single parameter which specify the XML file to parse.

The constructor will read the file, parse it and then store the result in a DOM tree.

Parameters:
n_config_file  The name of the XML file that will be parsed.
n_create_file  If the XML file does exist, should it be created? [false]

Definition at line 45 of file s3_xml_config.cc.

References S3FC_DBG.

s3_xml_config::~s3_xml_config  
 

Free all allocated objects.

Definition at line 82 of file s3_xml_config.cc.

References domstr_to_string, rootnode, and S3FC_DBG.


Member Function Documentation

s3_config_node * s3_xml_config::build_tree const DOM_Node &    node [static, protected]
 

Recursively build an s3_config_node tree from the supplied DOM document.

You have been warned...

Definition at line 245 of file s3_xml_config.cc.

References get_attributes, get_children, get_name, and get_value.

Referenced by get_children, and refresh.

std::string s3_xml_config::domstr_to_string const DOMString &    dstr [static, protected]
 

Convert the DOMString to a string.

Parameters:
dstr  DOMString string.
Returns:
string representation of dstr.

Definition at line 346 of file s3_xml_config.cc.

Referenced by s3_xml_config::error_handler::assemble_and_throw, get_attributes, get_name, get_value, and ~s3_xml_config.

void s3_xml_config::dump_DOM_tree const DOM_Node &    domdoc const [protected]
 

Dump the parsed DOM tree to cerr.

std::map< std::string, std::string > s3_xml_config::get_attributes const DOM_Node &    node [static, protected]
 

Return the attributes of the DOM node as a hash of strings.

Parameters:
node  DOM node.
Returns:
Attributes as name:value pairs.

Definition at line 308 of file s3_xml_config.cc.

References domstr_to_string.

Referenced by build_tree.

std::vector< s3_config_node * > s3_xml_config::get_children const DOM_Node &    node [static, protected]
 

Return a list of pointers to orphaned child nodes.

The caller owns the instances pointed to.

Returns:
List of orphaned children.

Definition at line 329 of file s3_xml_config.cc.

References build_tree.

Referenced by build_tree.

std::string s3_xml_config::get_name const DOM_Node &    node [static, protected]
 

Return the name of the DOM node as a string.

Parameters:
node  DOM node.
Returns:
Name of node as string.

Definition at line 269 of file s3_xml_config.cc.

References domstr_to_string.

Referenced by build_tree.

s3_config_node & s3_xml_config::get_rootnode   const [virtual]
 

Return the root node.

Implements s3_config_base.

Definition at line 103 of file s3_xml_config.cc.

References rootnode.

std::string s3_xml_config::get_value const DOM_Node &    node [static, protected]
 

Return the value of the DOM node as a string.

The value is the concatenation of the values of all the text nodes, with runs of white space removed.

Parameters:
node  DOM node.
Returns:
Value of node as string.

Definition at line 276 of file s3_xml_config.cc.

References domstr_to_string.

Referenced by build_tree.

DOM_Document s3_xml_config::parse const std::string &    filename throw (s3_generic_exception, s3_xml_exception) [static, protected]
 

Parse an XML file into a DOM tree.

Returns:
A DOM document representing the XML file.

Definition at line 176 of file s3_xml_config.cc.

Referenced by refresh.

void s3_xml_config::refresh   [virtual]
 

Refresh the configuration tree by reading the configuration file.

Any nodes previously obtained from this instance should be regarded as invalid after this call returns.

Implements s3_config_base.

Definition at line 108 of file s3_xml_config.cc.

References build_tree, config_file, doc, parse, and rootnode.

void s3_xml_config::set_config_file const std::string &    n_config_file
 

Set the configuration filename to the supplied argument.

Parameters:
Configuration  filename.

Definition at line 120 of file s3_xml_config.cc.

References config_file.

void s3_xml_config::write_node std::ostream &    os,
const s3_config_node   node,
unsigned int    depth = 0
[static]
 

Write the specified node, in XML format, to the supplied ostream, at the specified depth.

Invoke this function recursively on all children.

Parameters:
os  ostream object
node  Node to write to os.
depth  Recursion depth (optional - default: 0)

Definition at line 135 of file s3_xml_config.cc.

References s3_config_node::get_attributes, s3_config_node::get_child, s3_config_node::get_name, s3_config_node::get_num_children, s3_config_node::get_value, write_node, and write_spaces.

void s3_xml_config::write_node const std::string &    filename,
const s3_config_node   node
[static]
 

Save the configuration tree, rooted at node, as an XML file, named filename.

Definition at line 126 of file s3_xml_config.cc.

Referenced by write_node.

void s3_xml_config::write_spaces std::ostream &    os,
unsigned int    n
[static]
 

Definition at line 165 of file s3_xml_config.cc.

Referenced by write_node.


Friends And Related Function Documentation

friend class error_handler [friend]
 

Definition at line 221 of file s3_xml_config.h.


Member Data Documentation

std::string s3_xml_config::config_file [protected]
 

The name of the XML config file to parse.

Definition at line 76 of file s3_xml_config.h.

Referenced by refresh, and set_config_file.

DOM_Document s3_xml_config::doc [protected]
 

The DOM document tree of the parsed XML file.

The derived classes will use this instance variable directly.

Definition at line 81 of file s3_xml_config.h.

Referenced by refresh.

s3_config_node* s3_xml_config::rootnode [protected]
 

The rootnode.

Definition at line 85 of file s3_xml_config.h.

Referenced by get_rootnode, refresh, and ~s3_xml_config.


The documentation for this class was generated from the following files:
Send comments to: s3fc@stonethree.com SourceForge Logo