| 3616 | } |
| 3617 | |
| 3618 | Value Path::resolve(const Value& root, const Value& defaultValue) const { |
| 3619 | const Value* node = &root; |
| 3620 | for (const auto& arg : args_) { |
| 3621 | if (arg.kind_ == PathArgument::kindIndex) { |
| 3622 | if (!node->isArray() || !node->isValidIndex(arg.index_)) |
| 3623 | return defaultValue; |
| 3624 | node = &((*node)[arg.index_]); |
| 3625 | } else if (arg.kind_ == PathArgument::kindKey) { |
| 3626 | if (!node->isObject()) |
| 3627 | return defaultValue; |
| 3628 | node = &((*node)[arg.key_]); |
| 3629 | if (node == &Value::nullRef) |
| 3630 | return defaultValue; |
| 3631 | } |
| 3632 | } |
| 3633 | return *node; |
| 3634 | } |
| 3635 | |
| 3636 | Value& Path::make(Value& root) const { |
| 3637 | Value* node = &root; |
nothing calls this directly
no test coverage detected