Config::Objective::Hash - hash data type class for Config::Objective
use Config::Objective;
use Config::Objective::Hash;
my $conf = Config::Objective->new('filename', {
'hashobj' => Config::Objective::Hash->new(
'value_abspath' => 1,
...
)
});
The Config::Objective::Hash module provides a class that represents a
hash in an object so that it can be used with Config::Objective. Its
methods can be used to manipulate the encapsulated hash from the config file.
The Config::Objective::Hash class is derived from the
Config::Objective::DataType class, but it defines/overrides the
following methods:
- insert()
- Inserts the specified values into the object's hash. The argument must be
a reference to a hash, whose keys and values are copied into the object's
hash.
If the values are lists, inserting a key that already exists
will append the new list to the existing list. If the values are hashes,
inserting a key that already exists will insert the new key/value pairs
into the existing value hash.
If the object was created with the value_optional
attribute enabled, keys may be inserted with no defined values.
If the object was created with the value_type attribute
set to either "ARRAY" or "HASH", then the hash
values must be references to the corresponding structure type.
If the object was created with the value_abspath
attribute enabled, the hash values must be absolute path strings.
If the object was created with the key_abspath
attribute enabled, the hash keys must be absolute path strings.
- set()
- The same as insert(), except that the existing hash is emptied by
calling the unset() method before inserting the new data.
- default()
- Calls the insert() method.
- unset()
- Sets the object's value to an empty hash.
- delete()
- Deletes a specific hash key. The argument can be a scalar or a reference
to a list, in which case all of the keys in the list are deleted.
- exists()
- Returns true if the argument is found in the hash, false otherwise.
- find()
- If the argument is found in the hash, returns its value. Otherwise,
returns false.
The value_abspath and key_abspath attributes should be replaced by
a generic mechanism that allows the caller to supply a reference to a
subroutine that will be called to validate the key and value data.
Mark D. Roth <roth@uiuc.edu>
perl
Config::Objective
Config::Objective::DataType