gKeyfile Documentation

gKeyFile is a Scol library based from GLib 2.24 / 2.26.
Supported platforms : GNU / Linux and Microsoft Windows

Installation

  1. Download the library (MS Windows : gkeyfile.dll, GNU/Linux : gkeyfile.so) :
  2. Copy it to your scol's plugins directory
  3. Edit the usm.ini file and add this line :
    plugin plugins/gkeyfile.dll SCOLloadGKEYFILE SCOLfreeGKEYFILE
    if you are on MS Windows, or
    plugin ./plugins/gkeyfile.so SCOLloadGKEYFILE SCOLfreeGKEYFILE
    if you are on GNU/linux.
  4. (Re)Launch Scol.

You must have the GLib 2.24 or + library installed on your system. Only the GLib.
More information here (section : GTK+)

To uninstall, comment or remove the line to the usm.ini file. You can safely delete the *.dll or *.so if you want.

Introduction

It reads and write a key file, typically a configuration file.

This key file can contain groups, keys, values, list of values and localization for each key. It is possible to read and write any comments.
Here is an example :

# This is an example key-value file

[userconf]
# The default value of Name
Name=Your pseudo
# The french value of Name
Name[fr]=Votre pseudonyme
# The german value of Name
Name[de]=Ihr Spitzname
# His/her password
Pass=Your passeword
Pass[fr]=Votre mot de passe
Pass[es]=Contraseña
# Identification
Login=iri
Pwd=1%f5]mfé
# Number of connexion, success, fail
Conn=12;11;1

# Skin configuration
[skin]
Name=red
Path=app/themes/red/
Others=blue;yellow;green;black
Position=50;120

# Personnal values
[personnal]
# integer
value=12;4;589;-12;4
# float
valuef=0.25;4.52

The complete API can be found here

Here a basic example (with the key file above)

typeof Ini = ObjKeyFile;;

fun extrcatIniSub (list)=
	if list == nil then
		0
	else
		let hd list -> [key value] in
		(
		_fooS strcatn ".... " :: key :: " : " :: value :: nil;
		extrcatIniSub tl list
		);;

fun extrcatIni (list)=
	if list == nil then
		0
	else
		let hd list -> [group sublist] in
		(
		_fooS strcat ".. " group;
		extrcatIniSub sublist;
		extrcatIni tl list
		);;

fun main ()=
	_showconsole;
	
	// flag = 3 : we need the localization and the comments
	set Ini = _gkeyFileLoadP _channel _checkpack "tests/gkeyfile/test.ini" nil 3;
	if Ini == nil then
	(
		_fooS "The key file could not be loaded !";
		0
	else
	(
		// What structure is contained in this file ? It will be displayed in the console
		extrcatIni _gkeyFileGetDatas Ini;
		// Get somevalues ...
		_fooS gkeyFileGetValue Ini "username" "Name" GKF_VALUE_STRING;
		_fooS gkeyFileGetLocaleValue Ini "username" "Name" "fr";
		// We add a key and few localized values
		set Ini = _gkeyFileSetValue Ini "username" "hi" "Welcome" GKF_VALUE_STRING;
		set Ini = _gkeyFileSetLocaleValue Ini "username" "hi" "Bonjour !" "fr";
		set Ini = _gkeyFileSetLocaleValue Ini "username" "hi" "Benvenuti !" "it";
		// We save the strcuture to the key file (it will be overwritten)
		_fooId _gkeyFileSave Ini _getmodifypack "tests/gkeyfile/test.ini";
		0
	);;
Generated on Thu Mar 10 12:50:51 2011 for keyfile by  doxygen 1.6.3