diff options
Diffstat (limited to 'lib/Config/HAProxy/Node.pm')
-rw-r--r-- | lib/Config/HAProxy/Node.pm | 137 |
1 files changed, 137 insertions, 0 deletions
diff --git a/lib/Config/HAProxy/Node.pm b/lib/Config/HAProxy/Node.pm index be09538..8210067 100644 --- a/lib/Config/HAProxy/Node.pm +++ b/lib/Config/HAProxy/Node.pm | |||
@@ -97,3 +97,140 @@ sub is_empty { 0 } | |||
97 | sub is_comment { 0 } | 97 | sub is_comment { 0 } |
98 | 98 | ||
99 | 1; | 99 | 1; |
100 | __END__ | ||
101 | |||
102 | =head1 NAME | ||
103 | |||
104 | Config::HAProxy::Node - Abstract HAProxy configuration node | ||
105 | |||
106 | =head1 DESCRIPTION | ||
107 | |||
108 | The class B<Config::HAProxy::Node> represents an abstract node in the | ||
109 | HAProxy configuration parse tree. It serves as a base class for classes | ||
110 | representing configuration tree, section, simple statement, comment and | ||
111 | empty line. | ||
112 | |||
113 | =head1 CONSTRUCTOR | ||
114 | |||
115 | $obj = new Config::HAProxy::Node(%args); | ||
116 | |||
117 | Returns new object. B<%args> can contain the following keys: | ||
118 | |||
119 | =over 4 | ||
120 | |||
121 | =item B<kw> | ||
122 | |||
123 | Configuration keyword (string), | ||
124 | |||
125 | =item B<argv> | ||
126 | |||
127 | Reference to the list of arguments. | ||
128 | |||
129 | =item B<orig> | ||
130 | |||
131 | Original text as read from the configuration file. | ||
132 | |||
133 | =item B<locus> | ||
134 | |||
135 | Locus (a B<Text::Locus> object) where this statement occurred. | ||
136 | |||
137 | =item B<parent> | ||
138 | |||
139 | Parent node. | ||
140 | |||
141 | =back | ||
142 | |||
143 | =head1 METHODS | ||
144 | |||
145 | =head2 B<kw>, B<argv>, B<orig>, B<locus>, B<parent> | ||
146 | |||
147 | These methods return the corresponding field of the node. When called | ||
148 | with an argument, they set the field prior to returning it. The B<argv> | ||
149 | method returns array of strings and takes as its argument a reference to | ||
150 | the array of strings: | ||
151 | |||
152 | @a = $node->argv; | ||
153 | |||
154 | $node->argv([@a]); | ||
155 | |||
156 | =head2 index | ||
157 | |||
158 | Index (0-based) of this node in the parent node. | ||
159 | |||
160 | =head2 arg | ||
161 | |||
162 | $a = $node->arg($n) | ||
163 | |||
164 | Returns the B<$n>th argument (0-based) from the argument list. | ||
165 | |||
166 | =head2 drop | ||
167 | |||
168 | $node->drop; | ||
169 | |||
170 | Removes this node and destroys it. | ||
171 | |||
172 | =head2 iterator | ||
173 | |||
174 | $itr = $node->iterator(@args); | ||
175 | |||
176 | Returns the iterator for this node. See B<Config::HAProxy::Iterator> for | ||
177 | a detailed discussion. | ||
178 | |||
179 | =head2 depth | ||
180 | |||
181 | $n = $node->depth; | ||
182 | |||
183 | Returns the depth of this node in the configuration tree. Depth is the | ||
184 | number of parent nodes between the root of tree and this node. Top-level | ||
185 | nodes have depth 0. | ||
186 | |||
187 | =head2 root | ||
188 | |||
189 | $root_node = $node->root; | ||
190 | |||
191 | Returns the root node of the parse tree this node belongs to. | ||
192 | |||
193 | =head2 as_string | ||
194 | |||
195 | $s = $node->as_string; | ||
196 | |||
197 | Returns canonical string representation of this node. The canonical | ||
198 | representation consists of the keyword followed by arguments delimited | ||
199 | with horizontal space characters. | ||
200 | |||
201 | =head1 ABSTRACT METHODS | ||
202 | |||
203 | Derived classes must overload at least one of the following methods: | ||
204 | |||
205 | =head2 is_root | ||
206 | |||
207 | True if the node is a root node, false otherwise. | ||
208 | |||
209 | =head2 is_section | ||
210 | |||
211 | True if the node represents a section (i.e. contains subnodes). | ||
212 | |||
213 | =head2 is_statement | ||
214 | |||
215 | True if the node is a simple statement. | ||
216 | |||
217 | =head2 is_empty | ||
218 | |||
219 | True if the node represents an empty line. | ||
220 | |||
221 | =head2 is_comment | ||
222 | |||
223 | True if the node represents a comment. | ||
224 | |||
225 | =head1 SEE ALSO | ||
226 | |||
227 | B<Config::HAProxy::Node::Comment>, | ||
228 | B<Config::HAProxy::Node::Empty>, | ||
229 | B<Config::HAProxy::Node::Root>, | ||
230 | B<Config::HAProxy::Node::Section>, | ||
231 | B<Config::HAProxy::Node::Statement>, | ||
232 | B<Config::HAProxy::Iterator>, | ||
233 | B<Config::HAProxy>, | ||
234 | B<Text::Locus>. | ||
235 | |||
236 | =cut | ||