std/path/z/node

Standard Library documentation

Node wrapper used by std/path/z.

Module

Name
std/path/z/node
Area
Standard Library
Source
modules/std/path/z/node.zzm

NAME

std/path/z/node - Node wrapper used by std/path/z.

IMPLEMENTATION SUPPORT

This module is supported by all implementations of ZuzuScript.

DESCRIPTION

Objects of this class wrap underlying values and provide traversal and coercion helpers used while evaluating ZPath expressions.

EXPORTS

Classes

  • Node

    Base wrapper for values traversed by ZPath.

    • Node.from_root(obj)

      Parameters: obj is any query root. Returns: Node. Wraps a root value for traversal.

    • Node.wrap(obj, parent?, key?, ix?)

      Parameters: obj is any value, with optional parent, key, and index metadata. Returns: Node. Wraps a value in the appropriate node subclass.

    • node.hold_parent(owner)

      Parameters: owner is a parent node. Returns: Node. Retains parent metadata on the node.

    • node.raw(), node.value(), node.primitive_value()

      Parameters: none. Returns: value. Returns the wrapped raw, node, or primitive value.

    • node.parent()

      Parameters: none. Returns: Node or null. Returns the parent node.

    • node.key(), node.ix(), node.index(), node.id()

      Parameters: none. Returns: value. Returns traversal key, index, or stable node id metadata.

    • node.type(), node.name()

      Parameters: none. Returns: String or null. Returns the node type or name.

    • node.tagged()

      Parameters: none. Returns: String or null. Returns a KDL value tag when present.

    • node.has_tagged()

      Parameters: none. Returns: Boolean. Returns true when tag metadata is available.

    • node.string_value(), node.number_value()

      Parameters: none. Returns: String, Number, or null. Coerces the node for string or numeric ZPath operations.

    • node.can_have_named_children(), node.can_have_indexed_children(), node.can_have_named_indexed_children()

      Parameters: none. Returns: Boolean. Reports supported child lookup modes.

    • node.named_child(name), node.indexed_child(i), node.named_indexed_child(name, i)

      Parameters: name is a child name and i is an index. Returns: Node or null. Looks up child nodes.

    • node.next_child(child), node.prev_child(child), node.next_sibling(), node.prev_sibling()

      Parameters: child is a child node where required. Returns: Node or null. Traverses adjacent nodes.

    • node.named_attribute(name)

      Parameters: name is an attribute name. Returns: Node or null. Looks up one attribute node.

    • node.children(), node.attributes()

      Parameters: none. Returns: Array. Returns child or attribute nodes.

    • node.dump()

      Parameters: none. Returns: String. Returns a diagnostic rendering of the node.

    • node.find(zpath)

      Parameters: zpath is a ZPath object or subclass, such as ZZPath. Returns: Array. Evaluates a nested path from this node and returns selected node objects.

    • node.do_action(action), node.do_action_on_child(child, action)

      Parameters: action is a path action and child is a child node. Returns: value. Applies path mutation actions.

    • node.ref(), node.ref_on_child(child)

      Parameters: child is a child node where required. Returns: Function. Returns a reference-like getter/setter.

  • SimpleNode, StringNode, NumberNode, BooleanNode, NullNode

    Scalar node wrappers. They inherit the Node API and override type, string_value, or number_value where appropriate.

  • ArrayNode, SetNode, BagNode, DictNode, PairListNode, PairNode

    Collection node wrappers. They inherit the Node API and override child, attribute, assignment, and reference methods appropriate to their collection type. PairList children are PairNode objects in pair order; indexed_child uses global pair index, while named_indexed_child uses the occurrence index among pairs with the same key.

  • KDLDocumentNode, KDLNodeNode, KDLValueNode

    KDL node wrappers. They inherit the Node API and expose KDL children, attributes, names, value tags, and scalar coercions.

  • XmlNodeNode

    XML node wrapper. It inherits the Node API and exposes XML names, children, attributes, sibling traversal, and scalar text values.

  • TimeNode

    std/time wrapper. It inherits the Node API and exposes time attributes plus string and numeric values.

  • PathNode

    std/io path wrapper. It inherits the Node API and exposes path attributes plus string values.

  • WidgetNode

    std/gui/objects widget wrapper. It inherits the Node API and exposes widget children by widget class name and index, plus public widget properties as assignable attributes.

Variables

  • determine_class

    Type: Function. Chooses the concrete node wrapper class for a raw value.

COPYRIGHT AND LICENCE

std/path/z/node is copyright Toby Inkster.

It is free software; you may redistribute it and/or modify it under the terms of either the Artistic License 1.0 or the GNU General Public License version 2.