Guidedog Manual 0.6.3
Idioma
En esta página
Guidedog / Documentación 0.6.3

toml

Package toml reads TOML 1.0: tables, arrays of tables, dotted and quoted keys, inline tables, arrays, every string form, integers in all bases, floats, booleans, and date-times (kept as text). Errors carry the line, so a mistake in a configuration file points at itself. Guidedog’s conf.toml and a discussion catalog’s discussion.toml are read with it. It uses only Odin’s core library.

Types

toml.Error :: struct

Error is where and why a source is not TOML; line 0 is no error.

line: int
message: string
toml.Kind :: enum u8

Kind is the type of a Value.

String
Integer
Float
Boolean
Datetime
Array
Table
toml.Value :: struct

Value is one parsed TOML value. Its strings and lists are allocated with the allocator parse was called with, and belong to the caller.

kind: Kind
text: string

String and Datetime.

integer: i64
float: f64
boolean: bool
items: [dynamic]Value

Array.

keys: [dynamic]string

Table, in definition order.

values: [dynamic]Value

Table, parallel to keys.

line: int
defined: bool

Table: defined by a header or as a value, not only implied.

inline: bool

written inline, so it may not be extended later.

Procedures

toml.get :: proc(t: ^Value, key: string) -> ^Value

get is the value of key in table t, or nil when t is not a table or has no such key. It allocates nothing; the value borrows t.

toml.parse :: proc(source: string) -> (root: Value, err: Error)

parse reads source as TOML into a table. Everything it makes is allocated with context.allocator and belongs to the caller; it frees nothing, so parse in an arena. A malformed source is an Error with its line, and the table read so far.