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

Method Custom

framework/config/map.go:595–621  ·  view source on GitHub ↗

Custom maps configuration directive with the specified name to variable referenced by 'store' pointer. If inheritGlobal is true - Map will try to use a value from globalCfg if none is set in a processed configuration block. If required is true - Map will fail if no value is set in the configuratio

(name string, inheritGlobal, required bool, defaultVal func() (interface{}, error), mapper func(*Map, Node) (interface{}, error), store interface{})

Source from the content-addressed store, hash-verified

593// store is where the value returned by mapper should be stored. Can be nil
594// (value will be saved only in Map.Values).
595func (m *Map) Custom(name string, inheritGlobal, required bool, defaultVal func() (interface{}, error), mapper func(*Map, Node) (interface{}, error), store interface{}) {
596 if m.entries == nil {
597 m.entries = make(map[string]matcher)
598 }
599 if _, ok := m.entries[name]; ok {
600 panic("Map.Custom: duplicate matcher")
601 }
602
603 var target *reflect.Value
604 ptr := reflect.ValueOf(store)
605 if ptr.IsValid() && !ptr.IsNil() {
606 val := ptr.Elem()
607 if !val.CanSet() {
608 panic("Map.Custom: store argument must be settable (a pointer)")
609 }
610 target = &val
611 }
612
613 m.entries[name] = matcher{
614 name: name,
615 inheritGlobal: inheritGlobal,
616 required: required,
617 defaultVal: defaultVal,
618 mapper: mapper,
619 store: target,
620 }
621}
622
623// Callback creates mapping that will call mapper() function for each
624// directive with the specified name. No further processing is done.

Callers 15

ReadGlobalsFunction · 0.95
EnumListMethod · 0.95
EnumMethod · 0.95
DurationMethod · 0.95
DataSizeMethod · 0.95
BoolMethod · 0.95
StringListMethod · 0.95
StringMethod · 0.95
IntMethod · 0.95
UIntMethod · 0.95
Int32Method · 0.95
UInt32Method · 0.95

Calls

no outgoing calls