| 1679 | } |
| 1680 | |
| 1681 | Value Path::resolve(const Value& root, const Value& defaultValue) const { |
| 1682 | const Value* node = &root; |
| 1683 | for (const auto & arg : args_) { |
| 1684 | if (arg.kind_ == PathArgument::kindIndex) { |
| 1685 | if (!node->isArray() || !node->isValidIndex(arg.index_)) |
| 1686 | return defaultValue; |
| 1687 | node = &((*node)[arg.index_]); |
| 1688 | } else if (arg.kind_ == PathArgument::kindKey) { |
| 1689 | if (!node->isObject()) |
| 1690 | return defaultValue; |
| 1691 | node = &((*node)[arg.key_]); |
| 1692 | if (node == &Value::nullSingleton()) |
| 1693 | return defaultValue; |
| 1694 | } |
| 1695 | } |
| 1696 | return *node; |
| 1697 | } |
| 1698 | |
| 1699 | Value& Path::make(Value& root) const { |
| 1700 | Value* node = &root; |
nothing calls this directly
no test coverage detected