Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

SSD::Doc Class Reference

Document wrapper class this class wraps around a document, in the current version only XML documents are supported, but other similar formats might be added later on (by making Doc an abstract class and deriving from it. More...

#include <doc.h>

Collaboration diagram for SSD::Doc:

Collaboration graph
[legend]
List of all members.

Public Member Functions

bool loadXML (const char *filename)
 load an XML document using libxml
void processXPath (char *xpath)
 build related-to data for a given xpath
 Doc ()
 create an empty doc object
void flushDoc ()
 drop document information
 ~Doc ()
 destructor
NodegetRoot () const
 return root node for document
xmlDocPtr getDOM () const
 return libxml DOM root node for document this is used in output writers for reconstruction
NodeVec::const_iterator getNodesIter () const
 access to const iterators of nodes list
NodeVec::const_iterator getNodesIterEnd () const

Public Attributes

NodeEqClassVec index_by_label
 index of nodes by label
std::set< void * > processed
 set of libxml nodes processed (i.e. not ignored whitespace etc.)
hash_map< xmlNodePtr, Node *,
hash< void * > > 
xml_to_node
 map to find the Node object for a given libxml node
hash_map< RelEqClass, int,
hash_releqc
relcount
 count of relations in file to calculate credits

Static Public Attributes

static bool useWhitespace = false
 flag wheter to ignore whitespace or not

Protected Member Functions

void walkTree (Node *pos, xmlNodePtr node)
 Walk the document tree recursively This will transform the libXML dom tree into a tree of SSD::Node objects.
NodeappendNodeElement (Node *parent, xmlNodePtr node)
 Make a new element Node.
NodeappendNodeText (Node *parent, xmlNodePtr node)
 Make a new "text" Node.
NodeappendNodeAttribute (Node *parent, xmlNodePtr node, xmlAttrPtr attr)
 Make a new "attribute" Node.
void add_to_index (Node *node)
 insert a node into the index structure
void add_to_processed (xmlNodePtr node)
 add an libxml node into the processed set
void walkTreeXPath (xmlXPathContextPtr xpathctx, xmlXPathCompExprPtr xpath, Node *node)
 walk document by using an xpath expression

Protected Attributes

Noderoot
 document root node
xmlDocPtr dom
 XML dom document tree for output reconstruction.
NodeVec nodes
 list containing all nodes in the document for iteration

Detailed Description

Document wrapper class this class wraps around a document, in the current version only XML documents are supported, but other similar formats might be added later on (by making Doc an abstract class and deriving from it.

Definition at line 38 of file doc.h.


Constructor & Destructor Documentation

SSD::Doc::Doc  ) 
 

create an empty doc object

Definition at line 253 of file doc.cc.

SSD::Doc::~Doc  ) 
 

destructor

Definition at line 248 of file doc.cc.

References flushDoc().

Here is the call graph for this function:


Member Function Documentation

void SSD::Doc::add_to_index Node node  )  [protected]
 

insert a node into the index structure

Parameters:
node Node to be added to index

Definition at line 120 of file doc.cc.

References index_by_label.

Referenced by walkTree().

void SSD::Doc::add_to_processed xmlNodePtr  node  )  [protected]
 

add an libxml node into the processed set

this is used for reconstruction of the XML document; unprocessed libxml nodes (such as ignored whitespace) are handeled differently

Parameters:
node libxml node to be added

Definition at line 126 of file doc.cc.

References processed.

Referenced by walkTree().

Node * SSD::Doc::appendNodeAttribute Node parent,
xmlNodePtr  node,
xmlAttrPtr  attr
[protected]
 

Make a new "attribute" Node.

Parameters:
parent parent node for new element
node parent libxml node
attr libxml attribute
Returns:
new Node object for this node

Definition at line 227 of file doc.cc.

References SSD::Node::addChild(), and SSD::ustring::empty().

Referenced by walkTree().

Here is the call graph for this function:

Node * SSD::Doc::appendNodeElement Node parent,
xmlNodePtr  node
[protected]
 

Make a new element Node.

Parameters:
parent parent node for new element
node libxml node information
Returns:
new Node object for this node

Definition at line 194 of file doc.cc.

References SSD::Node::addChild(), SSD::ustring::empty(), and SSD::empty_ustring().

Referenced by walkTree().

Here is the call graph for this function:

Node * SSD::Doc::appendNodeText Node parent,
xmlNodePtr  node
[protected]
 

Make a new "text" Node.

Parameters:
parent parent node for new element
node libxml node information
Returns:
new Node object for this node

Definition at line 210 of file doc.cc.

References SSD::Node::addChild(), SSD::ustring::empty(), SSD::empty_ustring(), and useWhitespace.

Referenced by walkTree().

Here is the call graph for this function:

void SSD::Doc::flushDoc  ) 
 

drop document information

Definition at line 29 of file doc.cc.

References dom, nodes, and root.

Referenced by loadXML(), and ~Doc().

xmlDocPtr SSD::Doc::getDOM  )  const [inline]
 

return libxml DOM root node for document this is used in output writers for reconstruction

Definition at line 126 of file doc.h.

References dom.

Referenced by SSD::MarkedWriter::dump(), SSD::XUpdateWriter::run(), SSD::MergedWriter::run(), and SSD::MarkedWriter::run().

NodeVec::const_iterator SSD::Doc::getNodesIter  )  const [inline]
 

access to const iterators of nodes list

Definition at line 128 of file doc.h.

References nodes.

Referenced by SSD::DiffDijkstra::run().

NodeVec::const_iterator SSD::Doc::getNodesIterEnd  )  const [inline]
 

Definition at line 129 of file doc.h.

References nodes.

Referenced by SSD::DiffDijkstra::run().

Node* SSD::Doc::getRoot  )  const [inline]
 

return root node for document

Definition at line 123 of file doc.h.

References root.

bool SSD::Doc::loadXML const char *  filename  ) 
 

load an XML document using libxml

Parameters:
filename filename to be loaded
Returns:
true on successful load

Definition at line 85 of file doc.cc.

References dom, flushDoc(), and walkTree().

Here is the call graph for this function:

void SSD::Doc::processXPath char *  xpath  ) 
 

build related-to data for a given xpath

Parameters:
xpath XPath expression to be used

Definition at line 104 of file doc.cc.

References dom, root, and walkTreeXPath().

Here is the call graph for this function:

void SSD::Doc::walkTree Node pos,
xmlNodePtr  node
[protected]
 

Walk the document tree recursively This will transform the libXML dom tree into a tree of SSD::Node objects.

Parameters:
pos current position in SSD::Node tree when walking
node current position in libxml tree

Definition at line 132 of file doc.cc.

References add_to_index(), add_to_processed(), appendNodeAttribute(), appendNodeElement(), appendNodeText(), SSD::Node::children, nodes, root, and xml_to_node.

Referenced by loadXML().

Here is the call graph for this function:

void SSD::Doc::walkTreeXPath xmlXPathContextPtr  xpathctx,
xmlXPathCompExprPtr  xpath,
Node node
[protected]
 

walk document by using an xpath expression

this is used to build the list of related nodes for a given XPath expression

Parameters:
xpathctx XPath context (allocated externally for efficiency)
xpath compiled XPath expression (compiled exernally for efficiency)
node reference node

Definition at line 41 of file doc.cc.

References SSD::Node::children, SSD::Node::data, relcount, SSD::Node::reldown, SSD::Node::relup, and xml_to_node.

Referenced by processXPath().


Member Data Documentation

xmlDocPtr SSD::Doc::dom [protected]
 

XML dom document tree for output reconstruction.

Definition at line 43 of file doc.h.

Referenced by flushDoc(), getDOM(), loadXML(), and processXPath().

NodeEqClassVec SSD::Doc::index_by_label
 

index of nodes by label

Definition at line 98 of file doc.h.

Referenced by add_to_index(), SSD::DiffDijkstra::run(), and SSD::DiffDijkstra::step().

NodeVec SSD::Doc::nodes [protected]
 

list containing all nodes in the document for iteration

Definition at line 46 of file doc.h.

Referenced by flushDoc(), getNodesIter(), getNodesIterEnd(), and walkTree().

std::set<void* > SSD::Doc::processed
 

set of libxml nodes processed (i.e. not ignored whitespace etc.)

Definition at line 102 of file doc.h.

Referenced by add_to_processed(), SSD::XUpdateWriter::run(), and SSD::MergedWriter::run().

hash_map<RelEqClass, int, hash_releqc> SSD::Doc::relcount
 

count of relations in file to calculate credits

Definition at line 107 of file doc.h.

Referenced by SSD::DiffDijkstra::run(), and walkTreeXPath().

Node* SSD::Doc::root [protected]
 

document root node

Definition at line 41 of file doc.h.

Referenced by flushDoc(), getRoot(), processXPath(), and walkTree().

bool SSD::Doc::useWhitespace = false [static]
 

flag wheter to ignore whitespace or not

Definition at line 25 of file doc.cc.

Referenced by appendNodeText().

hash_map<xmlNodePtr, Node*, hash<void*> > SSD::Doc::xml_to_node
 

map to find the Node object for a given libxml node

Definition at line 105 of file doc.h.

Referenced by walkTree(), and walkTreeXPath().


The documentation for this class was generated from the following files:
Generated on Thu Aug 4 17:59:01 2005 for SSDDiff by  doxygen 1.4.3-20050530