MCPcopy Create free account
hub / github.com/CppMicroServices/CppMicroServices / AtCompoundKey

Function AtCompoundKey

framework/src/util/AnyMap.cpp:109–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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)

Callers 2

AnyMap.cppFile · 0.85
AtCompoundKeyMethod · 0.85

Calls 4

findMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected