Gnash  0.8.10
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:
gnash::Relay gnash::XML_as

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) const
void nodeValueSet (const std::string &value)
 Set value of this node.
void getNamespaceForPrefix (const std::string &prefix, std::string &ns) const
 Performs a recursive search of node attributes to find a match.
bool getPrefixForNamespace (const std::string &ns, std::string &prefix) const
 Performs a recursive search of node attributes to find a match.
void setNamespaceURI (const std::string &value)
const std::string & getNamespaceURI () const
bool hasChildNodes () const
XMLNode_asfirstChild () const
XMLNode_aslastChild () const
as_objectchildNodes ()
XMLNode_aspreviousSibling () const
XMLNode_asnextSibling () const
XMLNode_ascloneNode (bool deep) const
 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:
nodeThe node to add as a child

References assert.

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) const

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) const
XMLNode_as * gnash::XMLNode_as::firstChild ( ) const

Referenced by gnash::XML_as::toString().

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 
) const

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 insertBefore(), getPrefixForNamespace(), and getNamespaceForPrefix().

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

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

Returns:
false if no match found.

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

bool gnash::XMLNode_as::hasChildNodes ( ) const

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:
newnodeThe node to insert, moving from its current tree
posThe node before which to insert the new one. Must be a child of this XMLNode or the operation will fail.

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

XMLNode_as * gnash::XMLNode_as::lastChild ( ) const
size_t gnash::XMLNode_as::length ( ) const [inline]
XMLNode_as * gnash::XMLNode_as::nextSibling ( ) const

Referenced by gnash::XML_as::toString().

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 ( ) const
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:
nodeThe 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:
nameThe name of the attribute to set. If already present, the value is changed. If not present, the attribute is added.
valueThe value to set the named attribute to.

References gnash::getVM(), _global, gnash::as_object::set_member(), and gnash::getURI().

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.

References assert, and gnash::key::o.

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

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

Mark reachable elements.

These are: children, attributes object, associated as_object.

Reimplemented from gnash::Relay.

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

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

Convert the XMLNode to a string.

Parameters:
oThe ostream to write the string to.
encodeWhether 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 object(), childNodes(), and setAttribute().


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