ClearSilver::HDF Class Reference

Encapsulation of HDF dataset. More...

#include <HDF.h>

Inheritance diagram for ClearSilver::HDF:

ClearSilver::TraceObject ClearSilver::ConstHDFNode ClearSilver::HDFNode List of all members.

Public Types

typedef std::string Name
typedef std::string Name
STL type definitions
typedef size_t size_type
typedef forward_iterator_tag iterator_category
typedef HDF value_type
typedef ptrdiff_t difference_type
typedef HDFpointer
typedef HDF reference
typedef HDF iterator
typedef HDF const_reference
typedef HDF const_iterator

Public Member Functions

virtual ClearSilverNode node () const
 Access to the current node.
ClearSilverNode HDF::root () const
 Access the root node.
HDFAttributes attributes ()
 Access the node attributes.
void swap (HDF &) throw ()
 Swap contents with another object.
bool is_iterator () const
 Is this an iterator?
bool is_dataset () const
 Is this a dataset?
bool is_reference () const
 Is this a node within a dataset?
void sort (ClearSilverNodeComparator::Ptr)
 Sort the children of the current node.
Constructors
 HDF ()
 Default constructor.
 HDF (const char *path)
 Construct a dataset from a file.
 HDF (const std::string &path)
 Construct a dataset from a file.
 HDF (const RootNode &)
 Construct a dataset from a preexisting root node.
 HDF (const HDF &)
 Copy constructor.
 ~HDF () throw ()
 Destructor.
HDFoperator= (const HDF &)
 Assignment operator.
HDFoperator= (const char *value)
 Assign a new value to an HDF node.
HDFoperator= (const std::string &value)
 Assign a new value to an HDF node.
HDFoperator= (int value)
 Assign a new value to an HDF node.
HDFoperator= (bool value)
 Assign a new value to an HDF node.
HDFoperator= (const SymlinkTarget &)
 Create a symbolic link.
Inspectors
size_type depth () const
 Depth of current node from the root of the dataset.
std::string path () const
 Path to the current node from the root of the dataset.
Associative array interface
const_reference operator[] (const char *key) const
const_reference operator[] (const std::string &key) const
reference operator[] (const char *key)
reference operator[] (const std::string &key)
STL iterator constructors
const_iterator begin () const
const_iterator end () const
iterator begin ()
iterator end ()
const_iterator find (const char *key) const
const_iterator find (const std::string &key) const
iterator find (const char *key)
iterator find (const std::string &key)
Iterator methods
These methods provide the standard STL forward iteration interface.

iteratoroperator++ ()
iterator operator++ (int)
value_type operator * ()
 Dereference an iterator.
pointer operator-> ()
 Return a pointer to the current node.
HDFcopy (const HDF &dataset)
 Deep copy methods.
HDFcopy (const char *key, const HDF &dataset)
HDFcopy (const std::string &key, const HDF &dataset)
STL inspectors
bool empty () const
Conversions
 operator bool () const
 Is this a valid node?
 operator std::string () const
 Convert to the value of the node.
Node accessors
std::string name () const
 Name of the node.
std::string value () const
 Value of the node.
HDF dataset operations
These functions directly encapsulate the corresponding functions from the ClearSilver C API. Note that the values stored internally to represent boolean values correspond to the constants returned by True() and False().

std::string get_value () const
std::string get_value (const char *key) const
std::string get_value (const std::string &key) const
std::string get_value (const char *key, const char *default_value) const
std::string get_value (const std::string &key, const std::string &default_value) const
void write_file (const char *filename) const
void write_file (const std::string &filename) const
void dump () const
void dump (const char *prefix) const
void dump (const std::string &prefix) const
HDF dataset operations
Most of these functions directly encapsulate the corresponding functions from the ClearSilver C API. Note that the constants returned by ConstHDFNode::True() and ConstHDFNode::False() are used internally to represent the corresponding boolean values in the dataset.

void set_value (const char *value)
void set_value (const std::string &value)
void set_value (int value)
void set_value (bool value)
void set_value (const char *key, const char *value)
void set_value (const std::string &key, const std::string &value)
void set_value (const char *key, int value)
void set_value (const std::string &key, int value)
void set_value (const char *key, unsigned int value)
void set_value (const std::string &key, unsigned int value)
void set_value (const char *key, bool value)
void set_value (const std::string &key, bool value)
void read_file (const char *filename)
void read_file (const std::string &filename)
Delete subtree methods
Note that these methods invalidate any references and iterators referring to nodes within the deleted subtree.

void remove_tree (const char *key)
 Remove the subtree rooted at path.
void remove_tree (const std::string &key)
 Remove the subtree rooted at path.
void remove_tree (HDF &)
 Remove the subtree referenced by the HDF object.
void remove_cgi ()
 Delete the entire CGI environment from the HDF dataset.

Static Public Member Functions

static bool & debug ()
 Access the debug flag.
Boolean constants
These string values represent the boolean constants "true" and "false" within the dataset. This simplifies, for example, the comparison of node values expected to represent boolean values with a consistent set of contants.

static std::string Boolean (bool b)
static std::string True ()
static std::string False ()

Protected Member Functions

virtual Nodes nodes () const
virtual Nodesnodes ()
virtual void push (const ConstHDFNode::Name &, const ClearSilverNode &)
virtual void pop ()
virtual ClearSilverNode top () const
void swap (ConstHDFNode &) throw ()
 Swap contents with another object.
Nodes find_node (const std::string &) const
 Construct the path to a node.
bool & is_iterator ()
 Access the iterator flag.
void swap (HDFNode &) throw ()
 Swap contents with another object.

Friends

class ConstHDF
bool operator== (const reference &, const reference &)
 Equality comparison operator.

Classes

struct  forward_iterator_tag
struct  input_iterator_tag

Detailed Description

Encapsulation of HDF dataset.

This class provides one of the two primary interfaces to a ClearSilver (http://www.clearsilver.net/) HDF dataset. Specifically, it encapsulates a non-constant dataset; the other primary interface, the ConstHDF class, encapsulates a constant datset. Members provide access to data within the HDF dataset via accessor functions, via an associative array interface, and via an STL iterator interface. The same class is used for all of these interfaces in order to achieve a recursive interface, regardless of the current level of nesting within the dataset.

Definition at line 76 of file HDF.h.


Member Function Documentation

bool & ClearSilver::HDF::debug  )  [static]
 

Access the debug flag.

If the debug flag is true, syslog(3) messages with priority LOG_DEBUG will be logged.

Reimplemented from ClearSilver::ConstHDFNode.

Definition at line 468 of file HDF.cc.

Referenced by operator=().

bool & ClearSilver::ConstHDFNode::is_iterator  )  [protected, inherited]
 

Access the iterator flag.

The STL iterator constructors (e.g., begin() and end()) must set this flag appropriately in order for the assignment operator to differentiate between assigning the whole dataset in the case of an iterator or assigning the node value otherwise.

Definition at line 342 of file ConstHDFNode.cc.

Referenced by begin(), ClearSilver::ConstHDF::begin(), end(), ClearSilver::ConstHDF::end(), operator *(), ClearSilver::ConstHDF::operator *(), and operator=().

ClearSilver::HDF::value_type ClearSilver::HDF::operator *  ) 
 

Dereference an iterator.

This method interprets the current node as an iterator and dereferences it. Note that once dereferences, a node is no longer regarded as an iterator.

Definition at line 361 of file HDF.cc.

References ClearSilver::ConstHDFNode::is_iterator().

ClearSilver::HDF::pointer ClearSilver::HDF::operator->  ) 
 

Return a pointer to the current node.

This method interprets the current node as an iterator and returns a pointer to it.

Definition at line 369 of file HDF.cc.

ClearSilver::HDF::HDF & ClearSilver::HDF::operator= const SymlinkTarget  ) 
 

Create a symbolic link.

This method replaces the value of a node with a symbolic link to another target node (which need not exist in the dataset).

Definition at line 153 of file HDF.cc.

References path().

ClearSilver::HDF::HDF & ClearSilver::HDF::operator= bool  value  ) 
 

Assign a new value to an HDF node.

This method replaces the value of a node with a string version of its argument. Specifically, the value returned by the Boolean() method replaces the value of the node.

Definition at line 146 of file HDF.cc.

References ClearSilver::HDFNode::set_value().

ClearSilver::HDF::HDF & ClearSilver::HDF::operator= int  value  ) 
 

Assign a new value to an HDF node.

This method replaces the value of a node with its argument.

Definition at line 139 of file HDF.cc.

References ClearSilver::HDFNode::set_value().

ClearSilver::HDF::HDF & ClearSilver::HDF::operator= const std::string value  ) 
 

Assign a new value to an HDF node.

This method replaces the value of a node with its argument.

Bug:
Because the underlying ClearSilver C API provides no function analagous to assignment, the implementation of this method relies on the internals of the C data structures.

Definition at line 132 of file HDF.cc.

References ClearSilver::HDFNode::set_value().

ClearSilver::HDF::HDF & ClearSilver::HDF::operator= const char *  value  ) 
 

Assign a new value to an HDF node.

This method replaces the value of a node with its argument.

Definition at line 126 of file HDF.cc.

References operator=().

ClearSilver::HDF & ClearSilver::HDF::operator= const HDF  ) 
 

Assignment operator.

There are two distinct types of assignment semantics: assignment of an entire ClearSilver dataset and assignment of the value of a specific node within a dataset to another specific node. Both types of semantics are supported, depending on which of the following cases apply.

  • If both arguments represent the entire dataset (i.e., they do not contain a path leading to a specific node), assignment of the dataset occurs.
  • If both arguments represent iterators pointing to specific nodes (i.e., they do contain a path leading to a specific node and they were created with an iterator constructor (e.g., begin(), end(), or find())), assignment of the dataset occurs. This is equivalent to assigning the iterators, not the values they point to.
  • If both arguments represent a specific node (i.e., they do contain a path leading to a specific node and they were not created with an iterator constructor), assignment of the node value occurs.
  • Otherwise, an exception is thrown.

Definition at line 82 of file HDF.cc.

References std::basic_string< _CharT, _Traits, _Alloc >::c_str(), debug(), ClearSilver::ConstHDFNode::get_value(), ClearSilver::ConstHDFNode::is_dataset(), ClearSilver::ConstHDFNode::is_iterator(), ClearSilver::ConstHDFNode::is_reference(), ClearSilver::TraceObject::operator=(), ClearSilver::HDFNode::set_value(), and swap().

Referenced by operator=().

void ClearSilver::HDFNode::remove_cgi  )  [inherited]
 

Delete the entire CGI environment from the HDF dataset.

The CGI environment that is deleted includes nodes rooted at the following paths: CGI, HTTP, Query, and Cookie. Note that this method invalidates any references and iterators referring to nodes within the deleted subtrees.

Definition at line 173 of file HDFNode.cc.

References ClearSilver::HDFNode::remove_tree().


The documentation for this class was generated from the following files:
Generated on Tue May 16 14:50:54 2006 for ClearSilver C++ Library by  doxygen 1.4.5