resonance 1.0.1
Loading...
Searching...
No Matches
dict.h
Go to the documentation of this file.
1#pragma once
2
3#include "script/cxx/config.h"
6#include "script/cxx/object.h"
7
8namespace Py {
9
30class Dict : public MapBase<Object> {
31public:
40 Dict() {
41 set(FromAPI(PyDict_New()).mPtr);
42 validate();
43 }
44
53 explicit Dict(PyObject *pyob) : MapBase<Object>(pyob) {
54 validate();
55 }
56
65 virtual bool accepts(PyObject *pyob) const {
66 return pyob != nullptr && PyDict_Check(pyob);
67 }
68};
69
70} // namespace Py
Dict()
Create an empty dictionary.
Definition dict.h:40
virtual bool accepts(PyObject *pyob) const
Accept only a dictionary.
Definition dict.h:65
Dict(PyObject *pyob)
Take a borrowed reference to an existing dictionary.
Definition dict.h:53
Temporary owner of a new reference returned by the CPython API.
Definition fromapi.h:25
MapBase()
Definition mapbase.h:45
Reference-counted handle on any Python object, and the root of the PyCXX object hierarchy.
Definition object.h:42
void set(PyObject *pyob)
Replace the reference with a borrowed one and add a count of its own.
Definition object.h:215
void validate()
Enforce this type's accepts() test on the stored reference.
Definition object.h:237
PyObject * mPtr
Wrapped reference, null only between release() and the next assignment.
Definition object.h:191
Configuration header of the PyCXX binding layer.
C++ wrappers for the embedded Python interpreter's objects, types, and extension modules.
Definition attributeerror.h:7