Signed-off-by: Xiaona Han <[email protected]>
---
 bindings/python/babeltrace.i.in |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/bindings/python/babeltrace.i.in b/bindings/python/babeltrace.i.in
index 880b23e..806cc73 100755
--- a/bindings/python/babeltrace.i.in
+++ b/bindings/python/babeltrace.i.in
@@ -986,6 +986,25 @@ class ctf:
                        """
                        return _bt_ctf_get_string(self._d)
 
+               def get_value(self):
+                       """
+                       Return the value associated with the field according to 
its type.
+                       If the field does not exist, the value returned is 
undefined.
+                       To check if an error occured, use the ctf.field_error() 
function
+                       after accessing a field.
+                       """
+                       id = self.field_type()
+                       if id == ctf.type_id.STRING:
+                               return self.get_str()
+                       if type_id == ctf.type_id.ARRAY:
+                               return self.get_char_array()
+                       if type_id == ctf.type_id.INTEGER:
+                               if self.get_int_signedness == 0:
+                                       return self.get_uint64()
+                               else:
+                                       return self.get_int64()
+                       return None
+
                def get_scope(self):
                        """Return the scope of a field or None on error."""
                        return self._s
-- 
1.7.1


_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

Reply via email to