Commit | Line | Data |
---|---|---|
3fd40f46 PP |
1 | #ifndef BABELTRACE2_TRACE_IR_FIELD_CLASS_CONST_H |
2 | #define BABELTRACE2_TRACE_IR_FIELD_CLASS_CONST_H | |
78cf9df6 PP |
3 | |
4 | /* | |
0dcb770f | 5 | * Copyright (c) 2010-2019 EfficiOS Inc. and Linux Foundation |
78cf9df6 | 6 | * |
78cf9df6 PP |
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
8 | * of this software and associated documentation files (the "Software"), to deal | |
9 | * in the Software without restriction, including without limitation the rights | |
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
11 | * copies of the Software, and to permit persons to whom the Software is | |
12 | * furnished to do so, subject to the following conditions: | |
13 | * | |
14 | * The above copyright notice and this permission notice shall be included in | |
15 | * all copies or substantial portions of the Software. | |
16 | * | |
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
23 | * SOFTWARE. | |
78cf9df6 PP |
24 | */ |
25 | ||
9df34b44 PP |
26 | #ifndef __BT_IN_BABELTRACE_H |
27 | # error "Please include <babeltrace2/babeltrace.h> instead." | |
28 | #endif | |
29 | ||
78cf9df6 PP |
30 | #include <stdint.h> |
31 | #include <stddef.h> | |
32 | ||
e278f258 PP |
33 | #include <babeltrace2/types.h> |
34 | ||
78cf9df6 PP |
35 | #ifdef __cplusplus |
36 | extern "C" { | |
37 | #endif | |
38 | ||
ee78f405 | 39 | typedef enum bt_field_class_type { |
5d2d8d18 PP |
40 | BT_FIELD_CLASS_TYPE_BOOL = 1ULL << 0, |
41 | BT_FIELD_CLASS_TYPE_BIT_ARRAY = 1ULL << 1, | |
42 | BT_FIELD_CLASS_TYPE_INTEGER = 1ULL << 2, | |
43 | BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER = (1ULL << 3) | BT_FIELD_CLASS_TYPE_INTEGER, | |
44 | BT_FIELD_CLASS_TYPE_SIGNED_INTEGER = (1ULL << 4) | BT_FIELD_CLASS_TYPE_INTEGER, | |
45 | BT_FIELD_CLASS_TYPE_ENUMERATION = 1ULL << 5, | |
46 | BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION = BT_FIELD_CLASS_TYPE_ENUMERATION | BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER, | |
47 | BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION = BT_FIELD_CLASS_TYPE_ENUMERATION | BT_FIELD_CLASS_TYPE_SIGNED_INTEGER, | |
48 | BT_FIELD_CLASS_TYPE_REAL = 1ULL << 6, | |
49 | BT_FIELD_CLASS_TYPE_SINGLE_PRECISION_REAL = (1ULL << 7) | BT_FIELD_CLASS_TYPE_REAL, | |
50 | BT_FIELD_CLASS_TYPE_DOUBLE_PRECISION_REAL = (1ULL << 8) | BT_FIELD_CLASS_TYPE_REAL, | |
51 | BT_FIELD_CLASS_TYPE_STRING = 1ULL << 9, | |
52 | BT_FIELD_CLASS_TYPE_STRUCTURE = 1ULL << 10, | |
53 | BT_FIELD_CLASS_TYPE_ARRAY = 1ULL << 11, | |
54 | BT_FIELD_CLASS_TYPE_STATIC_ARRAY = (1ULL << 12) | BT_FIELD_CLASS_TYPE_ARRAY, | |
55 | BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY = (1ULL << 13) | BT_FIELD_CLASS_TYPE_ARRAY, | |
56 | BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD = (1ULL << 14) | BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY, | |
57 | BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD = (1ULL << 15) | BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY, | |
58 | BT_FIELD_CLASS_TYPE_OPTION = 1ULL << 16, | |
59 | BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR_FIELD = (1ULL << 17) | BT_FIELD_CLASS_TYPE_OPTION, | |
60 | BT_FIELD_CLASS_TYPE_OPTION_WITH_SELECTOR_FIELD = (1ULL << 18) | BT_FIELD_CLASS_TYPE_OPTION, | |
61 | BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD = (1ULL << 19) | BT_FIELD_CLASS_TYPE_OPTION_WITH_SELECTOR_FIELD, | |
62 | BT_FIELD_CLASS_TYPE_OPTION_WITH_INTEGER_SELECTOR_FIELD = (1ULL << 20) | BT_FIELD_CLASS_TYPE_OPTION_WITH_SELECTOR_FIELD, | |
63 | BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD = (1ULL << 21) | BT_FIELD_CLASS_TYPE_OPTION_WITH_INTEGER_SELECTOR_FIELD, | |
64 | BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD = (1ULL << 22) | BT_FIELD_CLASS_TYPE_OPTION_WITH_INTEGER_SELECTOR_FIELD, | |
65 | BT_FIELD_CLASS_TYPE_VARIANT = 1ULL << 23, | |
66 | BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR_FIELD = (1ULL << 24) | BT_FIELD_CLASS_TYPE_VARIANT, | |
67 | BT_FIELD_CLASS_TYPE_VARIANT_WITH_SELECTOR_FIELD = (1ULL << 25) | BT_FIELD_CLASS_TYPE_VARIANT, | |
68 | BT_FIELD_CLASS_TYPE_VARIANT_WITH_INTEGER_SELECTOR_FIELD = (1ULL << 26) | BT_FIELD_CLASS_TYPE_VARIANT_WITH_SELECTOR_FIELD, | |
69 | BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD = (1ULL << 27) | BT_FIELD_CLASS_TYPE_VARIANT_WITH_INTEGER_SELECTOR_FIELD, | |
70 | BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD = (1ULL << 28) | BT_FIELD_CLASS_TYPE_VARIANT_WITH_INTEGER_SELECTOR_FIELD, | |
71 | ||
72 | /* | |
73 | * Make sure the enumeration type is a 64-bit integer in case | |
74 | * the project needs field class types in the future. | |
75 | * | |
76 | * This is not part of the API. | |
77 | */ | |
78 | __BT_FIELD_CLASS_TYPE_BIG_VALUE = 1ULL << 62, | |
ee78f405 | 79 | } bt_field_class_type; |
78cf9df6 | 80 | |
ee78f405 | 81 | typedef enum bt_field_class_integer_preferred_display_base { |
a0c6c1d7 PP |
82 | BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_BINARY = 2, |
83 | BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_OCTAL = 8, | |
84 | BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL = 10, | |
85 | BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL = 16, | |
ee78f405 | 86 | } bt_field_class_integer_preferred_display_base; |
78cf9df6 | 87 | |
ee78f405 | 88 | extern bt_field_class_type bt_field_class_get_type( |
8eee8ea2 | 89 | const bt_field_class *field_class); |
78cf9df6 | 90 | |
5d2d8d18 PP |
91 | static inline |
92 | bt_bool bt_field_class_type_is(const bt_field_class_type type, | |
93 | const bt_field_class_type type_to_check) | |
94 | { | |
95 | return (type & type_to_check) == type_to_check; | |
96 | } | |
97 | ||
af90138b PP |
98 | extern const bt_value *bt_field_class_borrow_user_attributes_const( |
99 | const bt_field_class *field_class); | |
100 | ||
6943da6a PP |
101 | extern uint64_t bt_field_class_bit_array_get_length( |
102 | const bt_field_class *field_class); | |
103 | ||
78cf9df6 | 104 | extern uint64_t bt_field_class_integer_get_field_value_range( |
8eee8ea2 | 105 | const bt_field_class *field_class); |
78cf9df6 | 106 | |
ee78f405 | 107 | extern bt_field_class_integer_preferred_display_base |
78cf9df6 | 108 | bt_field_class_integer_get_preferred_display_base( |
8eee8ea2 | 109 | const bt_field_class *field_class); |
78cf9df6 | 110 | |
78cf9df6 | 111 | extern uint64_t bt_field_class_enumeration_get_mapping_count( |
8eee8ea2 | 112 | const bt_field_class *field_class); |
78cf9df6 | 113 | |
60bbfc7c PP |
114 | extern const bt_field_class_enumeration_unsigned_mapping * |
115 | bt_field_class_enumeration_unsigned_borrow_mapping_by_index_const( | |
b6baf3bb PP |
116 | const bt_field_class *field_class, uint64_t index); |
117 | ||
60bbfc7c PP |
118 | extern const bt_field_class_enumeration_unsigned_mapping * |
119 | bt_field_class_enumeration_unsigned_borrow_mapping_by_label_const( | |
02b61fe0 PP |
120 | const bt_field_class *field_class, const char *label); |
121 | ||
60bbfc7c PP |
122 | extern const bt_field_class_enumeration_signed_mapping * |
123 | bt_field_class_enumeration_signed_borrow_mapping_by_index_const( | |
b6baf3bb PP |
124 | const bt_field_class *field_class, uint64_t index); |
125 | ||
60bbfc7c PP |
126 | extern const bt_field_class_enumeration_signed_mapping * |
127 | bt_field_class_enumeration_signed_borrow_mapping_by_label_const( | |
02b61fe0 PP |
128 | const bt_field_class *field_class, const char *label); |
129 | ||
b6baf3bb PP |
130 | static inline |
131 | const bt_field_class_enumeration_mapping * | |
60bbfc7c PP |
132 | bt_field_class_enumeration_unsigned_mapping_as_mapping_const( |
133 | const bt_field_class_enumeration_unsigned_mapping *mapping) | |
b6baf3bb | 134 | { |
8470daa9 | 135 | return __BT_UPCAST_CONST(bt_field_class_enumeration_mapping, mapping); |
b6baf3bb | 136 | } |
78cf9df6 | 137 | |
b6baf3bb PP |
138 | static inline |
139 | const bt_field_class_enumeration_mapping * | |
60bbfc7c PP |
140 | bt_field_class_enumeration_signed_mapping_as_mapping_const( |
141 | const bt_field_class_enumeration_signed_mapping *mapping) | |
b6baf3bb | 142 | { |
8470daa9 | 143 | return __BT_UPCAST_CONST(bt_field_class_enumeration_mapping, mapping); |
b6baf3bb | 144 | } |
78cf9df6 | 145 | |
b6baf3bb PP |
146 | extern const char *bt_field_class_enumeration_mapping_get_label( |
147 | const bt_field_class_enumeration_mapping *mapping); | |
78cf9df6 | 148 | |
02b61fe0 | 149 | extern const bt_integer_range_set_unsigned * |
60bbfc7c PP |
150 | bt_field_class_enumeration_unsigned_mapping_borrow_ranges_const( |
151 | const bt_field_class_enumeration_unsigned_mapping *mapping); | |
78cf9df6 | 152 | |
02b61fe0 | 153 | extern const bt_integer_range_set_signed * |
60bbfc7c PP |
154 | bt_field_class_enumeration_signed_mapping_borrow_ranges_const( |
155 | const bt_field_class_enumeration_signed_mapping *mapping); | |
78cf9df6 | 156 | |
1091bb60 | 157 | typedef enum bt_field_class_enumeration_get_mapping_labels_for_value_status { |
fb25b9e3 PP |
158 | BT_FIELD_CLASS_ENUMERATION_GET_MAPPING_LABELS_BY_VALUE_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, |
159 | BT_FIELD_CLASS_ENUMERATION_GET_MAPPING_LABELS_BY_VALUE_STATUS_OK = __BT_FUNC_STATUS_OK, | |
1091bb60 | 160 | } bt_field_class_enumeration_get_mapping_labels_for_value_status; |
fb25b9e3 | 161 | |
1091bb60 | 162 | extern bt_field_class_enumeration_get_mapping_labels_for_value_status |
60bbfc7c | 163 | bt_field_class_enumeration_unsigned_get_mapping_labels_for_value( |
8eee8ea2 | 164 | const bt_field_class *field_class, uint64_t value, |
78cf9df6 PP |
165 | bt_field_class_enumeration_mapping_label_array *label_array, |
166 | uint64_t *count); | |
167 | ||
1091bb60 | 168 | extern bt_field_class_enumeration_get_mapping_labels_for_value_status |
60bbfc7c | 169 | bt_field_class_enumeration_signed_get_mapping_labels_for_value( |
8eee8ea2 | 170 | const bt_field_class *field_class, int64_t value, |
78cf9df6 PP |
171 | bt_field_class_enumeration_mapping_label_array *label_array, |
172 | uint64_t *count); | |
173 | ||
174 | extern uint64_t bt_field_class_structure_get_member_count( | |
8eee8ea2 | 175 | const bt_field_class *field_class); |
78cf9df6 | 176 | |
e24f271a PP |
177 | extern const bt_field_class_structure_member * |
178 | bt_field_class_structure_borrow_member_by_index_const( | |
179 | const bt_field_class *field_class, uint64_t index); | |
78cf9df6 | 180 | |
e24f271a PP |
181 | extern const bt_field_class_structure_member * |
182 | bt_field_class_structure_borrow_member_by_name_const( | |
8eee8ea2 | 183 | const bt_field_class *field_class, const char *name); |
78cf9df6 | 184 | |
e24f271a PP |
185 | extern const char *bt_field_class_structure_member_get_name( |
186 | const bt_field_class_structure_member *member); | |
187 | ||
188 | extern const bt_field_class * | |
189 | bt_field_class_structure_member_borrow_field_class_const( | |
190 | const bt_field_class_structure_member *member); | |
191 | ||
af90138b PP |
192 | extern const bt_value *bt_field_class_structure_member_borrow_user_attributes_const( |
193 | const bt_field_class_structure_member *member); | |
194 | ||
8eee8ea2 | 195 | extern const bt_field_class * |
78cf9df6 | 196 | bt_field_class_array_borrow_element_field_class_const( |
8eee8ea2 | 197 | const bt_field_class *field_class); |
78cf9df6 | 198 | |
60bbfc7c | 199 | extern uint64_t bt_field_class_array_static_get_length( |
8eee8ea2 | 200 | const bt_field_class *field_class); |
78cf9df6 | 201 | |
8eee8ea2 | 202 | extern const bt_field_path * |
b8ddb4f0 | 203 | bt_field_class_array_dynamic_with_length_field_borrow_length_field_path_const( |
8eee8ea2 | 204 | const bt_field_class *field_class); |
78cf9df6 | 205 | |
247fa9e3 PP |
206 | extern const bt_field_class * |
207 | bt_field_class_option_borrow_field_class_const( | |
208 | const bt_field_class *field_class); | |
209 | ||
210 | extern const bt_field_path * | |
8bc207af | 211 | bt_field_class_option_with_selector_field_borrow_selector_field_path_const( |
467673c1 PP |
212 | const bt_field_class *field_class); |
213 | ||
214 | extern bt_bool | |
8bc207af | 215 | bt_field_class_option_with_selector_field_bool_selector_is_reversed( |
467673c1 PP |
216 | const bt_field_class *field_class); |
217 | ||
218 | extern const bt_integer_range_set_unsigned * | |
8bc207af | 219 | bt_field_class_option_with_selector_field_integer_unsigned_borrow_selector_ranges_const( |
467673c1 PP |
220 | const bt_field_class *field_class); |
221 | ||
222 | extern const bt_integer_range_set_signed * | |
8bc207af | 223 | bt_field_class_option_with_selector_field_integer_signed_borrow_selector_ranges_const( |
247fa9e3 PP |
224 | const bt_field_class *field_class); |
225 | ||
78cf9df6 | 226 | extern uint64_t bt_field_class_variant_get_option_count( |
8eee8ea2 | 227 | const bt_field_class *field_class); |
78cf9df6 | 228 | |
e24f271a PP |
229 | extern const bt_field_class_variant_option * |
230 | bt_field_class_variant_borrow_option_by_index_const( | |
231 | const bt_field_class *field_class, uint64_t index); | |
78cf9df6 | 232 | |
e24f271a PP |
233 | extern const bt_field_class_variant_option * |
234 | bt_field_class_variant_borrow_option_by_name_const( | |
235 | const bt_field_class *field_class, const char *name); | |
236 | ||
8bc207af PP |
237 | extern const bt_field_class_variant_with_selector_field_integer_unsigned_option * |
238 | bt_field_class_variant_with_selector_field_integer_unsigned_borrow_option_by_index_const( | |
02b61fe0 PP |
239 | const bt_field_class *field_class, uint64_t index); |
240 | ||
8bc207af PP |
241 | extern const bt_field_class_variant_with_selector_field_integer_unsigned_option * |
242 | bt_field_class_variant_with_selector_field_integer_unsigned_borrow_option_by_name_const( | |
02b61fe0 PP |
243 | const bt_field_class *field_class, const char *name); |
244 | ||
8bc207af PP |
245 | extern const bt_field_class_variant_with_selector_field_integer_signed_option * |
246 | bt_field_class_variant_with_selector_field_integer_signed_borrow_option_by_index_const( | |
02b61fe0 PP |
247 | const bt_field_class *field_class, uint64_t index); |
248 | ||
8bc207af PP |
249 | extern const bt_field_class_variant_with_selector_field_integer_signed_option * |
250 | bt_field_class_variant_with_selector_field_integer_signed_borrow_option_by_name_const( | |
02b61fe0 PP |
251 | const bt_field_class *field_class, const char *name); |
252 | ||
e24f271a PP |
253 | extern const char *bt_field_class_variant_option_get_name( |
254 | const bt_field_class_variant_option *option); | |
255 | ||
256 | extern const bt_field_class * | |
257 | bt_field_class_variant_option_borrow_field_class_const( | |
258 | const bt_field_class_variant_option *option); | |
78cf9df6 | 259 | |
af90138b PP |
260 | extern const bt_value *bt_field_class_variant_option_borrow_user_attributes_const( |
261 | const bt_field_class_variant_option *option); | |
262 | ||
02b61fe0 | 263 | extern const bt_field_path * |
8bc207af | 264 | bt_field_class_variant_with_selector_field_borrow_selector_field_path_const( |
02b61fe0 PP |
265 | const bt_field_class *field_class); |
266 | ||
267 | extern const bt_integer_range_set_unsigned * | |
8bc207af PP |
268 | bt_field_class_variant_with_selector_field_integer_unsigned_option_borrow_ranges_const( |
269 | const bt_field_class_variant_with_selector_field_integer_unsigned_option *option); | |
02b61fe0 PP |
270 | |
271 | static inline | |
272 | const bt_field_class_variant_option * | |
8bc207af PP |
273 | bt_field_class_variant_with_selector_field_integer_unsigned_option_as_option_const( |
274 | const bt_field_class_variant_with_selector_field_integer_unsigned_option *option) | |
02b61fe0 PP |
275 | { |
276 | return __BT_UPCAST_CONST(bt_field_class_variant_option, option); | |
277 | } | |
278 | ||
279 | extern const bt_integer_range_set_signed * | |
8bc207af PP |
280 | bt_field_class_variant_with_selector_field_integer_signed_option_borrow_ranges_const( |
281 | const bt_field_class_variant_with_selector_field_integer_signed_option *option); | |
02b61fe0 PP |
282 | |
283 | static inline | |
284 | const bt_field_class_variant_option * | |
8bc207af PP |
285 | bt_field_class_variant_with_selector_field_integer_signed_option_as_option_const( |
286 | const bt_field_class_variant_with_selector_field_integer_signed_option *option) | |
02b61fe0 PP |
287 | { |
288 | return __BT_UPCAST_CONST(bt_field_class_variant_option, option); | |
289 | } | |
290 | ||
8eee8ea2 | 291 | extern void bt_field_class_get_ref(const bt_field_class *field_class); |
8c6884d9 | 292 | |
8eee8ea2 | 293 | extern void bt_field_class_put_ref(const bt_field_class *field_class); |
8c6884d9 PP |
294 | |
295 | #define BT_FIELD_CLASS_PUT_REF_AND_RESET(_var) \ | |
296 | do { \ | |
297 | bt_field_class_put_ref(_var); \ | |
298 | (_var) = NULL; \ | |
299 | } while (0) | |
300 | ||
301 | #define BT_FIELD_CLASS_MOVE_REF(_var_dst, _var_src) \ | |
302 | do { \ | |
303 | bt_field_class_put_ref(_var_dst); \ | |
304 | (_var_dst) = (_var_src); \ | |
305 | (_var_src) = NULL; \ | |
306 | } while (0) | |
307 | ||
308 | ||
78cf9df6 PP |
309 | #ifdef __cplusplus |
310 | } | |
311 | #endif | |
312 | ||
3fd40f46 | 313 | #endif /* BABELTRACE2_TRACE_IR_FIELD_CLASS_CONST_H */ |