+ 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 occured,
+ use the CTFReader.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 occured,
+ use the CTFReader.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 occured,
+ use the CTFReader.field_error() function after accessing a field.
+ """
+ return _bt_ctf_get_struct_field_index(self._d, i)
+
+ def get_value(self):
+ """
+ Return the value associated with the field according to its type.
+ Return None on error.
+ """
+ id = self.field_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.get_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.get_value())
+ elif id == CTFTypeId.FLOAT:
+ value = self.get_float()
+ elif id == CTFTypeId.VARIANT:
+ variant = CTFReader.Definition.__new__(CTFReader.Definition)
+ variant._d = self.get_variant();
+ value = variant.get_value()
+ elif id == CTFTypeId.STRUCT:
+ value = {}
+ for i in range(self.get_struct_field_count()):
+ member = CTFReader.Definition.__new__(CTFReader.Definition)
+ member._d = self.get_struct_field_at(i);
+ value[member.field_name()] = member.get_value()
+
+ if CTFReader.field_error():
+ raise CTFReader.FieldError("Error occured while accessing field {} of type {}".format(self.field_name(), CTFTypeId.get_type_name(self.field_type())))
+ return value
+
+ def get_scope(self):
+ """Return the scope of a field or None on error."""
+ return self._s