ArrayEachWildcard iterates over an array addressed by keys. A terminal [*] component is accepted as an explicit request for all elements; without it, the function behaves like ArrayEachErr. SYS-REQ-113
(data []byte, cb func(idx int, value []byte, vt ValueType, offset int, err error) error, keys ...string)
| 70 | // the function behaves like ArrayEachErr. |
| 71 | // SYS-REQ-113 |
| 72 | func ArrayEachWildcard(data []byte, cb func(idx int, value []byte, vt ValueType, offset int, err error) error, keys ...string) (int, error) { |
| 73 | if len(keys) > 0 && keys[len(keys)-1] == wildcardPathComponent { |
| 74 | keys = keys[:len(keys)-1] |
| 75 | } |
| 76 | |
| 77 | index := 0 |
| 78 | return ArrayEachErr(data, func(value []byte, valueType ValueType, offset int, err error) error { |
| 79 | current := index |
| 80 | index++ |
| 81 | return cb(current, value, valueType, offset, err) |
| 82 | }, keys...) |
| 83 | } |
| 84 | |
| 85 | // SetWildcard applies Set to every concrete path matched by [*]. Wildcards |
| 86 | // may appear at any array position and may be repeated. If a wildcard matches |