+ return _create_field_from_ptr(
+ field_ptr, self._owner_ptr, self._owner_get_ref, self._owner_put_ref
+ )
+
+
+class _OptionField(_Field):
+ _NAME = 'Option'
+
+ @property
+ def field(self):
+ field_ptr = native_bt.field_option_borrow_field_const(self._ptr)
+
+ if field_ptr is None:
+ return
+
+ return _create_field_from_ptr(
+ field_ptr, self._owner_ptr, self._owner_get_ref, self._owner_put_ref
+ )
+
+ @property
+ def has_field(self):
+ return self.field is not None
+
+ @has_field.setter
+ def has_field(self, value):
+ utils._check_bool(value)
+ native_bt.field_option_set_has_field(self._ptr, value)
+
+ def _spec_eq(self, other):
+ return _get_leaf_field(self) == other
+
+ def __bool__(self):
+ return self.has_field
+
+ def __str__(self):
+ return str(self.field)
+
+ def _repr(self):
+ return repr(self.field)
+
+ def _set_value(self, value):
+ self.has_field = True
+ field = self.field
+ assert field is not None
+ field.value = value
+
+ value = property(fset=_set_value)