CS::DocSystem Namespace Reference (Crystal Space 2.0 Public API Reference)

| ## Public API Reference

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Namespace List
- Namespace Members

Classes | Functions
CS::DocSystem Namespace Reference

Document system / XML helper classes. More...

## Classes
struct | NodeAttributeCompare
| Node comparator. More...
struct | NodeAttributeRegexpTest
| Check if a regular expression matches(case-insensitive) with the value of the given attribute. More...
struct | NodeAttributeValueTest
| Compare (case-sensitive) node attribute to given. More...
struct | NodeNameCompare
| Node comparator. More...
struct | NodeValueTest
| Compare (case-sensitive) node value to given. More...
## Functions
void | CloneAttributes (iDocumentNode *from, iDocumentNode *to)
| Copy the attributes of a node to another node.
void | CloneNode (iDocumentNode *from, iDocumentNode *to)
| Recursively clone a node with all its attributes and child-nodes.
template<class T >
csPtr< iDocumentNodeIterator > | FilterDocumentNodeIterator (csRef< iDocumentNodeIterator > parent, T filter)
| Get a filtering iDocumentNodeIterator.
csString | FlattenNode (iDocumentNode *node)
| "Flatten" a document node structure into a string, suitable for e.g.
csString | FlattenNodeShallow (iDocumentNode *node)
| "Flatten" a document node structure into a string ignoring child nodes,
csPtr< iDocument > | MakeChangeable (iDocument *doc, iDocumentSystem *docsys)
| Make a document changeable.
template<class T >
void | RemoveDuplicateChildren (iDocumentNode *rootNode, T eq)
| Remove duplicate child-nodes.
template<class T >
void | RemoveDuplicateChildren (iDocumentNode *rootNode, csRef< iDocumentNodeIterator > childIt, T eq)
| Remove duplicate child-nodes.
bool | SetContentsValue (iDocumentNode *node, const char *contents)
| Set the contents of a document node.

## Detailed Description

Document system / XML helper classes.

## Function Documentation

void CS::DocSystem::CloneAttributes | ( | iDocumentNode * | from,
|  | iDocumentNode * | to
| ) |  | `[inline]`

Copy the attributes of a node to another node.

Parameters:

  from | Source node
  to | Destination node

Definition at line 181 of file documenthelper.h.

void CS::DocSystem::CloneNode | ( | iDocumentNode * | from,
|  | iDocumentNode * | to
| ) |  | `[inline]`

Recursively clone a node with all its attributes and child-nodes.

Parameters:

  from | Source root node
  to | Destination root node

Definition at line 196 of file documenthelper.h.

template<class T >

csPtr<iDocumentNodeIterator> CS::DocSystem::FilterDocumentNodeIterator | ( | csRef< iDocumentNodeIterator > | parent,
|  | T | filter
| ) |  |

Get a filtering iDocumentNodeIterator.

Only nodes matching the filter are returned. Example usage:

     DocumentHelper::NodeAttributeValueTest test ("name", "Marten");
     csRef<iDocumentNodeIterator> it =
       FilterDocumentNodeIterator (node->GetNodes(), test);
     while (it->HasNext ())
     { ... }

Definition at line 347 of file documenthelper.h.

csString CS::DocSystem::FlattenNode | ( | iDocumentNode * | node | ) |

"Flatten" a document node structure into a string, suitable for e.g.

hashing.

csString CS::DocSystem::FlattenNodeShallow | ( | iDocumentNode * | node | ) |

"Flatten" a document node structure into a string ignoring child nodes,

See also:
  FlattenNode

csPtr<iDocument> CS::DocSystem::MakeChangeable | ( | iDocument * | doc,
|  | iDocumentSystem * | docsys
| ) |  |

Make a document changeable.

Not all documents can be changed in-place. This helper function checks the document doc and either returns the original document, if changeable, or a newly created, changeable document from docsys with the same contents as doc.

template<class T >

void CS::DocSystem::RemoveDuplicateChildren | ( | iDocumentNode * | rootNode,
|  | T | eq
| ) |  |

Remove duplicate child-nodes.

The functor T is used to determine what should be seen as equal nodes. This is potentially an O(n^2) operation!

Definition at line 115 of file documenthelper.h.

template<class T >

void CS::DocSystem::RemoveDuplicateChildren | ( | iDocumentNode * | rootNode,
|  | csRef< iDocumentNodeIterator > | childIt,
|  | T | eq
| ) |  |

Remove duplicate child-nodes.

The functor T is used to determine what should be seen as equal nodes. This is potentially an O(n^2) operation!

Definition at line 128 of file documenthelper.h.

bool CS::DocSystem::SetContentsValue | ( | iDocumentNode * | node,
|  | const char * | contents
| ) |  |

Set the contents of a document node.

This is the converse of iDocumentNode::GetContentsValue(): if node has a child of type CS_NODE_TEXT, the value of that child is changed to contents. If no such node exists one is created. Returns `false` if node couldn't be changed or a child created. (Typically if node was not of type CS_NODE_ELEMENT.)