Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

Fl_XmlNode Class Reference
[eFLTK XML module]

node. More...

#include <Fl_XmlNode.h>

Inheritance diagram for Fl_XmlNode:

Fl_XmlDoc List of all members.

Public Types

enum  NodeTypes {
  DOM_DOCUMENT = 1, DOM_ELEMENT, DOM_PI, DOM_TEXT,
  DOM_CDATA_SECTION, DOM_COMMENT
}
 Node type enumeration. More...


Public Methods

virtual ~Fl_XmlNode ()
 Destroys node and all it's children.

virtual void clear ()
 Deletes all children.

Fl_XmlNode * parent () const
 Returns parent node of this node. More...

Fl_XmlDocdocument () const
 Returns document context associated with this node.

int type () const
 Returns type of node.

bool is_document () const
 Returns true node is document type.

bool is_element () const
 Returns true node is element type.

bool is_leaf () const
 Returns true node is element type, but has no children.

bool is_pi () const
 Returns true node is processing instruction (PI) type.

bool is_comment () const
 Returns true node is comment type.

bool is_text () const
 Returns true node is text type.

bool is_cdata_section () const
 Returns true node is cdata-section type.

const Fl_Stringname () const
 Returns the node name. More...

void name (const Fl_String &name)
 Set new name for node.

void name (const char *name)
 Set new name for node.

Fl_Stringvalue ()
 Returns the value of the node. More...

void value (const Fl_String &new_value)
 Set new value to node. More...

void value (const char *new_value)
 Set new value to node. More...

void text (Fl_String &ret)
 Returns cdatas combined from children. More...

Fl_XmlNode * child (const char *name, bool recursive=true) const
 Returns the first occurence of child with the given name. More...

Fl_XmlNode_List nodes (const char *name)
 Returns list of all subnodes with give name. More...

Fl_XmlNode * clone_node (bool deep=false)
 Creates a deepcopy of the node. More...

Fl_XmlNode * remove_child (Fl_XmlNode *old_child)
 Removes the child node indicated by 'old_child' from the list of children, and returns it. More...

Fl_XmlNode * replace_child (Fl_XmlNode *new_child, Fl_XmlNode *old_child)
 Replaces the child node 'old_child' with 'new_child' in the list of children, and returns the 'old_child' node. More...

Fl_XmlNode * append_child (Fl_XmlNode *new_child)
 Adds the node 'new_child' to the end of the list of children of this node. More...

Fl_XmlNode * insert_before (Fl_XmlNode *new_child, Fl_XmlNode *ref_child)
 Inserts the node 'new_child' before the existing child node 'ref_child'. More...

const Fl_XmlNode_Listchild_nodes () const
 Returns list of child nodes.

unsigned children () const
 Returns number of child nodes.

bool has_child_nodes () const
 Returns true, if node has children.

Fl_XmlNode * child (int index) const
 Return child for given index, NULL if out of range.

const Fl_XmlAttributesattributes () const
bool has_attributes () const
 Returns true, if node has any attributes.

bool has_attribute (const char *attr) const
 Returns true, if given attribute is found. More...

Fl_Stringget_attribute (const char *attr) const
 Returns attribute value for given attribute. More...

void set_attribute (const char *attr, const char *value)
 Set new value to attribute 'attr'. More...

void set_attribute (const char *attr, const Fl_String &value)
 Set new value to attribute 'attr'. More...

virtual void save (Fl_Buffer &buffer, int indent=0)
 Saves node to buffer. More...


Protected Attributes

Fl_String m_name
Fl_String m_value
Fl_XmlAttributes m_attributes
uchar m_nodetype
Fl_XmlDocm_document
Fl_XmlNode * m_parent
Fl_XmlNode_List m_child_nodes

Friends

class Fl_XmlParser
class Fl_XmlDoc

Detailed Description

node.

Definition at line 67 of file Fl_XmlNode.h.


Member Enumeration Documentation

enum Fl_XmlNode::NodeTypes
 

Node type enumeration.

Enumeration values:
DOM_DOCUMENT  Document node.
DOM_ELEMENT  Normal element node, can contain subnodes.
DOM_PI  Processing Instruction node.
DOM_TEXT  Cdata where all default entities MUST be escaped.
DOM_CDATA_SECTION  Cdata section, which can contain preformatted char data.

e.g. <[CDATA[ <xml rules> ]]>

DOM_COMMENT  Comment node.

Definition at line 71 of file Fl_XmlNode.h.


Member Function Documentation

Fl_XmlNode* Fl_XmlNode::append_child Fl_XmlNode *    new_child
 

Adds the node 'new_child' to the end of the list of children of this node.

If the 'new_child' is already in the tree, it is first removed.

Fl_XmlNode* Fl_XmlNode::child const char *    name,
bool    recursive = true
const
 

Returns the first occurence of child with the given name.

Recursive is true, it will search throught children.

Parameters:
name  to be searched

Fl_XmlNode* Fl_XmlNode::clone_node bool    deep = false
 

Creates a deepcopy of the node.

If deep is true, then the cloning is done recursively which means that all the node's children are deep copied too. If deep is false only the node itself is copied and the copy will have no child nodes.

Fl_String& Fl_XmlNode::get_attribute const char *    attr const [inline]
 

Returns attribute value for given attribute.

If not found, empty string is returned. HTML tags can have empty attributes, for those you should use has_attribute() method.

Parameters:
attr  name of attribute

Definition at line 272 of file Fl_XmlNode.h.

References Fl_XmlAttributes::get_attribute().

bool Fl_XmlNode::has_attribute const char *    attr const [inline]
 

Returns true, if given attribute is found.

Parameters:
attr  to search

Definition at line 264 of file Fl_XmlNode.h.

References Fl_XmlAttributes::has_attribute().

Fl_XmlNode* Fl_XmlNode::insert_before Fl_XmlNode *    new_child,
Fl_XmlNode *    ref_child
 

Inserts the node 'new_child' before the existing child node 'ref_child'.

If 'ref_child' is null, insert 'new_child' at the end of the list of children. If the 'new_child' is already in the tree, it is first removed. Returns the node being inserted.

const Fl_String& Fl_XmlNode::name   const [inline]
 

Returns the node name.

The meaning of the value depends on the node type:
DOM_DOCUMENT document
DOM_ELEMENT The tag name
DOM_PI The target of the processing instruction
DOM_COMMENT comment
DOM_TEXT text
DOM_CDATA_SECTIONcdata-section

Definition at line 133 of file Fl_XmlNode.h.

Fl_XmlNode_List Fl_XmlNode::nodes const char *    name
 

Returns list of all subnodes with give name.

Parameters:
name  to add list

Fl_XmlNode* Fl_XmlNode::parent   const [inline]
 

Returns parent node of this node.

For Fl_XmlDocument this returns NULL.

Definition at line 94 of file Fl_XmlNode.h.

Fl_XmlNode* Fl_XmlNode::remove_child Fl_XmlNode *    old_child
 

Removes the child node indicated by 'old_child' from the list of children, and returns it.

Parameters:
old_child  as child to remove

Fl_XmlNode* Fl_XmlNode::replace_child Fl_XmlNode *    new_child,
Fl_XmlNode *    old_child
 

Replaces the child node 'old_child' with 'new_child' in the list of children, and returns the 'old_child' node.

If the 'new_child' is already in the tree, it is first removed.

virtual void Fl_XmlNode::save Fl_Buffer   buffer,
int    indent = 0
[virtual]
 

Saves node to buffer.

Parameters:
buffer  to save
indent  how many indent spaces at start

void Fl_XmlNode::set_attribute const char *    attr,
const Fl_String   value
[inline]
 

Set new value to attribute 'attr'.

If attribute is not found, it's added to map.

Parameters:
attr  attribute name
value  attribute value

Definition at line 288 of file Fl_XmlNode.h.

References Fl_XmlAttributes::set_attribute().

void Fl_XmlNode::set_attribute const char *    attr,
const char *    value
[inline]
 

Set new value to attribute 'attr'.

If attribute is not found, it's added to map.

Parameters:
attr  attribute name
value  attribute value

Definition at line 280 of file Fl_XmlNode.h.

References Fl_XmlAttributes::set_attribute().

void Fl_XmlNode::text Fl_String   ret
 

Returns cdatas combined from children.

e.g. "Some <tag>text</tag> here" becomes: "Some text here"

Parameters:
ret  string is stored here

void Fl_XmlNode::value const char *    new_value [inline]
 

Set new value to node.

Parameters:
new_value  value to set
See also:
value()

Definition at line 165 of file Fl_XmlNode.h.

void Fl_XmlNode::value const Fl_String   new_value [inline]
 

Set new value to node.

Parameters:
new_value  value to set
See also:
value()

Definition at line 158 of file Fl_XmlNode.h.

Fl_String& Fl_XmlNode::value   [inline]
 

Returns the value of the node.

The meaning of the value depends on the node type:
DOM_DOCUMENT none
DOM_ELEMENT none
DOM_PI The data of the processing intruction
DOM_COMMENT The comment
DOM_TEXT The text
DOM_CDATA_SECTIONThe data of the cdata-section

Definition at line 151 of file Fl_XmlNode.h.


The documentation for this class was generated from the following file:
Generated on Thu Jul 31 15:33:58 2003 for eFLTK by doxygen1.2.15