Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

data::grove::parent(3) [centos man page]

Data::Grove::Parent(3)					User Contributed Perl Documentation				    Data::Grove::Parent(3)

NAME
Data::Grove::Parent - provide parent properties to Data::Grove objects SYNOPSIS
use Data::Grove::Parent; $root = $object->root; $rootpath = $object->rootpath; $tied = $object->add_magic([ $parent ]); $node = Data::Grove::Parent->new($hash [, $parent]); $node_list = Data::Grove::ParentList->new($array [, $parent]); DESCRIPTION
Data::Grove::Parent is an extension to Data::Grove that adds `"Parent"' and `"Raw"' properties to Data::Grove objects and methods for returning the root node of a grove, a list of nodes between and including the root node and the current node, and a method that creates parented nodes. Data::Grove::Parent works by creating a Perl ``tied'' object that contains a parent reference (`"Parent"') and a reference to the original Data::Grove object (`"Raw"'). Tying-magic is used so that every time you reference the Data::Grove::Parent object it actually references the underlying raw object. When you retrieve a list or a property of the Raw object, Data::Grove::Parent automatically adds magic to the returned list or node. This means you only call `add_magic()' once to create the first Data::Grove::Parent object and then use the grove objects like you normally would. The most obvious use of this is so you don't have to call a `"delete"' method when you want to release a grove or part of a grove; since Data::Grove and Data::Grove::Parent objects have no cyclic references, Perl can garbage collect them normally. A secondary use is to allow you to reuse grove or property set fragments in multiple trees. WARNING: Data::Grove currently does not protect you from creating your own cyclic references! This could lead to infinite loops if you don't take care to avoid them. METHODS
$object->root() $object->rootpath() `"root()"' returns the root node if `$object' is a `"Data::Grove::Parent"' object. `"rootpath()"' returns an array of all the nodes between and including the root node and `$object'. $tied = $object->add_magic([ $parent ]) `"add_magic()"' returns a "Data::Grove::Parent" object with `$object' as it's `"Raw"' object. If `$parent' is given, that becomes the tied object's parent object. AUTHOR
Ken MacLeod, ken@bitsko.slc.ut.us SEE ALSO
perl(1), Data::Grove(3) perl v5.16.3 2003-10-21 Data::Grove::Parent(3)

Check Out this Related Man Page

Data::Grove::Visitor(3) 				User Contributed Perl Documentation				   Data::Grove::Visitor(3)

NAME
Data::Grove::Visitor - add visitor/callback methods to Data::Grove objects SYNOPSIS
use Data::Grove::Visitor; @results = $object->accept ($visitor, ...); @results = $object->accept_name ($visitor, ...); @results = $object->children_accept ($visitor, ...); @results = $object->children_accept_name ($visitor, ...); DESCRIPTION
Data::Grove::Visitor adds visitor methods (callbacks) to Data::Grove objects. A ``visitor'' is a class (a package) you write that has methods (subs) corresponding to the objects in the classes being visited. You use the visitor methods by creating an instance of your visitor class, and then calling `"accept($my_visitor)"' on the top-most object you want to visit, that object will in turn call your visitor back with `"visit_OBJECT"', where OBJECT is the type of object. There are several forms of `"accept"'. Simply calling `"accept"' calls your package back using the object type of the object you are visiting. Calling `"accept_name"' on an element object calls you back with `"visit_name_NAME"' where NAME is the tag name of the element, on all other objects it's as if you called `"accept"'. All of the forms of `"accept"' return a concatenated list of the result of all `"visit"' methods. `"children_accept"' calls `"accept"' on each of the children of the element. This is generally used in element callbacks to recurse down into the element's children, you don't need to get the element's contents and call `"accept"' on each item. `"children_accept_name"' does the same but calling `"accept_name"' on each of the children. `"attr_accept"' calls `"accept"' on each of the objects in the named attribute. Refer to the documentation of the classes you are visiting (XML::Grove, etc.) for the type names (`"element"', `"document"', etc.) of the objects it implements. RESERVED NAMES
The hash keys `"Contents"' and `"Name"' are used to indicate objects with children (for `"children_accept"') and named objects (for `"accept_name"'). NOTES
These are random ideas that haven't been implemented yet: o Several objects fall into subclasses, or you may want to be able to subclass a visited object and still be able to tell the difference. In SGML::Grove I had used the package name in the callback (`"visit_SGML_Element"') instead of a generic name (`"visit_element"'). The idea here would be to try calling `"visit_PACKAGE"' with the most specific class first, then try superclasses, and lastly to try the generic. AUTHOR
Ken MacLeod, ken@bitsko.slc.ut.us SEE ALSO
perl(1), Data::Grove Extensible Markup Language (XML) <http://www.w3c.org/XML> perl v5.16.3 2003-10-21 Data::Grove::Visitor(3)
Man Page