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

Function get_if

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 1

has_keyFunction · 0.85

Tested by

no test coverage detected