Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

Fl_Config Class Reference

The configuration holder. More...

#include <Fl_Config.h>

Inheritance diagram for Fl_Config:

Fl_Config_Section List of all members.

Public Types

enum  ConfigType { USER = 1, SYSTEM }
 Config file modes. More...


Public Methods

 Fl_Config (const char *vendor, const char *application, int mode=USER)
 Creates/reads/writes app specific config file. More...

 Fl_Config (const char *filename, bool readfile=true, bool createfile=true)
 Access custom file in filesystem. More...

virtual ~Fl_Config ()
 Destroys config.

bool read_file (bool create=true)
 (re)read file. More...

bool flush ()
 Flush entries to file. More...

const Fl_Stringfilename () const
 Returns current filename.

void filename (const char *filename)
 Set new filename. More...

void filename (const Fl_String &filename)
 Set new filename. More...

const Fl_Stringvendor () const
 Returns current vendor name.

void vendor (const char *vendor)
 Set new vendor name.

void vendor (const Fl_String &vendor)
 Set new vendor name.

const Fl_Stringapplication () const
 Returns current application name.

void application (const char *app)
 Set new application name.

void application (const Fl_String &app)
 Set new application name.

bool is_changed () const
 Returns true, if data changed. More...

void set_changed ()
 Set changed, forces flush() to write file. More...

int error () const
 Returns last error happened.

void reset_error ()
 Reset error, normally you don't need to call this.

const char * strerror () const
 Return string presentation for last happened error.

Fl_Config_Sectioncreate_section (const char *path)
 Create new section. More...

Fl_Config_Sectioncreate_section (const Fl_String &path)
 Create new section. More...

Fl_Config_Sectionfind_section (const char *path, bool perfect_match=true) const
 Find section. More...

Fl_Config_Sectionssection_list (const char *secpath) const
 Return child sections of section specified 'secpath'.

Fl_Config_Linesline_list (const char *secpath) const
 Return entries of section specified 'secpath'.

void set_section (const char *secpath)
 Set default section for read/write operations. More...

void set_section (Fl_Config_Section *sec)
 Set default section for read/write operations.

void remove_key (const char *section, const char *key)
 Remove entry associated with 'key' from section. More...

void remove_sec (const char *section)
 Remove section specified by 'section'. More...

int read (const char *key, Fl_String &ret, const char *def_value)
 Read Fl_String entry from config. More...

int read (const char *key, char *ret, const char *def_value, int size)
 Read char* entry from config. More...

int read (const char *key, char *&ret, const char *def_value=0)
 Read char* entry from config. More...

int read (const char *key, long &ret, long def_value=0)
 Read long entry from config. More...

int read (const char *key, int &ret, int def_value=0)
 Read int entry from config. More...

int read (const char *key, float &ret, float def_value=0)
 Read float entry from config. More...

int read (const char *key, double &ret, double def_value=0)
 Read double entry from config. More...

int read (const char *key, bool &ret, bool def_value=0)
 Read bool entry from config. More...

int read (const char *key, Fl_Color &ret, Fl_Color def_value=0)
 Read Fl_Color entry from config. More...

int write (const char *key, const Fl_String &value)
 Write Fl_String entry to config. More...

int write (const char *key, const char *value)
 Write const char* entry to config. More...

int write (const char *key, const long value)
 Write long entry to config. More...

int write (const char *key, const int value)
 Write int entry to config. More...

int write (const char *key, const float value)
 Write float entry to config. More...

int write (const char *key, const double value)
 Write double entry to config. More...

int write (const char *key, const bool value)
 Write bool entry to config. More...

int write (const char *key, const Fl_Color value)
 Write Fl_Color entry to config. More...

int get (const char *section, const char *key, Fl_String &ret, const char *def_value)
 Read Fl_String entry from config. More...

int get (const char *section, const char *key, char *ret, const char *def_value, int size)
 Read char* entry from config. More...

int get (const char *section, const char *key, char *&ret, const char *def_value=0)
 Read char* entry from config. More...

int get (const char *section, const char *key, long &ret, long def_value=0)
 Read long entry from config. More...

int get (const char *section, const char *key, int &ret, int def_value=0)
 Read int entry from config. More...

int get (const char *section, const char *key, float &ret, float def_value=0)
 Read float entry from config. More...

int get (const char *section, const char *key, double &ret, double def_value=0)
 Read double entry from config. More...

int get (const char *section, const char *key, bool &ret, bool def_value=0)
 Read bool entry from config. More...

int get (const char *section, const char *key, Fl_Color &ret, Fl_Color def_value=0)
 Read Fl_Color entry from config. More...

int set (const char *section, const char *key, const Fl_String &value)
 Write Fl_String entry to config. More...

int set (const char *section, const char *key, const char *value)
 Write const char *entry to config. More...

int set (const char *section, const char *key, const long value)
 Write long entry to config. More...

int set (const char *section, const char *key, const int value)
 Write int entry to config. More...

int set (const char *section, const char *key, const float value)
 Write float entry to config. More...

int set (const char *section, const char *key, const bool value)
 Write bool entry to config. More...

int set (const char *section, const char *key, const Fl_Color value)
 Write Fl_Color entry to config. More...


Static Public Methods

char * find_config_file (const char *filename, bool create=true, int mode=USER)
 Finds config file, depending on mode. More...

const char * strerror (int errnum)
 Return error string, associated with 'errnum'.


Detailed Description

The configuration holder.

This class maybe used very easily to store application settings to file. Either system wide or user specific, depending on config type. Fl_Config is derived Fl_Config_Section, please take look a look at functions it provides also.

See also:
Fl_Config_Section

Definition at line 149 of file Fl_Config.h.


Member Enumeration Documentation

enum Fl_Config::ConfigType
 

Config file modes.

Enumeration values:
USER  User specific config file.
SYSTEM  System wide config file.

Definition at line 155 of file Fl_Config.h.


Constructor & Destructor Documentation

Fl_Config::Fl_Config const char *    vendor,
const char *    application,
int    mode = USER
 

Creates/reads/writes app specific config file.

LINUX:
File is created in ($home)/.ede/apps/($application)/($application).conf Or ($prefix)/share/ede/apps/($application)/($application).conf


WIN32:
($home)\Local Settings\.ede\apps\($application)/($application).conf Or ($common files)\($application)\($application).conf

Location depends on ConfigType 'mode', USER or SYSTEM

Parameters:
vendor  aplication vendor, written down to file
application  name, written down to file
mode  which mode to use

Fl_Config::Fl_Config const char *    filename,
bool    readfile = true,
bool    createfile = true
 

Access custom file in filesystem.

Parameters:
filename  path to config (ini) file.
readfile  if true, file is readed on constructor. I.e no need for read_file()
createfile  if true, file is created if it doesn't exists.


Member Function Documentation

Fl_Config_Section* Fl_Config::create_section const Fl_String   path
 

Create new section.

You can pass full path as section name. For example: create_section("/path/to/my/section"); All nested sections are created automatically.

Returns pointer to created section, NULL if failed.

Fl_Config_Section* Fl_Config::create_section const char *    path [inline]
 

Create new section.

You can pass full path as section name. For example: create_section("/path/to/my/section"); All nested sections are created automatically.

Returns pointer to created section, NULL if failed.

Definition at line 287 of file Fl_Config.h.

void Fl_Config::filename const Fl_String   filename [inline]
 

Set new filename.

You need to call read_file() to get new entries.

Definition at line 231 of file Fl_Config.h.

void Fl_Config::filename const char *    filename [inline]
 

Set new filename.

You need to call read_file() to get new entries.

Definition at line 229 of file Fl_Config.h.

char* Fl_Config::find_config_file const char *    filename,
bool    create = true,
int    mode = USER
[static]
 

Finds config file, depending on mode.

NOTE: User MUST NOT free returned pointer!

LINUX:
File is created in ($home)/.ede/apps/($application)/($application).conf Or ($prefix)/share/ede/apps/($application)/($application).conf


WIN32:
($home)\Local Settings\.ede\apps\($application)/($application).conf Or ($common files)\($application)\($application).conf

Parameters:
filename  Relative filename, e.g. "myapp_config.ini"
create  if true, path is returned even if file is not found. Otherwise NULL if path not found.
mode  which mode to use

Fl_Config_Section* Fl_Config::find_section const char *    path,
bool    perfect_match = true
const
 

Find section.

You can pass full path as section name. For example: find_section("/path/to/my/section");

Returns pointer to found section, NULL if not found.

Parameters:
perfect_match  is true, it returns NULL if no exact section found. Otherwise it returns last found section in path.

bool Fl_Config::flush  
 

Flush entries to file.

Returns true on success.

See also:
filename()

int Fl_Config::get const char *    section,
const char *    key,
Fl_Color &    ret,
Fl_Color    def_value = 0
[inline]
 

Read Fl_Color entry from config.

Returns CONF_SUCCESS on success, otherwise errorcode. NOTE: section must be set as first parameter!

Parameters:
section  Section for entry
key  Key to entry.
ret  Result is stored to this.
def_value  Default value for ret, if not found.

Definition at line 633 of file Fl_Config.h.

int Fl_Config::get const char *    section,
const char *    key,
bool &    ret,
bool    def_value = 0
[inline]
 

Read bool entry from config.

Returns CONF_SUCCESS on success, otherwise errorcode. NOTE: section must be set as first parameter!

Parameters:
section  Section for entry
key  Key to entry.
ret  Result is stored to this.
def_value  Default value for ret, if not found.

Definition at line 621 of file Fl_Config.h.

int Fl_Config::get const char *    section,
const char *    key,
double &    ret,
double    def_value = 0
[inline]
 

Read double entry from config.

Returns CONF_SUCCESS on success, otherwise errorcode. NOTE: section must be set as first parameter!

Parameters:
section  Section for entry
key  Key to entry.
ret  Result is stored to this.
def_value  Default value for ret, if not found.

Definition at line 609 of file Fl_Config.h.

int Fl_Config::get const char *    section,
const char *    key,
float &    ret,
float    def_value = 0
[inline]
 

Read float entry from config.

Returns CONF_SUCCESS on success, otherwise errorcode. NOTE: section must be set as first parameter!

Parameters:
section  Section for entry
key  Key to entry.
ret  Result is stored to this.
def_value  Default value for ret, if not found.

Definition at line 597 of file Fl_Config.h.

int Fl_Config::get const char *    section,
const char *    key,
int &    ret,
int    def_value = 0
[inline]
 

Read int entry from config.

Returns CONF_SUCCESS on success, otherwise errorcode. NOTE: section must be set as first parameter!

Parameters:
section  Section for entry
key  Key to entry.
ret  Result is stored to this.
def_value  Default value for ret, if not found.

Definition at line 585 of file Fl_Config.h.

int Fl_Config::get const char *    section,
const char *    key,
long &    ret,
long    def_value = 0
[inline]
 

Read long entry from config.

Returns CONF_SUCCESS on success, otherwise errorcode. NOTE: section must be set as first parameter!

Parameters:
section  Section for entry
key  Key to entry.
ret  Result is stored to this.
def_value  Default value for ret, if not found.

Definition at line 573 of file Fl_Config.h.

int Fl_Config::get const char *    section,
const char *    key,
char *&    ret,
const char *    def_value = 0
[inline]
 

Read char* entry from config.

Returns CONF_SUCCESS on success, otherwise errorcode. NOTE: 'ret' is allocated by Fl_Confing, user MUST free 'ret' by calling free() function. NOTE: section must be set as first parameter!

Parameters:
section  Section for entry
key  Key to entry.
ret  Result is stored to this.
def_value  Default value for ret, if not found.

Definition at line 561 of file Fl_Config.h.

int Fl_Config::get const char *    section,
const char *    key,
char *    ret,
const char *    def_value,
int    size
[inline]
 

Read char* entry from config.

Returns CONF_SUCCESS on success, otherwise errorcode. NOTE: section must be set as first parameter!

Parameters:
section  Section for entry
key  Key to entry.
ret  Result is stored to this.
def_value  Default value for ret, if not found.

Definition at line 548 of file Fl_Config.h.

int Fl_Config::get const char *    section,
const char *    key,
Fl_String   ret,
const char *    def_value
[inline]
 

Read Fl_String entry from config.

Returns CONF_SUCCESS on success, otherwise errorcode. NOTE: section must be set as first parameter!

Parameters:
section  Section for entry
key  Key to entry.
ret  Result is stored to this.
def_value  Default value for ret, if not found.

Definition at line 536 of file Fl_Config.h.

bool Fl_Config::is_changed   const [inline]
 

Returns true, if data changed.

call flush() to sync changes to file

See also:
flush()

Definition at line 252 of file Fl_Config.h.

int Fl_Config::read const char *    key,
Fl_Color &    ret,
Fl_Color    def_value = 0
[inline]
 

Read Fl_Color entry from config.

Returns CONF_SUCCESS on success, otherwise errorcode. NOTE: This function assumes that current section is set with set_section().

Parameters:
key  Key to entry.
ret  Result is stored to this.
def_value  Default value for ret, if not found.

Definition at line 442 of file Fl_Config.h.

int Fl_Config::read const char *    key,
bool &    ret,
bool    def_value = 0
[inline]
 

Read bool entry from config.

Returns CONF_SUCCESS on success, otherwise errorcode. NOTE: This function assumes that current section is set with set_section().

Parameters:
key  Key to entry.
ret  Result is stored to this.
def_value  Default value for ret, if not found.

Definition at line 431 of file Fl_Config.h.

int Fl_Config::read const char *    key,
double &    ret,
double    def_value = 0
[inline]
 

Read double entry from config.

Returns CONF_SUCCESS on success, otherwise errorcode. NOTE: This function assumes that current section is set with set_section().

Parameters:
key  Key to entry.
ret  Result is stored to this.
def_value  Default value for ret, if not found.

Definition at line 420 of file Fl_Config.h.

int Fl_Config::read const char *    key,
float &    ret,
float    def_value = 0
[inline]
 

Read float entry from config.

Returns CONF_SUCCESS on success, otherwise errorcode. NOTE: This function assumes that current section is set with set_section().

Parameters:
key  Key to entry.
ret  Result is stored to this.
def_value  Default value for ret, if not found.

Definition at line 409 of file Fl_Config.h.

int Fl_Config::read const char *    key,
int &    ret,
int    def_value = 0
[inline]
 

Read int entry from config.

Returns CONF_SUCCESS on success, otherwise errorcode. NOTE: This function assumes that current section is set with set_section().

Parameters:
key  Key to entry.
ret  Result is stored to this.
def_value  Default value for ret, if not found.

Definition at line 398 of file Fl_Config.h.

int Fl_Config::read const char *    key,
long &    ret,
long    def_value = 0
[inline]
 

Read long entry from config.

Returns CONF_SUCCESS on success, otherwise errorcode. NOTE: This function assumes that current section is set with set_section().

Parameters:
key  Key to entry.
ret  Result is stored to this.
def_value  Default value for ret, if not found.

Definition at line 387 of file Fl_Config.h.

int Fl_Config::read const char *    key,
char *&    ret,
const char *    def_value = 0
[inline]
 

Read char* entry from config.

Returns CONF_SUCCESS on success, otherwise errorcode. NOTE: 'ret' is allocated by Fl_Confing, user MUST free 'ret' by calling free() function. NOTE: This function assumes that current section is set with set_section().

Parameters:
key  Key to entry.
ret  Result is stored to this.
def_value  Default value for ret, if not found.

Definition at line 376 of file Fl_Config.h.

int Fl_Config::read const char *    key,
char *    ret,
const char *    def_value,
int    size
[inline]
 

Read char* entry from config.

Returns CONF_SUCCESS on success, otherwise errorcode. NOTE: This function assumes that current section is set with set_section().

Parameters:
key  Key to entry.
ret  Result is stored to this.
def_value  Default value for ret, if not found.
size  of 'ret' char* array.

Definition at line 364 of file Fl_Config.h.

int Fl_Config::read const char *    key,
Fl_String   ret,
const char *    def_value
[inline]
 

Read Fl_String entry from config.

Returns CONF_SUCCESS on success, otherwise errorcode. NOTE: This function assumes that current section is set with set_section().

Parameters:
key  Key to entry.
ret  Result is stored to this.
def_value  Default value for ret, if not found.

Definition at line 352 of file Fl_Config.h.

bool Fl_Config::read_file bool    create = true
 

(re)read file.

NOTE: Deletes current entries from this Fl_Config object.

Parameters:
create  if true, file is created if it doesn't exists.
See also:
filename()

void Fl_Config::remove_key const char *    section,
const char *    key
 

Remove entry associated with 'key' from section.

NOTE: You can pass path to section e.g "/path/to/my/section"

void Fl_Config::remove_sec const char *    section
 

Remove section specified by 'section'.

NOTE: You can pass path to section e.g "/path/to/my/section"

int Fl_Config::set const char *    section,
const char *    key,
const Fl_Color    value
[inline]
 

Write Fl_Color entry to config.

You must call flush() to sunc changes to file. Returns CONF_SUCCESS on success, otherwise errorcode. NOTE: section must be set as first parameter!

Parameters:
section  Section for entry
key  Key to entry.
value  value to set. if entry with 'key' exists, value is replaced.

Definition at line 711 of file Fl_Config.h.

int Fl_Config::set const char *    section,
const char *    key,
const bool    value
[inline]
 

Write bool entry to config.

You must call flush() to sunc changes to file. Returns CONF_SUCCESS on success, otherwise errorcode. NOTE: section must be set as first parameter!

Parameters:
section  Section for entry
key  Key to entry.
value  value to set. if entry with 'key' exists, value is replaced.

Definition at line 700 of file Fl_Config.h.

int Fl_Config::set const char *    section,
const char *    key,
const float    value
[inline]
 

Write float entry to config.

You must call flush() to sunc changes to file. Returns CONF_SUCCESS on success, otherwise errorcode. NOTE: section must be set as first parameter!

Parameters:
section  Section for entry
key  Key to entry.
value  value to set. if entry with 'key' exists, value is replaced.

Definition at line 689 of file Fl_Config.h.

int Fl_Config::set const char *    section,
const char *    key,
const int    value
[inline]
 

Write int entry to config.

You must call flush() to sunc changes to file. Returns CONF_SUCCESS on success, otherwise errorcode. NOTE: section must be set as first parameter!

Parameters:
section  Section for entry
key  Key to entry.
value  value to set. if entry with 'key' exists, value is replaced.

Definition at line 678 of file Fl_Config.h.

int Fl_Config::set const char *    section,
const char *    key,
const long    value
[inline]
 

Write long entry to config.

You must call flush() to sunc changes to file. Returns CONF_SUCCESS on success, otherwise errorcode. NOTE: section must be set as first parameter!

Parameters:
section  Section for entry
key  Key to entry.
value  value to set. if entry with 'key' exists, value is replaced.

Definition at line 667 of file Fl_Config.h.

int Fl_Config::set const char *    section,
const char *    key,
const char *    value
[inline]
 

Write const char *entry to config.

You must call flush() to sunc changes to file. Returns CONF_SUCCESS on success, otherwise errorcode. NOTE: section must be set as first parameter!

Parameters:
section  Section for entry
key  Key to entry.
value  value to set. if entry with 'key' exists, value is replaced.

Definition at line 656 of file Fl_Config.h.

int Fl_Config::set const char *    section,
const char *    key,
const Fl_String   value
[inline]
 

Write Fl_String entry to config.

You must call flush() to sunc changes to file. Returns CONF_SUCCESS on success, otherwise errorcode. NOTE: section must be set as first parameter!

Parameters:
section  Section for entry
key  Key to entry.
value  value to set. if entry with 'key' exists, value is replaced.

Definition at line 645 of file Fl_Config.h.

void Fl_Config::set_changed   [inline]
 

Set changed, forces flush() to write file.

Even if it is not changed.

Definition at line 258 of file Fl_Config.h.

void Fl_Config::set_section const char *    secpath [inline]
 

Set default section for read/write operations.

NOTE: section is created, if it's not found.
NOTE: You can pass path to section e.g "/path/to/my/section"

Definition at line 323 of file Fl_Config.h.

int Fl_Config::write const char *    key,
const Fl_Color    value
[inline]
 

Write Fl_Color entry to config.

You must call flush() to sunc changes to file. Returns CONF_SUCCESS on success, otherwise errorcode. NOTE: This function assumes that current section is set with set_section().

Parameters:
key  Key to entry.
value  value to set. if entry with 'key' exists, value is replaced.

Definition at line 523 of file Fl_Config.h.

int Fl_Config::write const char *    key,
const bool    value
[inline]
 

Write bool entry to config.

You must call flush() to sunc changes to file. Returns CONF_SUCCESS on success, otherwise errorcode. NOTE: This function assumes that current section is set with set_section().

Parameters:
key  Key to entry.
value  value to set. if entry with 'key' exists, value is replaced.

Definition at line 513 of file Fl_Config.h.

int Fl_Config::write const char *    key,
const double    value
[inline]
 

Write double entry to config.

You must call flush() to sunc changes to file. Returns CONF_SUCCESS on success, otherwise errorcode. NOTE: This function assumes that current section is set with set_section().

Parameters:
key  Key to entry.
value  value to set. if entry with 'key' exists, value is replaced.

Definition at line 503 of file Fl_Config.h.

int Fl_Config::write const char *    key,
const float    value
[inline]
 

Write float entry to config.

You must call flush() to sunc changes to file. Returns CONF_SUCCESS on success, otherwise errorcode. NOTE: This function assumes that current section is set with set_section().

Parameters:
key  Key to entry.
value  value to set. if entry with 'key' exists, value is replaced.

Definition at line 493 of file Fl_Config.h.

int Fl_Config::write const char *    key,
const int    value
[inline]
 

Write int entry to config.

You must call flush() to sunc changes to file. Returns CONF_SUCCESS on success, otherwise errorcode. NOTE: This function assumes that current section is set with set_section().

Parameters:
key  Key to entry.
value  value to set. if entry with 'key' exists, value is replaced.

Definition at line 483 of file Fl_Config.h.

int Fl_Config::write const char *    key,
const long    value
[inline]
 

Write long entry to config.

You must call flush() to sunc changes to file. Returns CONF_SUCCESS on success, otherwise errorcode. NOTE: This function assumes that current section is set with set_section().

Parameters:
key  Key to entry.
value  value to set. if entry with 'key' exists, value is replaced.

Definition at line 473 of file Fl_Config.h.

int Fl_Config::write const char *    key,
const char *    value
[inline]
 

Write const char* entry to config.

You must call flush() to sunc changes to file. Returns CONF_SUCCESS on success, otherwise errorcode. NOTE: This function assumes that current section is set with set_section().

Parameters:
key  Key to entry.
value  value to set. if entry with 'key' exists, value is replaced.

Definition at line 463 of file Fl_Config.h.

int Fl_Config::write const char *    key,
const Fl_String   value
[inline]
 

Write Fl_String entry to config.

You must call flush() to sunc changes to file. Returns CONF_SUCCESS on success, otherwise errorcode. NOTE: This function assumes that current section is set with set_section().

Parameters:
key  Key to entry.
value  value to set. if entry with 'key' exists, value is replaced.

Definition at line 453 of file Fl_Config.h.


The documentation for this class was generated from the following file:
Generated on Thu Jul 31 15:33:47 2003 for eFLTK by doxygen1.2.15