+ def get_sequence_len(self):
+ """
+ Return the len of a sequence or a negative
+ value on error.
+ """
+ seq = _bt_python_get_sequence_from_def(self._d)
+ return _bt_sequence_len(seq)
+
+ def get_sequence_element_at(self, index):
+ """
+ Return the sequence's element at position index,
+ otherwise return None
+ """
+ seq = _bt_python_get_sequence_from_def(self._d)
+ if seq is not None:
+ definition_ptr = _bt_sequence_index(seq, index)
+ if definition_ptr is not None:
+ return _Definition(definition_ptr, self.scope)
+ return None
+
+ def get_uint64(self):
+ """
+ Return the value associated with the field.
+ If the field does not exist or is not of the type requested,
+ the value returned is undefined. To check if an error occured,
+ use the field_error() function after accessing a field.
+ """
+ return _bt_ctf_get_uint64(self._d)
+
+ def get_int64(self):
+ """
+ Return the value associated with the field.
+ If the field does not exist or is not of the type requested,
+ the value returned is undefined. To check if an error occured,
+ use the field_error() function after accessing a field.
+ """
+ return _bt_ctf_get_int64(self._d)
+
+ def get_char_array(self):
+ """
+ Return the value associated with the field.
+ If the field does not exist or is not of the type requested,
+ the value returned is undefined. To check if an error occurred,
+ use the field_error() function after accessing a field.
+ """
+ return _bt_ctf_get_char_array(self._d)
+
+ def get_str(self):
+ """
+ Return the value associated with the field.
+ If the field does not exist or is not of the type requested,
+ the value returned is undefined. To check if an error occurred,
+ use the field_error() function after accessing a field.
+ """
+ return _bt_ctf_get_string(self._d)
+
+ def get_float(self):
+ """
+ Return the value associated with the field.
+ If the field does not exist or is not of the type requested,
+ the value returned is undefined. To check if an error occurred,
+ use the field_error() function after accessing a field.
+ """
+ return _bt_ctf_get_float(self._d)
+
+ def get_variant(self):
+ """
+ Return the variant's selected field.
+ If the field does not exist or is not of the type requested,
+ the value returned is undefined. To check if an error occurred,
+ use the field_error() function after accessing a field.
+ """
+ return _bt_ctf_get_variant(self._d)
+
+ def get_struct_field_count(self):
+ """
+ Return the number of fields contained in the structure.
+ If the field does not exist or is not of the type requested,
+ the value returned is undefined.
+ """
+ return _bt_ctf_get_struct_field_count(self._d)
+
+ def get_struct_field_at(self, i):
+ """
+ Return the structure's field at position i.
+ If the field does not exist or is not of the type requested,
+ the value returned is undefined. To check if an error occurred,
+ use the field_error() function after accessing a field.
+ """
+ return _bt_ctf_get_struct_field_index(self._d, i)
+
+ @property
+ def value(self):
+ """
+ Return the value associated with the field according to its type.
+ Return None on error.
+ """
+ id = self.type
+ value = None
+ if id == CTFTypeId.STRING:
+ value = self.get_str()
+ elif id == CTFTypeId.ARRAY:
+ value = []
+ for i in range(self.get_array_len()):
+ element = self.get_array_element_at(i)
+ value.append(element.value)
+ elif id == CTFTypeId.INTEGER:
+ if self.get_int_signedness() == 0:
+ value = self.get_uint64()
+ else:
+ value = self.get_int64()
+ elif id == CTFTypeId.ENUM:
+ value = self.get_enum_str()
+ elif id == CTFTypeId.SEQUENCE:
+ seq_len = self.get_sequence_len()
+ value = []
+ for i in range(seq_len):
+ evDef = self.get_sequence_element_at(i)
+ value.append(evDef.value)
+ elif id == CTFTypeId.FLOAT:
+ value = self.get_float()
+ elif id == CTFTypeId.VARIANT:
+ variant = Definition.__new__(Definition)
+ variant._d = self.get_variant();
+ value = variant.value
+ elif id == CTFTypeId.STRUCT:
+ value = {}
+ for i in range(self.get_struct_field_count()):
+ member = _Definition(self.get_struct_field_at(i), self.scope)
+ value[member.name] = member.value
+
+ if field_error():
+ raise FieldError("Error occurred while accessing field {} of type {}".format(self.field_name(), CTFTypeId.get_type_name(self.field_type())))
+ return value
+
+ @property
+ def scope(self):
+ """Return the scope of a field or None on error."""
+ return self._s