format::ini+x86_64 +linux

format::ini provides a parser for DOS-style INI files:

# This is a comment
[harelang.org]
name=Hare
description=The Hare programming language

[blablabla]
key=value
# Unicode
trademark=™

Index

Types

type entry = (const str, const str, const str);

// Undocumented types:
type scanner = struct {
	scan: bufio::scanner,
	lineno: size,
	section: str,
};

Errors

type error = !(io::error | utf8::invalid | syntaxerr);
type syntaxerr = !size;

Functions

fn entry_dup(ent: entry) entry;
fn entry_finish(ent: entry) void;
fn finish(sc: *scanner) void;
fn next(sc: *scanner) (entry | io::EOF | error);
fn scan(in: io::handle) scanner;
fn strerror(err: error) const str;

Types

type entry[link]

type entry = (const str, const str, const str);

An entry in an INI file: (section, key, value).

type scanner[link]

Show undocumented member
type scanner = struct {
	scan: bufio::scanner,
	lineno: size,
	section: str,
};

Errors

type error[link]

type error = !(io::error | utf8::invalid | syntaxerr);

Any error that may occur during parsing.

type syntaxerr[link]

type syntaxerr = !size;

A syntax error occurred during parsing.

Functions

fn entry_dup[link]

fn entry_dup(ent: entry) entry;

Duplicates an entry. Use entry_finish to get rid of it.

fn entry_finish[link]

fn entry_finish(ent: entry) void;

Frees an entry previously duplicated with entry_dup.

fn finish[link]

fn finish(sc: *scanner) void;

Frees resources associated with a scanner.

fn next[link]

fn next(sc: *scanner) (entry | io::EOF | error);

Returns the next entry from an INI file. The return value is borrowed from the scanner. Use entry_dup to retain a copy.

fn scan[link]

fn scan(in: io::handle) scanner;

Creates an INI file scanner. Use next to read entries. The caller must call finish once they're done with this object.

fn strerror[link]

fn strerror(err: error) const str;

Returns a user-friendly representation of error. The result may be statically allocated.