2 @page ctfirexamples CTF IR examples
4 <strong>List of CTF IR examples</strong>:
6 - @subpage ctfirfieldtypesexamples CTF IR field types examples
8 @sa ctfir (API reference)
11 @page ctfirfieldtypesexamples CTF IR field types examples
13 This page contains usage examples of the \ref ctfirfieldtypes API.
18 @section ctfirfieldtypesexamples_intfieldtype Integer field type
22 @subsection ctfirfieldtypesexamples_intfieldtype0 Create a default, 16-bit integer field type
26 #include <babeltrace2/ctf-ir/field-types.h>
28 struct bt_field_type *create_int_field_type(void)
30 struct bt_field_type *field_type;
32 field_type = bt_field_type_integer_create(16);
39 @subsection ctfirfieldtypesexamples_intfieldtype1 Create a 23-bit, signed, big-endian integer field type
43 #include <babeltrace2/ctf-ir/field-types.h>
45 struct bt_field_type *create_int_field_type(void)
48 struct bt_field_type *field_type;
50 field_type = bt_field_type_integer_create(23);
53 ret = bt_field_type_set_byte_order(field_type,
54 BT_BYTE_ORDER_BIG_ENDIAN);
57 ret = bt_field_type_integer_set_signed(field_type, 1);
64 @subsection ctfirfieldtypesexamples_intfieldtype2 Create an 8-bit integer field type, displayed in hexadecimal, mapped to a CTF IR clock class
68 #include <babeltrace2/ctf-ir/field-types.h>
70 struct bt_field_type *create_int_field_type(
71 struct bt_clock_class *clock_class)
74 struct bt_field_type *field_type;
76 field_type = bt_field_type_integer_create(8);
79 ret = bt_field_type_integer_set_base(field_type,
80 BT_INTEGER_BASE_HEXADECIMAL);
83 ret = bt_field_type_integer_set_mapped_clock(field_type, clock_class);
91 @section ctfirfieldtypesexamples_floatfieldtype Floating point number field type
93 @sa ctfirfloatfieldtype
95 @subsection ctfirfieldtypesexamples_floatfieldtype0 Create a default floating point number field type
99 #include <babeltrace2/ctf-ir/field-types.h>
101 struct bt_field_type *create_float_field_type(void)
103 struct bt_field_type *field_type;
105 field_type = bt_field_type_floating_point_create();
112 @subsection ctfirfieldtypesexamples_floatfieldtype1 Create a "double", little-endian floating point number field type
116 #include <babeltrace2/ctf-ir/field-types.h>
118 struct bt_field_type *create_float_field_type(void)
121 struct bt_field_type *field_type;
123 field_type = bt_field_type_floating_point_create();
126 ret = bt_field_type_set_byte_order(field_type,
127 BT_BYTE_ORDER_LITTLE_ENDIAN);
130 ret = bt_field_type_floating_point_set_exponent_digits(field_type, 11);
133 ret = bt_field_type_floating_point_set_mantissa_digits(field_type, 53);