The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Config::HAProxy::Node - Abstract HAProxy configuration node

DESCRIPTION

The class Config::HAProxy::Node represents an abstract node in the HAProxy configuration parse tree. It serves as a base class for classes representing configuration tree, section, simple statement, comment and empty line.

CONSTRUCTOR

    $obj = new Config::HAProxy::Node(%args);

Returns new object. %args can contain the following keys:

kw

Configuration keyword (string),

argv

Reference to the list of arguments.

orig

Original text as read from the configuration file.

locus

Locus (a Text::Locus object) where this statement occurred.

parent

Parent node.

METHODS

kw, argv, orig, locus, parent

These methods return the corresponding field of the node. When called with an argument, they set the field prior to returning it. The argv method returns array of strings and takes as its argument a reference to the array of strings:

    @a = $node->argv;

    $node->argv([@a]);

index

Index (0-based) of this node in the parent node.

arg

    $a = $node->arg($n)

Returns the $nth argument (0-based) from the argument list.

drop

    $node->drop;

Removes this node and destroys it.

iterator

    $itr = $node->iterator(@args);

Returns the iterator for this node. See Config::HAProxy::Iterator for a detailed discussion.

depth

    $n = $node->depth;

Returns the depth of this node in the configuration tree. Depth is the number of parent nodes between the root of tree and this node. Top-level nodes have depth 0.

root

    $root_node = $node->root;

Returns the root node of the parse tree this node belongs to.

as_string

    $s = $node->as_string;

Returns canonical string representation of this node. The canonical representation consists of the keyword followed by arguments delimited with horizontal space characters.

ABSTRACT METHODS

Derived classes must overload at least one of the following methods:

is_root

True if the node is a root node, false otherwise.

is_section

True if the node represents a section (i.e. contains subnodes).

is_statement

True if the node is a simple statement.

is_empty

True if the node represents an empty line.

is_comment

True if the node represents a comment.

SEE ALSO

Config::HAProxy::Node::Comment, Config::HAProxy::Node::Empty, Config::HAProxy::Node::Root, Config::HAProxy::Node::Section, Config::HAProxy::Node::Statement, Config::HAProxy::Iterator, Config::HAProxy, Text::Locus.