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

NAME

FLTK::Preferences - Application preferences

Description

Preferences are data trees containing a root, branches and leaves.

Functions

deleteEntry

my $gone = $preferences->deleteEntry( $entry );

Delete a group.

deleteGroup

my $removed = $preferences->deleteGroup( $group );

Delete a group.

destroy

$preferences->destroy( );

Destroy individual keys.

Destroying the base preferences will flush changes to the prefs file. After destroying the base, none of the depending preferences must be read or written.

entries

my $count = $preferences->entries( );

Returns the number of entries (key/value) pairs for a group.

entry

my $key = $preferences->entry( $index );

Returns the name of an entry. There is no guaranteed order of entry names and $index must be within the range given by entries().

entryExists

my $exists = $preferences->entryExists( $entry );

Returns 1, if a group with this name exists.

flush

$preferences->flush( );

Writes all preferences to disk. This method works only with the base preference group.

Note: This method is rarely used as the preferences flush automatically when destroy( ) is called or when the base preferences go out of scope.

get

my $value = $preferences->get( $key, $value, $defaultValue );

Get an entry (key/value) pair.

getUserdataPath

my $path = $preferences->getUserdataPath( );

Creates a path that is related to the preferences file and that is usable for application data beyond what is covered by Preferences.

group

my $name = $preferences->group( $index );

Returns the group name of the $indexth group. There is no guaranteed order of group names and $index must be within the range given by groups( ).

groupExists

my $exists = $preferences->groupExists( $group );

Returns 1, if a group with this name exists.

groups

my $count = $preferences->groups( );

Returns the number of groups that are contained within a group.

new

my $tree = $preferences->new( $root, $vendor, $application );

Creates a new preferences object.

  • $root is a value representing either per machine (FLTK::Preferences::SYSTEM) or per user (FLTK::Preferences::USER) settings.

  • vendor is the unique identification of the author or vendor of $application.

    Note: vendor must be a valid directory name.

  • $application is a vendor unique application name, for example, PreferencesTest. Multiple preferences files can be created per application.

    Note: application name must be a valid file name.

my $node = $preferences->new( $parent, $group );

Creates a Preferences node in relation to a parent node for reading and writing

  • $parent is the base name for the group.

  • $group is a group name which may contain / separated group names.

Example:

  my $colors = FLTK::Preferences->new( $prefs, 'setup/colors' );
my $prefs = $preferences->new( $path, $vendor, $application );

Creates a Preferences object.

  • $path is an application-supplied path.

set

my $okay = $preferences->set( $entry, $value );

Set an entry (key/value) pair.

size

my $length = $preferences->size( $key );

Returns the size of the value part of an entry.

Author

Sanko Robinson <sanko@cpan.org> - http://sankorobinson.com/

License and Legal

Copyright (C) 2008-2010 by Sanko Robinson <sanko@cpan.org>

This program is free software; you can redistribute it and/or modify it under the terms of The Artistic License 2.0. See the LICENSE file included with this distribution or notes on the Artistic License 2.0 for clarification.

When separated from the distribution, all original POD documentation is covered by the Creative Commons Attribution-Share Alike 3.0 License. See the clarification of the CCA-SA3.0.