Public Types | Public Member Functions | Protected Member Functions | Protected Attributes

gnash::XMLNode_as Class Reference

A node in an XML tree. More...

#include <XMLNode_as.h>

Inheritance diagram for gnash::XMLNode_as:
Inheritance graph
[legend]
Collaboration diagram for gnash::XMLNode_as:
Collaboration graph
[legend]

List of all members.

Public Types

enum  NodeType {
  Element = 1, Attribute = 2, Text = 3, Cdata = 4,
  EntityRef = 5, Entity = 6, ProcInstr = 7, Comment = 8,
  Document = 9, DocType = 10, DocFragment = 11, Notation = 12
}
typedef std::list< XMLNode_as * > Children

Public Member Functions

 XMLNode_as (Global_as &gl)
virtual ~XMLNode_as ()
size_t length () const
const std::string & nodeName () const
const std::string & nodeValue () const
NodeType nodeType () const
 Get the type of an XML Node.
void nodeTypeSet (NodeType type)
 Set the type of an XML Node.
void nodeNameSet (const std::string &name)
 Set name of this node.
bool extractPrefix (std::string &prefix)
void nodeValueSet (const std::string &value)
 Set value of this node.
void getNamespaceForPrefix (const std::string &prefix, std::string &ns)
 Performs a recursive search of node attributes to find a match.
bool getPrefixForNamespace (const std::string &ns, std::string &prefix)
 Performs a recursive search of node attributes to find a match.
void setNamespaceURI (const std::string value)
const std::string & getNamespaceURI () const
bool hasChildNodes ()
XMLNode_asfirstChild ()
XMLNode_aslastChild ()
as_objectchildNodes ()
XMLNode_aspreviousSibling ()
XMLNode_asnextSibling ()
XMLNode_ascloneNode (bool deep)
 Copy a node.
void appendChild (XMLNode_as *node)
 Append a child node to this XML object.
void removeChild (XMLNode_as *node)
 Remove a child node from this XML object.
XMLNode_asgetParent () const
 Get the parent XMLNode_as of this node. Can be 0.
void insertBefore (XMLNode_as *newnode, XMLNode_as *pos)
 Insert a node before a node.
virtual void toString (std::ostream &str, bool encode=false) const
 Convert the XMLNode to a string.
as_objectgetAttributes () const
 Return the attributes object associated with this node.
void setAttribute (const std::string &name, const std::string &value)
 Set a named attribute to a value.
void setObject (as_object *o)
 Associate an as_object with this XMLNode_as.
as_objectobject ()
 Return the object associated with this XMLNode_as.

Protected Member Functions

virtual void setReachable ()
 Mark reachable elements.
void clearChildren ()
 Clear all children, making sure unreferenced children are deleted.

Protected Attributes

Global_as_global

Detailed Description

A node in an XML tree.

This class has various complications to reduce memory usage when parsing very large XML documents. 1. It is a Relay class that can be attached to an as_object. 2. It does not have to have an associated object. This is only created once the XMLNode is accessed in ActionScript. 3. The top node of an XML tree is always accessible in ActionScript, either as an XML_as or a user-created XMLNode_as. 4. XMLNodes consequently mark their children as reachable, but not their parent. 5. When an XMLNode is destroyed, any children without an associated object are also deleted. Children with an associated object will be destroyed when the GC destroys the object.


Member Typedef Documentation


Member Enumeration Documentation

Enumerator:
Element 
Attribute 
Text 
Cdata 
EntityRef 
Entity 
ProcInstr 
Comment 
Document 
DocType 
DocFragment 
Notation 

Constructor & Destructor Documentation

gnash::XMLNode_as::XMLNode_as ( Global_as gl  ) 

Referenced by cloneNode().

gnash::XMLNode_as::~XMLNode_as (  )  [virtual]

References clearChildren().


Member Function Documentation

void gnash::XMLNode_as::appendChild ( XMLNode_as node  ) 

Append a child node to this XML object.

The child node's parent is set to this object, the node is added to this object's children. The childNodes array will be updated if it exists.

Parameters:
node The node to add as a child
as_object * gnash::XMLNode_as::childNodes (  ) 
void gnash::XMLNode_as::clearChildren (  )  [protected]

Clear all children, making sure unreferenced children are deleted.

AS-referenced child nodes will no longer be marked as reachable, so the GC will remove them on the next run.

References gnash::key::e.

Referenced by ~XMLNode_as().

XMLNode_as * gnash::XMLNode_as::cloneNode ( bool  deep  ) 

Copy a node.

Method; constructs and returns a new XML node of the same type, name, value, and attributes as the specified XML object. If deep is set to true, all child nodes are recursively cloned, resulting in an exact copy of the original object's document tree.

References XMLNode_as().

bool gnash::XMLNode_as::extractPrefix ( std::string &  prefix  ) 
XMLNode_as * gnash::XMLNode_as::firstChild (  ) 
as_object* gnash::XMLNode_as::getAttributes (  )  const [inline]

Return the attributes object associated with this node.

void gnash::XMLNode_as::getNamespaceForPrefix ( const std::string &  prefix,
std::string &  ns 
)

Performs a recursive search of node attributes to find a match.

References gnash::key::_1, and getParent().

const std::string& gnash::XMLNode_as::getNamespaceURI (  )  const [inline]
XMLNode_as* gnash::XMLNode_as::getParent (  )  const [inline]

Get the parent XMLNode_as of this node. Can be 0.

Referenced by getNamespaceForPrefix(), getPrefixForNamespace(), and insertBefore().

bool gnash::XMLNode_as::getPrefixForNamespace ( const std::string &  ns,
std::string &  prefix 
)

Performs a recursive search of node attributes to find a match.

Returns:
false if no match found.

References gnash::key::_1, getParent(), and name.

bool gnash::XMLNode_as::hasChildNodes (  ) 

Returns true if the specified node has child nodes; otherwise, returns false.

void gnash::XMLNode_as::insertBefore ( XMLNode_as newnode,
XMLNode_as pos 
)

Insert a node before a node.

Method; inserts a new child node into the XML object's child list, before the beforeNode node. If the beforeNode parameter is undefined or null, the node is added using the appendChild() method. If beforeNode is not a child of my_xml, the insertion fails.

Parameters:
newnode The node to insert, moving from its current tree
pos The node before which to insert the new one. Must be a child of this XMLNode or the operation will fail.

References _, getParent(), IF_VERBOSE_ASCODING_ERRORS, and removeChild().

XMLNode_as * gnash::XMLNode_as::lastChild (  ) 

References _.

size_t gnash::XMLNode_as::length (  )  const [inline]
XMLNode_as * gnash::XMLNode_as::nextSibling (  ) 
const std::string& gnash::XMLNode_as::nodeName (  )  const [inline]
void gnash::XMLNode_as::nodeNameSet ( const std::string &  name  )  [inline]

Set name of this node.

NodeType gnash::XMLNode_as::nodeType (  )  const [inline]

Get the type of an XML Node.

void gnash::XMLNode_as::nodeTypeSet ( NodeType  type  )  [inline]

Set the type of an XML Node.

const std::string& gnash::XMLNode_as::nodeValue (  )  const [inline]
void gnash::XMLNode_as::nodeValueSet ( const std::string &  value  )  [inline]

Set value of this node.

as_object * gnash::XMLNode_as::object (  ) 
XMLNode_as * gnash::XMLNode_as::previousSibling (  ) 
void gnash::XMLNode_as::removeChild ( XMLNode_as node  ) 

Remove a child node from this XML object.

The child node's parent is set to 0, the node is removed from this object's children. The childNodes array will be updated if it exists.

Parameters:
node The node to remove.

Referenced by insertBefore().

void gnash::XMLNode_as::setAttribute ( const std::string &  name,
const std::string &  value 
)

Set a named attribute to a value.

Parameters:
name The name of the attribute to set. If already present, the value is changed. If not present, the attribute is added.
value The value to set the named attribute to.

References _global, gnash::string_table::find(), gnash::getStringTable(), and gnash::as_object::set_member().

void gnash::XMLNode_as::setNamespaceURI ( const std::string  value  )  [inline]
void gnash::XMLNode_as::setObject ( as_object o  )  [inline]

Associate an as_object with this XMLNode_as.

An XMLNode_as with an associated object is regarded as being owned by that object, so make sure it is! Using as_object::setRelay will achieve that.

Referenced by object(), and gnash::XML_as::XML_as().

void gnash::XMLNode_as::setReachable (  )  [protected, virtual]

Mark reachable elements.

These are: children, attributes object, associated as_object.

Reimplemented from gnash::Relay.

References gnash::for_each(), and gnash::GcResource::setReachable().

void gnash::XMLNode_as::toString ( std::ostream &  str,
bool  encode = false 
) const [virtual]

Convert the XMLNode to a string.

Parameters:
o The ostream to write the string to.
encode Whether to URL encode the node values. This is false by default, as it is only necessary for XML.sendAndLoad.

Reimplemented in gnash::XML_as.


Member Data Documentation

Referenced by childNodes(), object(), and setAttribute().


The documentation for this class was generated from the following files: