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 | 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 |
Friends | |
class | GCMarkGuard |
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 | ) |
Referenced by cloneNode().
|
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 |
as_object * gnash::XMLNode_as::childNodes | ( | ) |
References _global, and gnash::Global_as::createArray().
|
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().
|
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().
|
inline |
|
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 | ||
) | const |
Performs a recursive search of node attributes to find a match.
References gnash::key::_1, getParent(), and name.
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.
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 | ( | ) | const |
|
inline |
XMLNode_as * gnash::XMLNode_as::nextSibling | ( | ) | const |
Referenced by gnash::XML_as::toString().
|
inline |
|
inline |
Set name of this node.
References name.
|
inline |
Get the type of an XML Node.
|
inline |
Set the type of an XML Node.
|
inline |
|
inline |
Set value of this node.
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::NSV::CLASS_XMLNODE, gnash::createObject(), gnash::getMember(), gnash::getVM(), gnash::as_object::init_member(), gnash::key::o, gnash::NSV::PROP_CONSTRUCTOR, gnash::NSV::PROP_PROTOTYPE, gnash::as_object::set_prototype(), setObject(), gnash::as_object::setRelay(), and gnash::toObject().
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.
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.
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().
|
inline |
|
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.
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(), GCMarkGuard, and gnash::GcResource::setReachable().
|
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.
|
friend |
Referenced by setReachable().
|
protected |
Referenced by childNodes(), object(), and setAttribute().