Skip to main content

CPointerBase

Base class for objects that have a pointer access property that controls access to the underlying C pointer.

Attributes

AttributeTypeDescription
ptr_typetype = c_void_pThe ctypes class or type used to validate compatible pointer assignments.
destructorcallable = NoneA callable used to free the memory of the C++ object when the instance is deleted.
null_ptr_exception_classException = AttributeErrorThe 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

TypeDescription
c_void_pThe 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

NameTypeDescription
ptrc_void_pThe new C pointer to assign to this object, which must be compatible with the defined ptr_type.