| 4024 | } |
| 4025 | |
| 4026 | Value Path::resolve(const Value& root, const Value& defaultValue) const { |
| 4027 | const Value* node = &root; |
| 4028 | for (Args::const_iterator it = args_.begin(); it != args_.end(); ++it) { |
| 4029 | const PathArgument& arg = *it; |
| 4030 | if (arg.kind_ == PathArgument::kindIndex) { |
| 4031 | if (!node->isArray() || !node->isValidIndex(arg.index_)) |
| 4032 | return defaultValue; |
| 4033 | node = &((*node)[arg.index_]); |
| 4034 | } else if (arg.kind_ == PathArgument::kindKey) { |
| 4035 | if (!node->isObject()) |
| 4036 | return defaultValue; |
| 4037 | node = &((*node)[arg.key_]); |
| 4038 | if (node == &Value::nullSingleton()) |
| 4039 | return defaultValue; |
| 4040 | } |
| 4041 | } |
| 4042 | return *node; |
| 4043 | } |
| 4044 | |
| 4045 | Value& Path::make(Value& root) const { |
| 4046 | Value* node = &root; |
nothing calls this directly
no test coverage detected