MCPcopy Create free account
hub / github.com/alibaba/zvec / get_if

Function get_if

src/binding/python/model/common/python_config.cc:25–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23
24template <typename T>
25std::optional<T> get_if(py::dict d, const std::string &key) {
26 if (has_key(d, key)) {
27 try {
28 py::object obj = d[py::str(key)];
29 return obj.cast<T>();
30 } catch (const py::cast_error &) {
31 throw py::type_error("Key '" + key + "' is not of expected type.");
32 }
33 }
34 return std::nullopt;
35}
36
37inline std::string to_lower(const std::string &s) {
38 std::string lower;

Callers

nothing calls this directly

Calls 1

has_keyFunction · 0.85

Tested by

no test coverage detected