Gnash
0.8.11dev
|
A node in an XML tree. More...
#include <XMLNode_as.h>
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. More... | |
void | nodeTypeSet (NodeType type) |
Set the type of an XML Node. More... | |
void | nodeNameSet (const std::string &name) |
Set name of this node. More... | |
bool | extractPrefix (std::string &prefix) const |
void | nodeValueSet (const std::string &value) |
Set value of this node. More... | |
void | getNamespaceForPrefix (const std::string &prefix, std::string &ns) const |
Performs a recursive search of node attributes to find a match. More... | |
bool | getPrefixForNamespace (const std::string &ns, std::string &prefix) const |
Performs a recursive search of node attributes to find a match. More... | |
void | setNamespaceURI (const std::string &value) |
const std::string & | getNamespaceURI () const |
bool | descendsFrom (XMLNode_as *node) const |
Returns true if 'this' descends from the specified node. More... | |
bool | hasChildNodes () const |
XMLNode_as * | firstChild () const |
XMLNode_as * | lastChild () const |
as_object * | childNodes () |
XMLNode_as * | previousSibling () const |
XMLNode_as * | nextSibling () const |
XMLNode_as * | cloneNode (bool deep) const |
Copy a node. More... | |
void | appendChild (XMLNode_as *node) |
Append a child node to this XML object. More... | |
void | removeChild (XMLNode_as *node) |
Remove a child node from this XML object. More... | |
XMLNode_as * | getParent () const |
Get the parent XMLNode_as of this node. Can be 0. More... | |
void | insertBefore (XMLNode_as *newnode, XMLNode_as *pos) |
Insert a node before a node. More... | |
virtual void | toString (std::ostream &str, bool encode=false) const |
Convert the XMLNode to a string. More... | |
as_object * | getAttributes () const |
Return the attributes object associated with this node. More... | |
void | setAttribute (const std::string &name, const std::string &value) |
Set a named attribute to a value. More... | |
void | setObject (as_object *o) |
Associate an as_object with this XMLNode_as. More... | |
as_object * | object () |
Return the object associated with this XMLNode_as. More... | |
![]() | |
virtual | ~Relay ()=0 |
virtual void | clean () |
Handle any cleanup necessary before the Relay is destroyed. More... | |
Protected Member Functions | |
virtual void | setReachable () |
Mark reachable elements. More... | |
void | clearChildren () |
Clear all children, making sure unreferenced children are deleted. More... | |
Protected Attributes | |
Global_as & | _global |
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.
typedef std::list<XMLNode_as*> gnash::XMLNode_as::Children |
gnash::XMLNode_as::XMLNode_as | ( | Global_as & | gl | ) |
References _global.
Referenced by cloneNode(), gnash::registerXMLNative(), gnash::XML_as::toString(), and gnash::xmlnode_class_init().
|
virtual |
References clearChildren().
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.
node | The node to add as a child |
Referenced by gnash::XML_as::toString(), and gnash::xmlnode_class_init().
as_object * gnash::XMLNode_as::childNodes | ( | ) |
References _global, and gnash::Global_as::createArray().
Referenced by gnash::xmlnode_class_init().
|
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 _global, gnash::callMethod(), Element, gnash::escapeXML(), gnash::log_debug(), nodeName(), nodeType(), nodeValue(), gnash::NSV::PROP_ESCAPE, Text, gnash::as_value::to_string(), and toString().
Referenced by gnash::XML_as::parseXML(), and ~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().
Referenced by gnash::xmlnode_class_init().
bool gnash::XMLNode_as::descendsFrom | ( | XMLNode_as * | node | ) | const |
Returns true if 'this' descends from the specified node.
References descendsFrom(), and getParent().
Referenced by descendsFrom(), getNamespaceURI(), and gnash::xmlnode_class_init().
bool gnash::XMLNode_as::extractPrefix | ( | std::string & | prefix | ) | const |
Referenced by nodeNameSet(), and gnash::xmlnode_class_init().
XMLNode_as * gnash::XMLNode_as::firstChild | ( | ) | const |
Referenced by getNamespaceURI(), gnash::XML_as::toString(), and gnash::xmlnode_class_init().
|
inline |
Return the attributes object associated with this node.
References name, and setAttribute().
Referenced by gnash::xmlnode_class_init().
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().
Referenced by nodeValueSet(), and gnash::xmlnode_class_init().
|
inline |
References descendsFrom(), firstChild(), hasChildNodes(), and lastChild().
Referenced by gnash::XML_as::toString(), and gnash::xmlnode_class_init().
|
inline |
Get the parent XMLNode_as of this node. Can be 0.
References insertBefore(), and toString().
Referenced by descendsFrom(), getNamespaceForPrefix(), getPrefixForNamespace(), insertBefore(), gnash::XML_as::toString(), and gnash::xmlnode_class_init().
bool gnash::XMLNode_as::getPrefixForNamespace | ( | const std::string & | ns, |
std::string & | prefix | ||
) | const |
Performs a recursive search of node attributes to find a match.
References gnash::key::_1, getParent(), and name.
Referenced by nodeValueSet(), and gnash::xmlnode_class_init().
bool gnash::XMLNode_as::hasChildNodes | ( | ) | const |
Returns true if the specified node has child nodes; otherwise, returns false.
Referenced by getNamespaceURI(), and gnash::xmlnode_class_init().
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.
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, gnash::log_aserror(), and removeChild().
Referenced by getParent(), and gnash::xmlnode_class_init().
XMLNode_as * gnash::XMLNode_as::lastChild | ( | ) | const |
Referenced by getNamespaceURI(), and gnash::xmlnode_class_init().
|
inline |
XMLNode_as * gnash::XMLNode_as::nextSibling | ( | ) | const |
Referenced by gnash::XML_as::toString(), and gnash::xmlnode_class_init().
|
inline |
Referenced by clearChildren(), gnash::XML_as::toString(), and gnash::xmlnode_class_init().
|
inline |
Set name of this node.
References extractPrefix(), and name.
Referenced by gnash::registerXMLNative(), gnash::XML_as::toString(), and gnash::xmlnode_class_init().
|
inline |
Get the type of an XML Node.
Referenced by clearChildren(), and gnash::xmlnode_class_init().
|
inline |
Set the type of an XML Node.
Referenced by gnash::registerXMLNative(), and gnash::XML_as::toString().
|
inline |
Referenced by clearChildren(), and gnash::xmlnode_class_init().
|
inline |
Set value of this node.
References getNamespaceForPrefix(), and getPrefixForNamespace().
Referenced by gnash::registerXMLNative(), gnash::XML_as::toString(), and gnash::xmlnode_class_init().
as_object * gnash::XMLNode_as::object | ( | ) |
Return the object associated with this XMLNode_as.
The object will be created if it does not already exist.
References _global, gnash::arrayKey(), gnash::NSV::CLASS_XMLNODE, gnash::createObject(), gnash::getMember(), gnash::getVM(), gnash::key::i, gnash::as_object::init_member(), gnash::key::o, object(), gnash::NSV::PROP_CONSTRUCTOR, gnash::NSV::PROP_LENGTH, gnash::NSV::PROP_PROTOTYPE, gnash::PropFlags::readOnly, gnash::as_object::set_member(), gnash::as_object::set_member_flags(), gnash::as_object::set_prototype(), setObject(), gnash::as_object::setRelay(), and gnash::toObject().
Referenced by object(), gnash::registerXMLNative(), setObject(), and gnash::xmlnode_class_init().
XMLNode_as * gnash::XMLNode_as::previousSibling | ( | ) | const |
Referenced by gnash::xmlnode_class_init().
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.
node | The node to remove. |
Referenced by insertBefore(), and gnash::xmlnode_class_init().
void gnash::XMLNode_as::setAttribute | ( | const std::string & | name, |
const std::string & | value | ||
) |
Set a named attribute to a value.
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::getURI(), gnash::getVM(), and gnash::as_object::set_member().
Referenced by getAttributes(), and gnash::XML_as::toString().
|
inline |
Referenced by gnash::XML_as::toString().
|
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 gnash::key::o, object(), and setReachable().
Referenced by object(), and gnash::XML_as::XML_as().
|
protectedvirtual |
Mark reachable elements.
These are: children, attributes object, associated as_object.
Reimplemented from gnash::Relay.
References gnash::renderer::opengl::for_each(), and gnash::GcResource::setReachable().
Referenced by setObject().
|
virtual |
Convert the XMLNode to a string.
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.
Referenced by clearChildren(), getParent(), and gnash::xmlnode_class_init().
|
protected |
Referenced by childNodes(), clearChildren(), object(), setAttribute(), gnash::XML_as::toString(), and XMLNode_as().