| 1621 | } |
| 1622 | |
| 1623 | Value Path::resolve(const Value& root, const Value& defaultValue) const { |
| 1624 | const Value* node = &root; |
| 1625 | for (Args::const_iterator it = args_.begin(); it != args_.end(); ++it) { |
| 1626 | const PathArgument& arg = *it; |
| 1627 | if (arg.kind_ == PathArgument::kindIndex) { |
| 1628 | if (!node->isArray() || !node->isValidIndex(arg.index_)) |
| 1629 | return defaultValue; |
| 1630 | node = &((*node)[arg.index_]); |
| 1631 | } else if (arg.kind_ == PathArgument::kindKey) { |
| 1632 | if (!node->isObject()) |
| 1633 | return defaultValue; |
| 1634 | node = &((*node)[arg.key_]); |
| 1635 | if (node == &Value::nullSingleton()) |
| 1636 | return defaultValue; |
| 1637 | } |
| 1638 | } |
| 1639 | return *node; |
| 1640 | } |
| 1641 | |
| 1642 | Value& Path::make(Value& root) const { |
| 1643 | Value* node = &root; |
nothing calls this directly
no test coverage detected