.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "ConfigReader::Values 3pm" .TH ConfigReader::Values 3pm "2022-10-13" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" ConfigReader::Values \- stores a set of configuration values .SH "DESCRIPTION" .IX Header "DESCRIPTION" This class stores a set of configuration values that have been read from a configuration file. Methods are provided to define directives, assign and retrieve values, and to create accessor subroutines. .PP As this class will usually be subclassed to implement a reader for a specific style of configuration files, the user-oriented methods will be described first. Methods used to help implement a subclass are described later. .SH "USER METHODS" .IX Header "USER METHODS" .ie n .SS """directive($directive, [$parser, [$default, [$whence]]])""" .el .SS "\f(CWdirective($directive, [$parser, [$default, [$whence]]])\fP" .IX Subsection "directive($directive, [$parser, [$default, [$whence]]])" Defines a directive named \f(CW$directive\fR for the configuration file. You may optionally specify a parsing function or method for the directive, and a default value. .PP If \f(CW$directive\fR is a simple string, it will be used as both the name of the directive inside of the program and in the configuration file. You can use an array ref of the form .PP .Vb 1 \& [\*(Aqprogram\-name\*(Aq, \*(Aqname1\*(Aq, \*(Aqname2\*(Aq, \*(Aqname3\*(Aq ...] .Ve .PP to use 'program\-name' inside of the program, but to recognize any of \&'name1', 'name2', 'name3' as the name of directive in the configuration file. .PP A directive will be set to undef if you don't specify a default value and it is not set in the configuration file. .PP Any errors or warnings that occur while parsing the default value are normally reported as orginating in the caller's module. You can change the reported location by specifying \f(CW$whence\fR. .ie n .SS """required($directive, [$parser, [$whence]])""" .el .SS "\f(CWrequired($directive, [$parser, [$whence]])\fP" .IX Subsection "required($directive, [$parser, [$whence]])" Defines a directive which must be specified in the configuration file. .ie n .SS """ignore($directive, [$whence])""" .el .SS "\f(CWignore($directive, [$whence])\fP" .IX Subsection "ignore($directive, [$whence])" Defines a directive which will be accepted but ignored in the configuration file. .ie n .SS """directives()""" .el .SS "\f(CWdirectives()\fP" .IX Subsection "directives()" Returns an array of the configuration directive names. .ie n .SS """value($directive, [$whence])""" .el .SS "\f(CWvalue($directive, [$whence])\fP" .IX Subsection "value($directive, [$whence])" Returns the value of the configuration directive \f(CW$directive\fR. .ie n .SS """define_accessors([$package, [@names]])""" .el .SS "\f(CWdefine_accessors([$package, [@names]])\fP" .IX Subsection "define_accessors([$package, [@names]])" Creates subroutines in the caller's package to access configuration values. For example, if one of the configuration directives is named \&\*(L"Input_File\*(R", you can do: .PP .Vb 2 \& $config\->define_accessors(); \& ... \& \& open(IN, Input_File()); .Ve .PP The names of the created subroutines is returned in an array. If you'd like to export the accessor subroutines, you can say: .PP .Vb 1 \& push @EXPORT, $config\->define_accessors(); .Ve .PP You can specify the package in which to create the subroutines with the optional \f(CW$package\fR argument. You may also specify which configuration directives to create accessor subroutines for. By default, subroutines will be created for all the directives. .SH "IMPLEMENTATION METHODS" .IX Header "IMPLEMENTATION METHODS" The following methods will probably be called by a subclass implementing a reader for a particular style of configuration files. .SS "new( [$spec] )" .IX Subsection "new( [$spec] )" The static method \fBnew()\fR creates and returns a new ConfigReader::Values object. .PP Unless the optional \f(CW$spec\fR argument is present, a new ConfigReader::Spec object will be created to store the configuration specification. The \fBdirective()\fR, \fBrequired()\fR, \fBignore()\fR, \fBvalue()\fR, and \&\fBdirective()\fR methods described above are passed through to the spec object. .PP By setting \f(CW$spec\fR, you can use a different class (perhaps a subclass) to store the specification. .PP You can also set \f(CW$spec\fR if you want to use one specification for multiple sets of values. Files like /etc/termcap describe a configuration for multiple objects (terminals, in this case), but use the same directives to describe each object. .ie n .SS """values()""" .el .SS "\f(CWvalues()\fP" .IX Subsection "values()" Returns the hash ref which actually stores the configuration directive values. The key of the hash ref is the directive name. .ie n .SS """spec()""" .el .SS "\f(CWspec()\fP" .IX Subsection "spec()" Returns the internal spec object used to store the configuration specification. .ie n .SS """assign($directive, $value_string, $whence)""" .el .SS "\f(CWassign($directive, $value_string, $whence)\fP" .IX Subsection "assign($directive, $value_string, $whence)" Normally called while reading the configuration file, assigns a value to the directive named \f(CW$directive\fR. The \f(CW$value_string\fR will be parsed by the directive's parsing function or method, if any. \f(CW$whence\fR should describe the line in the configuration file which contained the value string. .ie n .SS """assign_defaults($whence)""" .el .SS "\f(CWassign_defaults($whence)\fP" .IX Subsection "assign_defaults($whence)" After the configuration file is read, the \fBassign_defaults()\fR method is called to assign the default values for directives which were not specified in the configuration file. \f(CW$whence\fR should describe the name of the configuration file.