An open API service indexing awesome lists of open source software.

https://github.com/hackx2/hxmini

Haxelib for parsing data in the (ini/toml/cfg) format.
https://github.com/hackx2/hxmini

haxe haxe-library haxelib hxini hxmini ini ini-parser toml toml-parser

Last synced: 4 months ago
JSON representation

Haxelib for parsing data in the (ini/toml/cfg) format.

Awesome Lists containing this project

README

          





![e](/.resources/logo-noir-ini-es.png)


Matter.ini 🌌 is a lightweight and simple library for parsing .ini data.
It offers an easy way to read, modify, and create your own .ini data.



Features :p




  • Comment Support: Ignores nodes starting with a semicolon(;) or an hashtag (#).


  • Multi-line support: Allows you to define a node using triple quotation marks (""" """)


  • File Creation & Editing: Lets you create and edit .ini files


Installation 🔧


You can install the library directly using haxelib.


haxelib install mini

Or you could install using git.


haxelib git mini https://github.com/hackx2/hxmini.git


Usage

Parse & Access .ini data

Here is a simple example of how to use the parser in your Haxe project.


First, let's assume you have a file named config.ini with the following contents:

```ini
[main.test]
name="hackx2"
meows="meow"
```

Now, you can parse this file and access its data:

```haxe
import mini.Parser;

// Get `testing.ini`'s file content.
final content : String = sys.io.File.getContent('testing.ini');

// Parse the content.
final ini:Ini = Parser.parse(content);

// Get the element.
final main:Ini = ini.elementsNamed("main.test").next();

// Get and print data.
Sys.println(main.get('name')); // Returns "hackx2"
Sys.println(main.get('meows')); // Returns "meow"

// -----------------------------
```

Create your own .ini files

Heres how you can create a .ini file:

```haxe
// Create the document.
final ini:Ini = Ini.createDocument();

// Create a Section
final user:Ini = Ini.createSection("User");
user.set("username", "Milo");
user.set("role", "Admin");
user.set("progress", "78%");
ini.addChild(user);

user.get('progress'); // Returns: "78%"

ini.toString(); // Returns the serialized .ini document
```


## Contribution (yippie)
Contributions are always welcome and appreciated!!! 💖If you have a bug or have any suggestions, please open an [issue](https://github.com/hackx2/hxmini/issues).


License


This project is licensed under the MIT License.