[go: up one dir, main page]

IniFiction

General purpose library for reading and writing .ini files in an object oriented code style.
https://github.com/imfi-jz/IniFiction

To install, run:

haxelib install IniFiction 0.1.0 

See using Haxelib in Haxelib documentation for more information.

README.md

IniFiction

This is the GitHub repository for the Haxelib IniFiction. IniFiction is a library that allows reading and writing of ini files. The library uses inheritance to make working in an object oriented codebase easier without needing to write adapters or something similar (you still can of course).

The library supports [sections] and ; comments, and automatically uses an approperiate newline character for the OS it runs on. The library supports all Haxe targets that have access to #sys.

Installation

Before using this library you should know what Haxe is and have the Haxe toolkit installed.

  1. Type haxelib install IniFiction in a command prompt/shell.
  2. Add --library IniFiction to your .hxml file.

Usage

You can get started by creating a new ini file object:

var ini = new IniFile("MyIniFile", "C:/my/path");

If the path is an existing ini file, call the load method:

ini.load();

You can add key/value data by creating a Key object:

var key = new Key("MyKey", "MyValue");

This key can be added to the ini file, and saved to have the file reflect the change:

ini.keys.add(key);
ini.save();

Sections can be added in a similar way:

var section = new Section("MySection", ini.lineSeparator);
ini.sections.add(section);
ini.save();

To add keys to your section, use the same method as when adding keys to the file itself, but on the section (remember that the section was already added to the ini object):

section.keys.add(key);
ini.save();

Comments can be added using the Key object:

var comment = new Key("; Hello World!");
ini.keys.add(comment);
ini.save();

These code snippets should result in the following ini file:

MyIniFile.ini

MyKey=MyValue
; Hello World!

[MySection]
MyKey=MyValue

There are currently no formatting options available at this time, aside from what is shown above. Each entry writes to a new line and each section is prepended by an empty line. Entries not in a section will always appear above all sections. Values are written and read as String.

Conditional compilation

The library supports 2 conditional compilation flags:

# This will output warnings to the console (recommended).
-D warn

# This will output debug logs to the console (e.g. file initialised, loaded, saved, etc.).
-D inifiction_log

Contact/support

Join my Discord for support, questions or suggestions. The Discord will also keep you updated on my other projects. This was a hobby project of mine from 2019.

You can also use the Issues tab to report issues.

License

You are free to use this library as it is licensed MIT.

Contributors
imfi-jz
Version
0.1.0
Published
3 years ago
License
MIT

All libraries are free

Every month, more than a thousand developers use Haxelib to find, share, and reuse code — and assemble it in powerful new ways. Enjoy Haxe; It is great!

Explore Haxe

Haxe Manual

Haxe Code Cookbook

Haxe API documentation

You can try Haxe in the browser! try.haxe.org

Join us on GitHub!

Haxe is being developed on GitHub. Feel free to contribute or report issues to our projects.

Haxe on GitHub