NAME

Config::Proxy::Node - Abstract Proxy configuration node

DESCRIPTION

The class Config::Proxy::Node represents an abstract node in the Proxy 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::Proxy::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::Proxy::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.

write

$node->write([$file, %hash]);

Writes the node to the named file or file handle. First argument can be a file name, file handle or a string reference. If it is the only argument, the original indentation is preserved. Otherwise, if %hash controls the indentation of the output. It must contain at least the indent key, which specifies the amount of indentation per nesting level. If tabstop key is also present, its value must be a reference to the list of tabstop columns. For each statement with arguments, this array is consulted to determine the column number for each subsequent argument. Arguments are zero-indexed. Starting column where the argument should be placed is determined as $tabstop[$i], where $i is the argument index. Arguments with $i greater than or equal to @tabstop are appended to the resulting output, preserving their original offsets.

Normally, comments retain their original indentation. However, if the key reindent_comments is present, and its value is evaluated as true, then comments are reindented following the rules described above.

Called without arguments, this method writes the node content to standard output in unaltered form.

format

$node->format($file, %hash);

Writes the node to the $file. See write for a detailed discussion. The difference between format and write is that format outputs only the node itself, and does not descend into its subordinate nodes.

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::Proxy::Node::Comment, Config::Proxy::Node::Empty, Config::Proxy::Node::Root, Config::Proxy::Node::Section, Config::Proxy::Node::Statement, Config::Proxy::Iterator, Config::Proxy, Text::Locus, Config::HAProxy, Config::Pound.