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{})
| 593 | // store is where the value returned by mapper should be stored. Can be nil |
| 594 | // (value will be saved only in Map.Values). |
| 595 | func (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. |
no outgoing calls