You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Warning: this library isn't maintained anymore, as I am no longer able to write Zig due to various constrains. I will
gladly accept any pull requests to help keep this functional, but no more features will be added. Thanks.
usage
assuming that the file at path contains the following:
[root]integer = -1345
string = My string
boolean = enabled
// Load file into memory.varfd=trystd.fs.cwd().openFile(path, .{ .read=true });
deferfd.close();
varfc=tryallocator.alloc(u8, tryfd.getEndPos());
deferallocator.free(fc);
// Parse `.ini` from memory.varini=tryparseIntoMap(fc, allocator);
deferini.deinit();
// `ini.map` now contains a hash map with the contents.
spec
a .ini file is composed of:
comments: starting with ; up to the end of the line
sections: enclosed with []
identifiers: alphanumeric + _
values:
numbers: integers or float, parsed by Zig
booleans:
truthy: 1, true, True, t, T, yes, Yes, y, Y, on, On, enabled, Enabled
falsey: 0, false, False, f, F, no, No, n, N, off, Off, disabled, Disabled
strings: non-escaped text
types only make sense when parsing into a struct, when parsing to a map,
all values get coerced to []const u8
the .ini file should have at least one section, no
orphan keys are allowed