From 44bb5f60de2bd7162a6de2d0cb73377ce1a55bc1 Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Sun, 28 Apr 2002 16:41:17 +0000 Subject: Add Fl_Preferences class to base library. Add FLTK_DATADIR definition to config.h for system-wide configuration data. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@2126 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- documentation/Fl_Preferences.html | 184 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 184 insertions(+) create mode 100644 documentation/Fl_Preferences.html (limited to 'documentation/Fl_Preferences.html') diff --git a/documentation/Fl_Preferences.html b/documentation/Fl_Preferences.html new file mode 100644 index 000000000..966cf08e2 --- /dev/null +++ b/documentation/Fl_Preferences.html @@ -0,0 +1,184 @@ + + + + + +

class Fl_Preferences

+ +
+ +

Class Hierarchy

+ + + +

Include Files

+ + + +

Description

+ +

Fl_Preferences provides methods to store user +setting between application starts. It is similar to the +Registry on WIN32 and Preferences on MacOS, and provides a +simple configuration mechanism for UNIX. + +

Fl_Preferences uses a hierarchy to store data. It +bundles similar data into groups and manages entries into those +groups as name/value pairs. + +

Preferences are stored in text files that can be edited +manually. The file format is easy to read and relatively +forgiving. Preferences files are the same on all platforms. User +comments in preference files are preserved. Filenames are unique +for each application by using a vendor/application naming +scheme. The user must provide default values for all entries to +ensure proper operation should preferences be corrupted or not +yet exist. + +

Entries can be of any length. However, the size of each +preferences file should be kept under 100k for performance +reasons. One application can have multiple preferences files. +Extensive binary data however should be stored in seperate +files; see the getUserdataPath() +method. + +

Methods

+ + + +

Fl_Preferences(enum Root root, +const char *vendor, const char *application)
+Fl_Preferences(Fl_Preferences &p, const char *groupname)

+ +

The constructor creates a group that manages name/value pairs and +child groups. Groups are ready for reading and writing at any time. +The root argument is either Fl_Preferences::USER +or Fl_Preferences::SYSTEM. + +

The first format creates the base instance for all +following entries and reads existing databases into memory. The +vendor argument is a unique text string identifying the +development team or vendor of an application. A domain name or +an EMail address are great unique names, e.g. +"researchATmatthiasm.com" or "fltk.org". The +application argument can be the working title or final +name of your application. Both vendor and +application must be valid relative UNIX pathnames and +may contain '/'s to create deeper file structures. + +

The groupname argument identifies a group of +entries. It can contain '/'s to get quick access to individual +elements inside the hierarchy. + +

~Fl_Preferences()

+ +

The destructor removes allocated resources. When used on the +base preferences group, the destructor flushes all +changes to the preferences file and deletes all internal +databases. + +

int Fl_Preferences::deleteEntry(const char *entry)

+ +

Removes a single entry (name/value pair). + +

int Fl_Preferences::deleteGroup(const char *groupname)

+ +

Deletes a group. + +

int Fl_Preferences::entries()

+ +

Returns the number of entries (name/value) pairs in a group. + +

const char *Fl_Preferences::entry(int ix)

+ +

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

int Fl_Preferences::entryExists(const char *entry)

+ +

Returns non-zero if an entry with this name exists. + +

void Fl_Preferences::flush()

+ +

Write all preferences to disk. This function works only with +the base preference group. This function is rarely used as +deleting the base preferences flushes automatically. + +

int Fl_Preferences::getUserdataPath(char *path)

+ +

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

int get(const char *entry, int &value,   int defaultValue)
+int get(const char *entry, int &value,    int defaultValue)
+int get(const char *entry, float &value,  float defaultValue)
+int get(const char *entry, double &value, double defaultValue ) +int get(const char *entry, char *&value,  const char *defaultValue)
+int get(const char *entry, char *value,   const char *defaultValue, +int maxSize)

+ +

Reads an entry from the group. A default value must be +supplied. The return value indicates if the value was available +(non-zero) or the default was used (0). If the 'char +*&value' form is used, the resulting text must be freed +with 'free(value)'. + +

const char +*Fl_Preferences::group(int ix)

+ +

Returns the name of the Nth group. There is no guaranteed +order of group names. The index must be within the range given +by groups(). + +

int Fl_Preferences::groupExists(const char *groupname)

+ +

Returns non-zero if a group with this name exists. + +

int Fl_Preferences::groups()

+ +

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

int set(const char *entry, int value)
+int set(const char *entry, int value)
+int set(const char *entry, float value)
+int set(const char *entry, double value)
+int set(const char *entry, const char *value)

+ +

Sets an entry (name/value pair). Text data must not contain +any '\n' or '\r' characters. The return value indicates if there +was a problem storing the data in memory. However it does not +reflect if the value was actually stored in the preferences +file. + +

int Fl_Preferences::size(const char *key)

+ +

Returns the size of the value part of an entry. + + + + -- cgit v1.2.3