Value
#struct ValueOne value of a setting.
| Name | Type | Description |
|---|---|---|
kind | int = 0 | VAL_WORD, VAL_STR or VAL_NUM. |
text | str = "" | The value as text; strings without their quotes and with escapes resolved. |
line | int = 0 | The line, counting from 1. |
col | int = 0 | The column, counting from 1. |
import net.httpd.conf
func main:
text := `
server:
site:
listen = 80 tls
names = "a.test www.a.test"
location "/api/": cache = 1h end
end
end
`
mut d := conf.Parse(text)
println d.ok, d.nodes.Len(), conf.Count(d, conf.Root())
server := conf.Find(d, conf.Root(), "server")
site := conf.Find(d, server, "site")
println conf.Name(d, site), conf.Count(d, site), d.nodes.Get(site).block
listen := conf.Find(d, site, "listen")
v := d.nodes.Get(listen).values.Get(0)
println v.text, v.kind == conf.VAL_NUM, v.line, v.col
w := d.nodes.Get(listen).values.Get(1)
println w.text, w.kind == conf.VAL_WORD, conf.ValueText(d, conf.Find(d, site, "names"), 0)
names := d.nodes.Get(conf.Find(d, site, "names")).values.Get(0)
println names.kind == conf.VAL_STR
loc := conf.ChildAt(d, site, 2)
n := d.nodes.Get(loc)
println conf.Name(d, loc),
n.labels.Get(0),
n.block,
n.words.Len(),
n.children.Len(),
n.line,
n.col
conf.Free(d)
endtrue 7 1 site 3 true 80 true 4 18 tls true a.test www.a.test true location /api/ true 1 1 6 9