Apache-ConfigParser
view release on metacpan or search on metacpan
lib/Apache/ConfigParser/Directive.pm view on Meta::CPAN
# You can set undef values for the strings.
$d->value(undef);
=head1 DESCRIPTION
The C<Apache::ConfigParser::Directive> module is a subclass of
C<Tree::DAG_Node>, which provides methods to represents nodes in a
tree. Each node is a single Apache configuration directive or root
node for a context, such as <Directory> or <VirtualHost>. All of the
methods in that module are available here. This module adds some
additional methods that make it easier to represent Apache directives
and contexts.
This module holds a directive or context:
name
value in string form
value in array form
a separate value termed 'original' in string form
a separate value termed 'original' in array form
the filename where the directive was set
the line number in the filename where the directive was set
The 'original' value is separate from the non-'original' value and the
methods to operate on the two sets of values have distinct names. The
'original' value can be used to store the original value of a
directive while the non-'directive' value can be a modified form, such
as changing the CustomLog filename to make it absolute. The actual
use of these two distinct values is up to the caller as this module
does not link the two in any way.
=head1 METHODS
The following methods are available:
=over
=cut
=item $d = Apache::ConfigParser::Directive->new;
This creates a brand new C<Apache::ConfigParser::Directive> object.
It is not recommended to pass any arguments to C<new> to set the
internal state and instead use the following methods.
There actually is no C<new> method in the
C<Apache::ConfigParser::Directive> module. Instead, due to
C<Apache::ConfigParser::Directive> being a subclass of
C<Tree::DAG_Node>, C<Tree::DAG_Node::new> will be used.
=cut
# The Apache::ConfigParser::Directive object still needs to be
# initialized. This is done here. Tree::DAG_Node->new calls
# Apache::ConfigParser::Directive->_init, which will call
# Tree::DAG_Node->_init.
sub _init {
my $self = shift;
$self->SUPER::_init;
$self->{name} = '';
$self->{value} = '';
$self->{value_array} = [];
$self->{orig_value} = '';
$self->{orig_value_array} = [];
$self->{filename} = '';
$self->{line_number} = -1;
}
=item $d->name
=item $d->name($name)
In the first form get the directive or context's name. In the second
form set the new name of the directive or context to the lowercase
version of I<$name> and return the original name.
=cut
sub name {
unless (@_ < 3) {
confess "$0: Apache::ConfigParser::Directive::name ",
$INCORRECT_NUMBER_OF_ARGS;
}
my $self = shift;
if (@_) {
my $old = $self->{name};
$self->{name} = lc($_[0]);
return $old;
} else {
return $self->{name};
}
}
=item $d->value
=item $d->value($value)
In the first form get the directive's value in string form. In the
second form, return the previous directive value in string form and
set the new directive value to I<$value>. I<$value> can be set to
undef.
If the value is being set, then I<$value> is saved so another call to
C<value> will return I<$value>. If I<$value> is defined, then
I<$value> is also parsed into an array of elements that can be
retrieved with the C<value_array_ref> or C<get_value_array> methods.
The parser separates elements by whitespace, unless whitespace
separated elements are enclosed by "'s. Protected quotes, \", are
honored to not begin or end a value element.
=item $d->orig_value
=item $d->orig_value($value)
Identical behavior as C<value>, except that this applies to a the
'original' value. Use C<orig_value_ref> or C<get_orig_value_array> to
get the value elements.
( run in 0.625 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )