SYS-REQ-113
(data []byte, concrete, remaining []string, paths *[][]string)
| 110 | |
| 111 | // SYS-REQ-113 |
| 112 | func expandWildcardPaths(data []byte, concrete, remaining []string, paths *[][]string) error { |
| 113 | wildcard := wildcardIndex(remaining) |
| 114 | if wildcard == -1 { |
| 115 | path := make([]string, len(concrete)+len(remaining)) |
| 116 | copy(path, concrete) |
| 117 | copy(path[len(concrete):], remaining) |
| 118 | *paths = append(*paths, path) |
| 119 | return nil |
| 120 | } |
| 121 | |
| 122 | arrayPath := make([]string, len(concrete)+wildcard) |
| 123 | copy(arrayPath, concrete) |
| 124 | copy(arrayPath[len(concrete):], remaining[:wildcard]) |
| 125 | |
| 126 | array, valueType, _, err := Get(data, arrayPath...) |
| 127 | if err != nil { |
| 128 | return err |
| 129 | } |
| 130 | if valueType != Array { |
| 131 | return MalformedArrayError |
| 132 | } |
| 133 | |
| 134 | index := 0 |
| 135 | _, err = ArrayEachErr(array, func(_ []byte, _ ValueType, _ int, parseErr error) error { |
| 136 | if parseErr != nil { |
| 137 | return parseErr |
| 138 | } |
| 139 | |
| 140 | nextPath := make([]string, len(arrayPath)+1) |
| 141 | copy(nextPath, arrayPath) |
| 142 | nextPath[len(arrayPath)] = "[" + strconv.Itoa(index) + "]" |
| 143 | index++ |
| 144 | |
| 145 | return expandWildcardPaths(data, nextPath, remaining[wildcard+1:], paths) |
| 146 | }) |
| 147 | return err |
| 148 | } |
| 149 | |
| 150 | // SYS-REQ-113 |
| 151 | func wildcardIndex(path []string) int { |
no test coverage detected