CPointerBase
Base class for objects that have a pointer access property that controls access to the underlying C pointer.
Attributes
| Attribute | Type | Description |
|---|---|---|
| ptr_type | type = c_void_p | The ctypes class or type used to validate compatible pointer assignments. |
| destructor | callable = None | A callable used to free the memory of the C++ object when the instance is deleted. |
| null_ptr_exception_class | Exception = AttributeError | The exception type raised when attempting to access the ptr property while the internal pointer is NULL. |
Constructor
Signature
def CPointerBase() - > null
Methods
ptr()
@classmethod
def ptr() - > c_void_p
Retrieves the underlying C pointer or raises an exception if the pointer is NULL to prevent invalid memory access.
Returns
| Type | Description |
|---|---|
c_void_p | The valid C pointer associated with this object instance. |
ptr()
@classmethod
def ptr(
ptr: c_void_p
)
Sets the underlying C pointer after validating that the provided value is either None or matches the expected pointer type.
Parameters
| Name | Type | Description |
|---|---|---|
| ptr | c_void_p | The new C pointer to assign to this object, which must be compatible with the defined ptr_type. |