resonance 1.0.1
Loading...
Searching...
No Matches
char.h
Go to the documentation of this file.
1#pragma once
2
3#include "script/cxx/config.h"
4#include "script/cxx/object.h"
5
6namespace Py {
7
22class Char : public Object {
23public:
32 explicit Char(PyObject *pyob) : Object(pyob) {
33 validate();
34 }
35
44 virtual bool accepts(PyObject *pyob) const {
45 return pyob != nullptr && PyString_Check(pyob) && PySequence_Length(pyob) == 1;
46 }
47};
48
49} // namespace Py
virtual bool accepts(PyObject *pyob) const
Accept only a string of length one.
Definition char.h:44
Char(PyObject *pyob)
Take a borrowed reference to an existing one-character string.
Definition char.h:32
Object(PyObject *pyob=Py_None)
Take a borrowed reference and add a count of its own.
Definition object.h:52
void validate()
Enforce this type's accepts() test on the stored reference.
Definition object.h:237
Configuration header of the PyCXX binding layer.
C++ wrappers for the embedded Python interpreter's objects, types, and extension modules.
Definition attributeerror.h:7