summaryrefslogtreecommitdiff
path: root/lib/inifile/types.myr
blob: f2736e073c543ed3d2548d5bcc900c548d9e2b07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use std

pkg inifile =
	type error = union
		`Fileerr
		`Parseerr int
		`Dupkey int
	;;

	type inifile = struct
		sects	: byte[:][:]
		elts	: std.htab((byte[:], byte[:]), byte[:])#
	;;

	impl std.hashable (byte[:], byte[:])
	impl std.comparable (byte[:], byte[:])
;;

impl std.hashable (byte[:], byte[:]) =
	hash = {k
		var sect, key

		(sect, key) = k
		-> std.hash(sect) ^ std.hash(key)
	}
;;

impl std.comparable (byte[:], byte[:]) =
	cmp = {a, b
		var s1, k1
		var s2, k2

		(s1, k1) = a
		(s2, k2) = a
		-> std.cmp(s1, s2) && std.cmp(k1, k2)
	}
;;