MCPcopy Index your code
hub / github.com/foxcpp/maddy / Bool

Method Bool

framework/config/map.go:326–347  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

324// the global configuration (if inheritGlobal is true) then Process will store
325// true in target variable.
326func (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.

Callers 15

ReadGlobalsFunction · 0.95
TestMapBoolFunction · 0.95
readListCfgMethod · 0.95
RunFunction · 0.80
ConfigureMethod · 0.80
ConfigureMethod · 0.80
ConfigureMethod · 0.80
ConfigureMethod · 0.80
ConfigureMethod · 0.80
ConfigureMethod · 0.80
logger.goFile · 0.80
ConfigureMethod · 0.80

Calls 3

CustomMethod · 0.95
ParseBoolFunction · 0.85
NodeErrFunction · 0.70

Tested by 1

TestMapBoolFunction · 0.76