Bool maps presence of some configuration directive to a boolean variable. Additionally, 'name yes' and 'name no' are mapped to true and false correspondingly. I.e. if directive 'io_debug' exists in processed configuration block or in the global configuration (if inheritGlobal is true) then Process
(name string, inheritGlobal, defaultVal bool, store *bool)
| 324 | // the global configuration (if inheritGlobal is true) then Process will store |
| 325 | // true in target variable. |
| 326 | func (m *Map) Bool(name string, inheritGlobal, defaultVal bool, store *bool) { |
| 327 | m.Custom(name, inheritGlobal, false, func() (interface{}, error) { |
| 328 | return defaultVal, nil |
| 329 | }, func(_ *Map, node Node) (interface{}, error) { |
| 330 | if len(node.Children) != 0 { |
| 331 | return nil, NodeErr(node, "can't declare block here") |
| 332 | } |
| 333 | |
| 334 | if len(node.Args) == 0 { |
| 335 | return true, nil |
| 336 | } |
| 337 | if len(node.Args) != 1 { |
| 338 | return nil, NodeErr(node, "expected exactly 1 argument") |
| 339 | } |
| 340 | |
| 341 | b, err := ParseBool(node.Args[0]) |
| 342 | if err != nil { |
| 343 | return nil, NodeErr(node, "bool argument should be 'yes' or 'no'") |
| 344 | } |
| 345 | return b, nil |
| 346 | }, store) |
| 347 | } |
| 348 | |
| 349 | // StringList maps configuration directive with the specified name to variable |
| 350 | // referenced by 'store' pointer. |