| 1598 | } |
| 1599 | |
| 1600 | Value Path::resolve(const Value& root, const Value& defaultValue) const { |
| 1601 | const Value* node = &root; |
| 1602 | for (const auto& arg : args_) { |
| 1603 | if (arg.kind_ == PathArgument::kindIndex) { |
| 1604 | if (!node->isArray() || !node->isValidIndex(arg.index_)) |
| 1605 | return defaultValue; |
| 1606 | node = &((*node)[arg.index_]); |
| 1607 | } else if (arg.kind_ == PathArgument::kindKey) { |
| 1608 | if (!node->isObject()) |
| 1609 | return defaultValue; |
| 1610 | node = &((*node)[arg.key_]); |
| 1611 | if (node == &Value::nullSingleton()) |
| 1612 | return defaultValue; |
| 1613 | } |
| 1614 | } |
| 1615 | return *node; |
| 1616 | } |
| 1617 | |
| 1618 | Value& Path::make(Value& root) const { |
| 1619 | Value* node = &root; |
nothing calls this directly
no test coverage detected