hxIni is a fast, light and simple library to read and write INI files, using hashes.
Checkout wikipedia for more information about INI Files.
Use haxelib to install the release version of the library (if avaliable):
> haxelib install hxIni
Otherwise, you can download this repository as a zip from GitHub (you can try this link), and use the local installer from haxelib:
> haxelib local hxIni-master.zip
Also, don't forget to add
<haxelib name="hxIni" />
to your xml project file, or, for a standard Haxe project, add
in your hxml build file.
Let's explain this with an example. Imagine you have this example.ini file:
; - example.ini ; last modified 1 April 2001 by John Doe [owner] name=John Doe organization=Acme Widgets Inc. [database] ; use IP address in case network name resolution is not working server=192.0.2.62 port=143 file="payroll.dat"
There we have two sections (owner and database), and each one has its own parameters ([name, organization] and [server, port, file]).
Now, to parse this with hxIni, we must create an Ini object with IniManager class:
var ini: Ini = IniManager.loadFromFile("example.ini");
Or, if you have that stored in a String, you can use:
var ini: Ini = IniManager.loadFromString(str_data);
And, the access to parameters it's pretty simple. Imagine a map of maps, so a section if linked to a map of parameters, and you can access like this:
var name = ini["owner"]["name"];
Finally, you can transform them to a string (after modifications), or save it to a file:
IniManager.writeToFile(ini, "test.ini"); trace( IniManager.toString(ini) );
Also, don't forget to import the classes!
import hxIni.IniManager; import hxIni.IniManager.Ini;
;) and white lines will be ignored.
Clone the repository:
$ git clone https://github.com/wikiti/hxini
Then, setup the development directory:
$ haxelib dev hxini hxini
To run tests use munit:
$ haxelib install munit $ haxelib run munit test
The following people have helped to develop this library:
|Thomas ten Cate||ttencate||GitHub Profile|