| 107 | Any AtCompoundKey(std::vector<Any> const& v, std::string_view const& key, Any&& defaultVal); |
| 108 | |
| 109 | Any |
| 110 | AtCompoundKey(AnyMap const& m, std::string_view const& key, Any&& defaultVal) |
| 111 | { |
| 112 | auto pos = key.find("."); |
| 113 | if (pos != AnyMap::key_type::npos) |
| 114 | { |
| 115 | auto const head = key.substr(0, pos); |
| 116 | auto const tail = key.substr(pos + 1); |
| 117 | auto itr = m.find(std::string(head)); |
| 118 | if (itr != m.end()) |
| 119 | { |
| 120 | auto& h = itr->second; |
| 121 | if (h.Type() == typeid(AnyMap)) |
| 122 | { |
| 123 | return AtCompoundKey(ref_any_cast<AnyMap>(h), tail, std::move(defaultVal)); |
| 124 | } |
| 125 | else if (h.Type() == typeid(std::vector<Any>)) |
| 126 | { |
| 127 | return AtCompoundKey(ref_any_cast<std::vector<Any>>(h), tail, std::move(defaultVal)); |
| 128 | } |
| 129 | } |
| 130 | } |
| 131 | else |
| 132 | { |
| 133 | auto itr = m.find(std::string(key)); |
| 134 | if (itr != m.end()) |
| 135 | { |
| 136 | return itr->second; |
| 137 | } |
| 138 | } |
| 139 | return std::move(defaultVal); |
| 140 | } |
| 141 | |
| 142 | Any |
| 143 | AtCompoundKey(std::vector<Any> const& v, std::string_view const& key, Any&& defaultval) |
no test coverage detected