| 3000 | } |
| 3001 | |
| 3002 | Value Path::resolve(const Value &root, const Value &defaultValue) const { |
| 3003 | const Value *node = &root; |
| 3004 | for (Args::const_iterator it = args_.begin(); it != args_.end(); ++it) { |
| 3005 | const PathArgument &arg = *it; |
| 3006 | if (arg.kind_ == PathArgument::kindIndex) { |
| 3007 | if (!node->isArray() || !node->isValidIndex(arg.index_)) |
| 3008 | return defaultValue; |
| 3009 | node = &((*node)[arg.index_]); |
| 3010 | } else if (arg.kind_ == PathArgument::kindKey) { |
| 3011 | if (!node->isObject()) |
| 3012 | return defaultValue; |
| 3013 | node = &((*node)[arg.key_]); |
| 3014 | if (node == &Value::null) |
| 3015 | return defaultValue; |
| 3016 | } |
| 3017 | } |
| 3018 | return *node; |
| 3019 | } |
| 3020 | |
| 3021 | Value &Path::make(Value &root) const { |
| 3022 | Value *node = &root; |
nothing calls this directly
no test coverage detected