Int maps configuration directive with the specified name to variable referenced by 'store' pointer. Configuration directive must be in form 'name 123'. See Custom function for details about inheritGlobal, required and defaultVal.
(name string, inheritGlobal, required bool, defaultVal int, store *int)
| 399 | // See Custom function for details about inheritGlobal, required and |
| 400 | // defaultVal. |
| 401 | func (m *Map) Int(name string, inheritGlobal, required bool, defaultVal int, store *int) { |
| 402 | m.Custom(name, inheritGlobal, required, func() (interface{}, error) { |
| 403 | return defaultVal, nil |
| 404 | }, func(_ *Map, node Node) (interface{}, error) { |
| 405 | if len(node.Args) != 1 { |
| 406 | return nil, NodeErr(node, "expected 1 argument") |
| 407 | } |
| 408 | if len(node.Children) != 0 { |
| 409 | return nil, NodeErr(node, "can't declare block here") |
| 410 | } |
| 411 | |
| 412 | i, err := strconv.Atoi(node.Args[0]) |
| 413 | if err != nil { |
| 414 | return nil, NodeErr(node, "invalid integer: %s", node.Args[0]) |
| 415 | } |
| 416 | return i, nil |
| 417 | }, store) |
| 418 | } |
| 419 | |
| 420 | // UInt maps configuration directive with the specified name to variable |
| 421 | // referenced by 'store' pointer. |