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

NAME

Config::Maker::Type - describe directive type

SYNOPSIS

  use Config::Maker

  my $type = Config::Maker::Type->new(
    name => $name,
    format => [$typespec => @valuespec],
    children => \@children,
    contexts => \@parents,
    checks => [$check => $path, ...],
    actions => \@actions
  )
    
  $type->add($othertype);
  $othertype->addto($type);
  
  $type->addchecks(@checks)

DESCRIPTION

Config::Maker::Type describe available types of options (and metaconfig options). Each type has 5 parameters. These are:

name

The name of the directive. This is the keyword used in config to specify option of this type.

format

This is a listref, that is passed to the body production in Config::Maker::Grammar. The first element is either simple, named_group or anon_group, to mean option without block, option with value and block and option with only a block respectively. For the first two, rest of the list is passed to the value production of the grammar.

children

This is a list of types, that should be recognized in the body of this type. Parser won't recognize other types when parsing body of this type.

checks

This is a list of keyword-path pairs, that specify how many of different subtypes can appear in an option of this type. The keys may be none, opt, one, mand or any, which mean the following path must have no, at most one, exactly one, at least one and any number of matches respectively. An error is reported when those conditions are not met.

actions

This is a list of perl closures, that shall be invoked when option of this type is parsed. It can do whatever it wants.

The constructor takes these five named arguments and one extra, contexts. The new element is added to those types as a child.

In addition to constructor, there are three methods, add, addto and addchecks. These allow to add children, parents and checks to an already constructed type.

For description how types are constructed from the schema in metaconfig see configit(1).

Special types

There are two special types, / and *, accessible through class methods root and repository.

The / special type represents the top-level of a config or metaconfig file. On top-level, only option types added to this special type are recognized.

The * special type is a repository of types. It is used in schema to store types for reuse.

AUTHOR

Jan Hudec <bulb@ucw.cz>

COPYRIGHT AND LICENSE

Copyright 2004 Jan Hudec. All rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO

configit(1), perl(1), Config::Maker(3pm).