| 3987 | } |
| 3988 | |
| 3989 | Value Path::resolve(const Value& root, const Value& defaultValue) const { |
| 3990 | const Value* node = &root; |
| 3991 | for (Args::const_iterator it = args_.begin(); it != args_.end(); ++it) { |
| 3992 | const PathArgument& arg = *it; |
| 3993 | if (arg.kind_ == PathArgument::kindIndex) { |
| 3994 | if (!node->isArray() || !node->isValidIndex(arg.index_)) |
| 3995 | return defaultValue; |
| 3996 | node = &((*node)[arg.index_]); |
| 3997 | } else if (arg.kind_ == PathArgument::kindKey) { |
| 3998 | if (!node->isObject()) |
| 3999 | return defaultValue; |
| 4000 | node = &((*node)[arg.key_]); |
| 4001 | if (node == &Value::nullRef) |
| 4002 | return defaultValue; |
| 4003 | } |
| 4004 | } |
| 4005 | return *node; |
| 4006 | } |
| 4007 | |
| 4008 | Value& Path::make(Value& root) const { |
| 4009 | Value* node = &root; |
nothing calls this directly
no test coverage detected