| 1 | #ifndef BABELTRACE_CTF_IR_FIELD_TYPES_H |
| 2 | #define BABELTRACE_CTF_IR_FIELD_TYPES_H |
| 3 | |
| 4 | /* |
| 5 | * BabelTrace - CTF IR: Event field types |
| 6 | * |
| 7 | * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com> |
| 8 | * |
| 9 | * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com> |
| 10 | * |
| 11 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 12 | * of this software and associated documentation files (the "Software"), to deal |
| 13 | * in the Software without restriction, including without limitation the rights |
| 14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 15 | * copies of the Software, and to permit persons to whom the Software is |
| 16 | * furnished to do so, subject to the following conditions: |
| 17 | * |
| 18 | * The above copyright notice and this permission notice shall be included in |
| 19 | * all copies or substantial portions of the Software. |
| 20 | * |
| 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 27 | * SOFTWARE. |
| 28 | * |
| 29 | * The Common Trace Format (CTF) Specification is available at |
| 30 | * http://www.efficios.com/ctf |
| 31 | */ |
| 32 | |
| 33 | /* For bt_get() */ |
| 34 | #include <babeltrace/ref.h> |
| 35 | |
| 36 | /* For bt_bool */ |
| 37 | #include <babeltrace/types.h> |
| 38 | |
| 39 | #include <stdint.h> |
| 40 | #include <stddef.h> |
| 41 | |
| 42 | #ifdef __cplusplus |
| 43 | extern "C" { |
| 44 | #endif |
| 45 | |
| 46 | struct bt_field_type; |
| 47 | struct bt_field_path; |
| 48 | struct bt_field_type_signed_enumeration_mapping_ranges; |
| 49 | struct bt_field_type_unsigned_enumeration_mapping_ranges; |
| 50 | |
| 51 | typedef const char * const *bt_field_type_enumeration_mapping_label_array; |
| 52 | |
| 53 | enum bt_field_type_id { |
| 54 | BT_FIELD_TYPE_ID_UNSIGNED_INTEGER, |
| 55 | BT_FIELD_TYPE_ID_SIGNED_INTEGER, |
| 56 | BT_FIELD_TYPE_ID_UNSIGNED_ENUMERATION, |
| 57 | BT_FIELD_TYPE_ID_SIGNED_ENUMERATION, |
| 58 | BT_FIELD_TYPE_ID_REAL, |
| 59 | BT_FIELD_TYPE_ID_STRING, |
| 60 | BT_FIELD_TYPE_ID_STRUCTURE, |
| 61 | BT_FIELD_TYPE_ID_STATIC_ARRAY, |
| 62 | BT_FIELD_TYPE_ID_DYNAMIC_ARRAY, |
| 63 | BT_FIELD_TYPE_ID_VARIANT, |
| 64 | }; |
| 65 | |
| 66 | enum bt_field_type_integer_preferred_display_base { |
| 67 | BT_FIELD_TYPE_INTEGER_PREFERRED_DISPLAY_BASE_BINARY, |
| 68 | BT_FIELD_TYPE_INTEGER_PREFERRED_DISPLAY_BASE_OCTAL, |
| 69 | BT_FIELD_TYPE_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL, |
| 70 | BT_FIELD_TYPE_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL, |
| 71 | }; |
| 72 | |
| 73 | extern enum bt_field_type_id bt_field_type_get_type_id( |
| 74 | struct bt_field_type *field_type); |
| 75 | |
| 76 | extern struct bt_field_type *bt_field_type_unsigned_integer_create(void); |
| 77 | |
| 78 | extern struct bt_field_type *bt_field_type_signed_integer_create(void); |
| 79 | |
| 80 | extern uint64_t bt_field_type_integer_get_field_value_range( |
| 81 | struct bt_field_type *field_type); |
| 82 | |
| 83 | extern int bt_field_type_integer_set_field_value_range( |
| 84 | struct bt_field_type *field_type, uint64_t size); |
| 85 | |
| 86 | extern enum bt_field_type_integer_preferred_display_base |
| 87 | bt_field_type_integer_get_preferred_display_base( |
| 88 | struct bt_field_type *field_type); |
| 89 | |
| 90 | extern int bt_field_type_integer_set_preferred_display_base( |
| 91 | struct bt_field_type *field_type, |
| 92 | enum bt_field_type_integer_preferred_display_base base); |
| 93 | |
| 94 | extern struct bt_field_type *bt_field_type_real_create(void); |
| 95 | |
| 96 | extern bt_bool bt_field_type_real_is_single_precision( |
| 97 | struct bt_field_type *field_type); |
| 98 | |
| 99 | extern int bt_field_type_real_set_is_single_precision( |
| 100 | struct bt_field_type *field_type, |
| 101 | bt_bool is_single_precision); |
| 102 | |
| 103 | extern struct bt_field_type *bt_field_type_unsigned_enumeration_create(void); |
| 104 | |
| 105 | extern struct bt_field_type *bt_field_type_signed_enumeration_create(void); |
| 106 | |
| 107 | extern uint64_t bt_field_type_enumeration_get_mapping_count( |
| 108 | struct bt_field_type *field_type); |
| 109 | |
| 110 | extern void bt_field_type_unsigned_enumeration_borrow_mapping_by_index( |
| 111 | struct bt_field_type *field_type, uint64_t index, |
| 112 | const char **label, |
| 113 | struct bt_field_type_unsigned_enumeration_mapping_ranges **ranges); |
| 114 | |
| 115 | extern void bt_field_type_signed_enumeration_borrow_mapping_by_index( |
| 116 | struct bt_field_type *field_type, uint64_t index, |
| 117 | const char **label, |
| 118 | struct bt_field_type_signed_enumeration_mapping_ranges **ranges); |
| 119 | |
| 120 | extern uint64_t bt_field_type_unsigned_enumeration_mapping_ranges_get_range_count( |
| 121 | struct bt_field_type_unsigned_enumeration_mapping_ranges *ranges); |
| 122 | |
| 123 | extern uint64_t bt_field_type_signed_enumeration_mapping_ranges_get_range_count( |
| 124 | struct bt_field_type_signed_enumeration_mapping_ranges *ranges); |
| 125 | |
| 126 | extern void bt_field_type_unsigned_enumeration_mapping_ranges_get_range_by_index( |
| 127 | struct bt_field_type_unsigned_enumeration_mapping_ranges *ranges, |
| 128 | uint64_t index, uint64_t *lower, uint64_t *upper); |
| 129 | |
| 130 | extern void bt_field_type_signed_enumeration_mapping_ranges_get_range_by_index( |
| 131 | struct bt_field_type_unsigned_enumeration_mapping_ranges *ranges, |
| 132 | uint64_t index, int64_t *lower, int64_t *upper); |
| 133 | |
| 134 | extern int bt_field_type_unsigned_enumeration_get_mapping_labels_by_value( |
| 135 | struct bt_field_type *field_type, uint64_t value, |
| 136 | bt_field_type_enumeration_mapping_label_array *label_array, |
| 137 | uint64_t *count); |
| 138 | |
| 139 | extern int bt_field_type_signed_enumeration_get_mapping_labels_by_value( |
| 140 | struct bt_field_type *field_type, int64_t value, |
| 141 | bt_field_type_enumeration_mapping_label_array *label_array, |
| 142 | uint64_t *count); |
| 143 | |
| 144 | extern int bt_field_type_unsigned_enumeration_map_range( |
| 145 | struct bt_field_type *field_type, const char *label, |
| 146 | uint64_t range_lower, uint64_t range_upper); |
| 147 | |
| 148 | extern int bt_field_type_signed_enumeration_map_range( |
| 149 | struct bt_field_type *field_type, const char *label, |
| 150 | int64_t range_lower, int64_t range_upper); |
| 151 | |
| 152 | extern struct bt_field_type *bt_field_type_string_create(void); |
| 153 | |
| 154 | extern struct bt_field_type *bt_field_type_structure_create(void); |
| 155 | |
| 156 | extern uint64_t bt_field_type_structure_get_member_count( |
| 157 | struct bt_field_type *field_type); |
| 158 | |
| 159 | extern void bt_field_type_structure_borrow_member_by_index( |
| 160 | struct bt_field_type *struct_field_type, uint64_t index, |
| 161 | const char **name, struct bt_field_type **field_type); |
| 162 | |
| 163 | extern |
| 164 | struct bt_field_type *bt_field_type_structure_borrow_member_field_type_by_name( |
| 165 | struct bt_field_type *field_type, const char *name); |
| 166 | |
| 167 | extern int bt_field_type_structure_append_member( |
| 168 | struct bt_field_type *struct_field_type, const char *name, |
| 169 | struct bt_field_type *field_type); |
| 170 | |
| 171 | extern struct bt_field_type *bt_field_type_static_array_create( |
| 172 | struct bt_field_type *elem_field_type, |
| 173 | uint64_t length); |
| 174 | |
| 175 | extern struct bt_field_type *bt_field_type_dynamic_array_create( |
| 176 | struct bt_field_type *elem_field_type); |
| 177 | |
| 178 | extern struct bt_field_type *bt_field_type_array_borrow_element_field_type( |
| 179 | struct bt_field_type *field_type); |
| 180 | |
| 181 | extern uint64_t bt_field_type_static_array_get_length( |
| 182 | struct bt_field_type *field_type); |
| 183 | |
| 184 | extern struct bt_field_path * |
| 185 | bt_field_type_dynamic_array_borrow_length_field_path( |
| 186 | struct bt_field_type *field_type); |
| 187 | |
| 188 | extern int bt_field_type_dynamic_array_set_length_field_type( |
| 189 | struct bt_field_type *field_type, |
| 190 | struct bt_field_type *length_field_type); |
| 191 | |
| 192 | extern struct bt_field_type *bt_field_type_variant_create(void); |
| 193 | |
| 194 | extern struct bt_field_path * |
| 195 | bt_field_type_variant_borrow_selector_field_path( |
| 196 | struct bt_field_type *field_type); |
| 197 | |
| 198 | extern int bt_field_type_variant_set_selector_field_type( |
| 199 | struct bt_field_type *field_type, |
| 200 | struct bt_field_type *selector_field_type); |
| 201 | |
| 202 | extern uint64_t bt_field_type_variant_get_option_count( |
| 203 | struct bt_field_type *field_type); |
| 204 | |
| 205 | extern void bt_field_type_variant_borrow_option_by_index( |
| 206 | struct bt_field_type *variant_field_type, uint64_t index, |
| 207 | const char **name, struct bt_field_type **field_type); |
| 208 | |
| 209 | extern |
| 210 | struct bt_field_type *bt_field_type_variant_borrow_option_field_type_by_name( |
| 211 | struct bt_field_type *field_type, |
| 212 | const char *name); |
| 213 | |
| 214 | extern int bt_field_type_variant_append_option( |
| 215 | struct bt_field_type *var_field_type, |
| 216 | const char *name, struct bt_field_type *field_type); |
| 217 | |
| 218 | #ifdef __cplusplus |
| 219 | } |
| 220 | #endif |
| 221 | |
| 222 | #endif /* BABELTRACE_CTF_IR_FIELD_TYPES_H */ |