| 1670 | |
| 1671 | |
| 1672 | Value |
| 1673 | Path::resolve( const Value &root, |
| 1674 | const Value &defaultValue ) const |
| 1675 | { |
| 1676 | const Value *node = &root; |
| 1677 | for ( Args::const_iterator it = args_.begin(); it != args_.end(); ++it ) |
| 1678 | { |
| 1679 | const PathArgument &arg = *it; |
| 1680 | if ( arg.kind_ == PathArgument::kindIndex ) |
| 1681 | { |
| 1682 | if ( !node->isArray() || node->isValidIndex( arg.index_ ) ) |
| 1683 | return defaultValue; |
| 1684 | node = &((*node)[arg.index_]); |
| 1685 | } |
| 1686 | else if ( arg.kind_ == PathArgument::kindKey ) |
| 1687 | { |
| 1688 | if ( !node->isObject() ) |
| 1689 | return defaultValue; |
| 1690 | node = &((*node)[arg.key_]); |
| 1691 | if ( node == &Value::null ) |
| 1692 | return defaultValue; |
| 1693 | } |
| 1694 | } |
| 1695 | return *node; |
| 1696 | } |
| 1697 | |
| 1698 | |
| 1699 | Value & |
nothing calls this directly
no test coverage detected