Skip to content

hackx2/hxmini

Repository files navigation



Matter

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 (""" """, Multiline Test=\ possible\ hehe )
  • 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:

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

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

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:

// 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.


License

This project is licensed under the MIT License.