| 4090 | } |
| 4091 | |
| 4092 | Value Path::resolve(const Value& root, const Value& defaultValue) const { |
| 4093 | const Value* node = &root; |
| 4094 | for (Args::const_iterator it = args_.begin(); it != args_.end(); ++it) { |
| 4095 | const PathArgument& arg = *it; |
| 4096 | if (arg.kind_ == PathArgument::kindIndex) { |
| 4097 | if (!node->isArray() || !node->isValidIndex(arg.index_)) |
| 4098 | return defaultValue; |
| 4099 | node = &((*node)[arg.index_]); |
| 4100 | } else if (arg.kind_ == PathArgument::kindKey) { |
| 4101 | if (!node->isObject()) |
| 4102 | return defaultValue; |
| 4103 | node = &((*node)[arg.key_]); |
| 4104 | if (node == &Value::nullSingleton()) |
| 4105 | return defaultValue; |
| 4106 | } |
| 4107 | } |
| 4108 | return *node; |
| 4109 | } |
| 4110 | |
| 4111 | Value& Path::make(Value& root) const { |
| 4112 | Value* node = &root; |
nothing calls this directly
no test coverage detected