MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/SPlisHSPlasH / dict

Class dict

extern/pybind/include/pybind11/pytypes.h:2144–2181  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2142}
2143
2144class dict : public object {
2145public:
2146 PYBIND11_OBJECT_CVT(dict, object, PyDict_Check, raw_dict)
2147 dict() : object(PyDict_New(), stolen_t{}) {
2148 if (!m_ptr) {
2149 pybind11_fail("Could not allocate dict object!");
2150 }
2151 }
2152 template <typename... Args,
2153 typename = detail::enable_if_t<args_are_all_keyword_or_ds<Args...>()>,
2154 // MSVC workaround: it can't compile an out-of-line definition, so defer the
2155 // collector
2156 typename collector = detail::deferred_t<detail::unpacking_collector<>, Args...>>
2157 explicit dict(Args &&...args) : dict(collector(std::forward<Args>(args)...).kwargs()) {}
2158
2159 size_t size() const { return (size_t) PyDict_Size(m_ptr); }
2160 bool empty() const { return size() == 0; }
2161 detail::dict_iterator begin() const { return {*this, 0}; }
2162 detail::dict_iterator end() const { return {}; }
2163 void clear() /* py-non-const */ { PyDict_Clear(ptr()); }
2164 template <typename T>
2165 bool contains(T &&key) const {
2166 auto result = PyDict_Contains(m_ptr, detail::object_or_cast(std::forward<T>(key)).ptr());
2167 if (result == -1) {
2168 throw error_already_set();
2169 }
2170 return result == 1;
2171 }
2172
2173private:
2174 /// Call the `dict` Python type -- always returns a new reference
2175 static PyObject *raw_dict(PyObject *op) {
2176 if (PyDict_Check(op)) {
2177 return handle(op).inc_ref().ptr();
2178 }
2179 return PyObject_CallFunctionObjArgs((PyObject *) &PyDict_Type, op, nullptr);
2180 }
2181};
2182
2183class sequence : public object {
2184public:

Callers 7

setup.pyFile · 0.85
setup.pyFile · 0.85
dispatcherMethod · 0.85
initFunction · 0.85
annotationsMethod · 0.85
loadMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected