| 2970 | } |
| 2971 | |
| 2972 | Value Path::resolve(const Value& root, const Value& defaultValue) const { |
| 2973 | const Value* node = &root; |
| 2974 | for (Args::const_iterator it = args_.begin(); it != args_.end(); ++it) { |
| 2975 | const PathArgument& arg = *it; |
| 2976 | if (arg.kind_ == PathArgument::kindIndex) { |
| 2977 | if (!node->isArray() || !node->isValidIndex(arg.index_)) |
| 2978 | return defaultValue; |
| 2979 | node = &((*node)[arg.index_]); |
| 2980 | } else if (arg.kind_ == PathArgument::kindKey) { |
| 2981 | if (!node->isObject()) |
| 2982 | return defaultValue; |
| 2983 | node = &((*node)[arg.key_]); |
| 2984 | if (node == &Value::null) |
| 2985 | return defaultValue; |
| 2986 | } |
| 2987 | } |
| 2988 | return *node; |
| 2989 | } |
| 2990 | |
| 2991 | Value& Path::make(Value& root) const { |
| 2992 | Value* node = &root; |
nothing calls this directly
no test coverage detected