MCPcopy Create free account
hub / github.com/Illumina/hap.py / resolve

Method resolve

external/jsoncpp/jsoncpp.cpp:3002–3019  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3000}
3001
3002Value 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
3021Value &Path::make(Value &root) const {
3022 Value *node = &root;

Callers

nothing calls this directly

Calls 5

beginMethod · 0.80
isArrayMethod · 0.80
isValidIndexMethod · 0.80
isObjectMethod · 0.80
endMethod · 0.45

Tested by

no test coverage detected