Fix: src.ctf.lttng-live: emitting stream end msg with no stream
[babeltrace.git] / include / babeltrace2 / trace-ir / field-class-const.h
CommitLineData
924dc299
PP
1#ifndef BABELTRACE2_TRACE_IR_FIELD_CLASS_CONST_H
2#define BABELTRACE2_TRACE_IR_FIELD_CLASS_CONST_H
40f4ba76
PP
3
4/*
bbb7b5f0 5 * Copyright (c) 2010-2019 EfficiOS Inc. and Linux Foundation
40f4ba76 6 *
40f4ba76
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.
40f4ba76
PP
24 */
25
4fa90f32
PP
26#ifndef __BT_IN_BABELTRACE_H
27# error "Please include <babeltrace2/babeltrace.h> instead."
28#endif
29
40f4ba76
PP
30#include <stdint.h>
31#include <stddef.h>
32
959b3d46
PP
33#include <babeltrace2/types.h>
34
40f4ba76
PP
35#ifdef __cplusplus
36extern "C" {
37#endif
38
4cdfc5e8 39typedef enum bt_field_class_type {
9c3869a9
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,
4cdfc5e8 79} bt_field_class_type;
40f4ba76 80
4cdfc5e8 81typedef enum bt_field_class_integer_preferred_display_base {
7b6afccb
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,
4cdfc5e8 86} bt_field_class_integer_preferred_display_base;
40f4ba76 87
4cdfc5e8 88extern bt_field_class_type bt_field_class_get_type(
b19ff26f 89 const bt_field_class *field_class);
40f4ba76 90
9c3869a9
PP
91static inline
92bt_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
c6962c96
PP
98extern const bt_value *bt_field_class_borrow_user_attributes_const(
99 const bt_field_class *field_class);
100
1094efa4
PP
101extern uint64_t bt_field_class_bit_array_get_length(
102 const bt_field_class *field_class);
103
40f4ba76 104extern uint64_t bt_field_class_integer_get_field_value_range(
b19ff26f 105 const bt_field_class *field_class);
40f4ba76 106
4cdfc5e8 107extern bt_field_class_integer_preferred_display_base
40f4ba76 108bt_field_class_integer_get_preferred_display_base(
b19ff26f 109 const bt_field_class *field_class);
40f4ba76 110
40f4ba76 111extern uint64_t bt_field_class_enumeration_get_mapping_count(
b19ff26f 112 const bt_field_class *field_class);
40f4ba76 113
9c08c816
PP
114extern const bt_field_class_enumeration_unsigned_mapping *
115bt_field_class_enumeration_unsigned_borrow_mapping_by_index_const(
8f3ccfbc
PP
116 const bt_field_class *field_class, uint64_t index);
117
9c08c816
PP
118extern const bt_field_class_enumeration_unsigned_mapping *
119bt_field_class_enumeration_unsigned_borrow_mapping_by_label_const(
45c51519
PP
120 const bt_field_class *field_class, const char *label);
121
9c08c816
PP
122extern const bt_field_class_enumeration_signed_mapping *
123bt_field_class_enumeration_signed_borrow_mapping_by_index_const(
8f3ccfbc
PP
124 const bt_field_class *field_class, uint64_t index);
125
9c08c816
PP
126extern const bt_field_class_enumeration_signed_mapping *
127bt_field_class_enumeration_signed_borrow_mapping_by_label_const(
45c51519
PP
128 const bt_field_class *field_class, const char *label);
129
8f3ccfbc
PP
130static inline
131const bt_field_class_enumeration_mapping *
9c08c816
PP
132bt_field_class_enumeration_unsigned_mapping_as_mapping_const(
133 const bt_field_class_enumeration_unsigned_mapping *mapping)
8f3ccfbc 134{
005f1204 135 return __BT_UPCAST_CONST(bt_field_class_enumeration_mapping, mapping);
8f3ccfbc 136}
40f4ba76 137
8f3ccfbc
PP
138static inline
139const bt_field_class_enumeration_mapping *
9c08c816
PP
140bt_field_class_enumeration_signed_mapping_as_mapping_const(
141 const bt_field_class_enumeration_signed_mapping *mapping)
8f3ccfbc 142{
005f1204 143 return __BT_UPCAST_CONST(bt_field_class_enumeration_mapping, mapping);
8f3ccfbc 144}
40f4ba76 145
8f3ccfbc
PP
146extern const char *bt_field_class_enumeration_mapping_get_label(
147 const bt_field_class_enumeration_mapping *mapping);
40f4ba76 148
45c51519 149extern const bt_integer_range_set_unsigned *
9c08c816
PP
150bt_field_class_enumeration_unsigned_mapping_borrow_ranges_const(
151 const bt_field_class_enumeration_unsigned_mapping *mapping);
40f4ba76 152
45c51519 153extern const bt_integer_range_set_signed *
9c08c816
PP
154bt_field_class_enumeration_signed_mapping_borrow_ranges_const(
155 const bt_field_class_enumeration_signed_mapping *mapping);
40f4ba76 156
185ecf64 157typedef enum bt_field_class_enumeration_get_mapping_labels_for_value_status {
d24d5663
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,
185ecf64 160} bt_field_class_enumeration_get_mapping_labels_for_value_status;
d24d5663 161
185ecf64 162extern bt_field_class_enumeration_get_mapping_labels_for_value_status
9c08c816 163bt_field_class_enumeration_unsigned_get_mapping_labels_for_value(
b19ff26f 164 const bt_field_class *field_class, uint64_t value,
40f4ba76
PP
165 bt_field_class_enumeration_mapping_label_array *label_array,
166 uint64_t *count);
167
185ecf64 168extern bt_field_class_enumeration_get_mapping_labels_for_value_status
9c08c816 169bt_field_class_enumeration_signed_get_mapping_labels_for_value(
b19ff26f 170 const bt_field_class *field_class, int64_t value,
40f4ba76
PP
171 bt_field_class_enumeration_mapping_label_array *label_array,
172 uint64_t *count);
173
174extern uint64_t bt_field_class_structure_get_member_count(
b19ff26f 175 const bt_field_class *field_class);
40f4ba76 176
1e6fd1d7
PP
177extern const bt_field_class_structure_member *
178bt_field_class_structure_borrow_member_by_index_const(
179 const bt_field_class *field_class, uint64_t index);
40f4ba76 180
1e6fd1d7
PP
181extern const bt_field_class_structure_member *
182bt_field_class_structure_borrow_member_by_name_const(
b19ff26f 183 const bt_field_class *field_class, const char *name);
40f4ba76 184
1e6fd1d7
PP
185extern const char *bt_field_class_structure_member_get_name(
186 const bt_field_class_structure_member *member);
187
188extern const bt_field_class *
189bt_field_class_structure_member_borrow_field_class_const(
190 const bt_field_class_structure_member *member);
191
c6962c96
PP
192extern const bt_value *bt_field_class_structure_member_borrow_user_attributes_const(
193 const bt_field_class_structure_member *member);
194
b19ff26f 195extern const bt_field_class *
40f4ba76 196bt_field_class_array_borrow_element_field_class_const(
b19ff26f 197 const bt_field_class *field_class);
40f4ba76 198
9c08c816 199extern uint64_t bt_field_class_array_static_get_length(
b19ff26f 200 const bt_field_class *field_class);
40f4ba76 201
b19ff26f 202extern const bt_field_path *
81b8fa44 203bt_field_class_array_dynamic_with_length_field_borrow_length_field_path_const(
b19ff26f 204 const bt_field_class *field_class);
40f4ba76 205
b38aea74
PP
206extern const bt_field_class *
207bt_field_class_option_borrow_field_class_const(
208 const bt_field_class *field_class);
209
210extern const bt_field_path *
de821fe5 211bt_field_class_option_with_selector_field_borrow_selector_field_path_const(
0aa006b7
PP
212 const bt_field_class *field_class);
213
214extern bt_bool
de821fe5 215bt_field_class_option_with_selector_field_bool_selector_is_reversed(
0aa006b7
PP
216 const bt_field_class *field_class);
217
218extern const bt_integer_range_set_unsigned *
de821fe5 219bt_field_class_option_with_selector_field_integer_unsigned_borrow_selector_ranges_const(
0aa006b7
PP
220 const bt_field_class *field_class);
221
222extern const bt_integer_range_set_signed *
de821fe5 223bt_field_class_option_with_selector_field_integer_signed_borrow_selector_ranges_const(
b38aea74
PP
224 const bt_field_class *field_class);
225
40f4ba76 226extern uint64_t bt_field_class_variant_get_option_count(
b19ff26f 227 const bt_field_class *field_class);
40f4ba76 228
1e6fd1d7
PP
229extern const bt_field_class_variant_option *
230bt_field_class_variant_borrow_option_by_index_const(
231 const bt_field_class *field_class, uint64_t index);
40f4ba76 232
1e6fd1d7
PP
233extern const bt_field_class_variant_option *
234bt_field_class_variant_borrow_option_by_name_const(
235 const bt_field_class *field_class, const char *name);
236
de821fe5
PP
237extern const bt_field_class_variant_with_selector_field_integer_unsigned_option *
238bt_field_class_variant_with_selector_field_integer_unsigned_borrow_option_by_index_const(
45c51519
PP
239 const bt_field_class *field_class, uint64_t index);
240
de821fe5
PP
241extern const bt_field_class_variant_with_selector_field_integer_unsigned_option *
242bt_field_class_variant_with_selector_field_integer_unsigned_borrow_option_by_name_const(
45c51519
PP
243 const bt_field_class *field_class, const char *name);
244
de821fe5
PP
245extern const bt_field_class_variant_with_selector_field_integer_signed_option *
246bt_field_class_variant_with_selector_field_integer_signed_borrow_option_by_index_const(
45c51519
PP
247 const bt_field_class *field_class, uint64_t index);
248
de821fe5
PP
249extern const bt_field_class_variant_with_selector_field_integer_signed_option *
250bt_field_class_variant_with_selector_field_integer_signed_borrow_option_by_name_const(
45c51519
PP
251 const bt_field_class *field_class, const char *name);
252
1e6fd1d7
PP
253extern const char *bt_field_class_variant_option_get_name(
254 const bt_field_class_variant_option *option);
255
256extern const bt_field_class *
257bt_field_class_variant_option_borrow_field_class_const(
258 const bt_field_class_variant_option *option);
40f4ba76 259
c6962c96
PP
260extern const bt_value *bt_field_class_variant_option_borrow_user_attributes_const(
261 const bt_field_class_variant_option *option);
262
45c51519 263extern const bt_field_path *
de821fe5 264bt_field_class_variant_with_selector_field_borrow_selector_field_path_const(
45c51519
PP
265 const bt_field_class *field_class);
266
267extern const bt_integer_range_set_unsigned *
de821fe5
PP
268bt_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);
45c51519
PP
270
271static inline
272const bt_field_class_variant_option *
de821fe5
PP
273bt_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)
45c51519
PP
275{
276 return __BT_UPCAST_CONST(bt_field_class_variant_option, option);
277}
278
279extern const bt_integer_range_set_signed *
de821fe5
PP
280bt_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);
45c51519
PP
282
283static inline
284const bt_field_class_variant_option *
de821fe5
PP
285bt_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)
45c51519
PP
287{
288 return __BT_UPCAST_CONST(bt_field_class_variant_option, option);
289}
290
b19ff26f 291extern void bt_field_class_get_ref(const bt_field_class *field_class);
c5b9b441 292
b19ff26f 293extern void bt_field_class_put_ref(const bt_field_class *field_class);
c5b9b441
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
40f4ba76
PP
309#ifdef __cplusplus
310}
311#endif
312
924dc299 313#endif /* BABELTRACE2_TRACE_IR_FIELD_CLASS_CONST_H */
This page took 0.059727 seconds and 4 git commands to generate.