Skip to content

ziglibs/ini

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

INI parser library

This is a very simple ini-parser library that provides:

  • Raw record reading
  • Leading/trailing whitespace removal
  • (not yet) string escaping
  • comments based on ; and #
  • Zig API
  • (not yet) C API

Usage example

Zig

const ini = @import("ini");

const config =
    \\[Meta]
    \\author = xq
    \\library = ini
    \\
    \\[Albums]
    \\Thriller
    \\Back in Black
    \\Bat Out of Hell
    \\The Dark Side of the Moon
;

test {
    var parser = ini.parse(std.testing.allocator, std.io.fixedBufferStream(config).reader());
    defer parser.deinit();

    var writer = std.io.getStdOut().writer();

    while (try parser.next()) |record| {
        switch (record) {
            .section => |heading| try writer.print("[{s}]\n", .{heading}),
            .property => |kv| try writer.print("{s} = {s}\n", .{ kv.key, kv.value }),
            .enumeration => |value| try writer.print("{s}\n", .{value}),
        }
    }
}

About

A teeny tiny ini parser

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published

Contributors 5