Fix: headers: make static inline upcasts compatible with C++
[babeltrace.git] / include / babeltrace / trace-ir / field-class-const.h
CommitLineData
40f4ba76
PP
1#ifndef BABELTRACE_TRACE_IR_FIELD_CLASSES_CONST_H
2#define BABELTRACE_TRACE_IR_FIELD_CLASSES_CONST_H
3
4/*
e2f7325d 5 * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
40f4ba76
PP
6 * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
7 *
40f4ba76
PP
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 * SOFTWARE.
25 *
26 * The Common Trace Format (CTF) Specification is available at
27 * http://www.efficios.com/ctf
28 */
29
b19ff26f 30/*
8f3ccfbc
PP
31 * For bt_bool, bt_field_class, bt_field_path,
32 * bt_field_class_enumeration_mapping,
33 * bt_field_class_unsigned_enumeration_mapping,
34 * bt_field_class_signed_enumeration_mapping,
005f1204 35 * bt_field_class_enumeration_mapping_label_array, __BT_UPCAST_CONST
b19ff26f 36 */
40f4ba76
PP
37#include <babeltrace/types.h>
38
39#include <stdint.h>
40#include <stddef.h>
41
42#ifdef __cplusplus
43extern "C" {
44#endif
45
4cdfc5e8 46typedef enum bt_field_class_status {
4295b9e0
PP
47 BT_FIELD_CLASS_STATUS_OK = 0,
48 BT_FIELD_CLASS_STATUS_NOMEM = -12,
4cdfc5e8 49} bt_field_class_status;
4295b9e0 50
4cdfc5e8 51typedef enum bt_field_class_type {
40f4ba76
PP
52 BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER,
53 BT_FIELD_CLASS_TYPE_SIGNED_INTEGER,
54 BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION,
55 BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION,
56 BT_FIELD_CLASS_TYPE_REAL,
57 BT_FIELD_CLASS_TYPE_STRING,
58 BT_FIELD_CLASS_TYPE_STRUCTURE,
59 BT_FIELD_CLASS_TYPE_STATIC_ARRAY,
60 BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY,
61 BT_FIELD_CLASS_TYPE_VARIANT,
4cdfc5e8 62} bt_field_class_type;
40f4ba76 63
4cdfc5e8 64typedef enum bt_field_class_integer_preferred_display_base {
40f4ba76
PP
65 BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_BINARY,
66 BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_OCTAL,
67 BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL,
68 BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL,
4cdfc5e8 69} bt_field_class_integer_preferred_display_base;
40f4ba76 70
4cdfc5e8 71extern bt_field_class_type bt_field_class_get_type(
b19ff26f 72 const bt_field_class *field_class);
40f4ba76
PP
73
74extern uint64_t bt_field_class_integer_get_field_value_range(
b19ff26f 75 const bt_field_class *field_class);
40f4ba76 76
4cdfc5e8 77extern bt_field_class_integer_preferred_display_base
40f4ba76 78bt_field_class_integer_get_preferred_display_base(
b19ff26f 79 const bt_field_class *field_class);
40f4ba76
PP
80
81extern bt_bool bt_field_class_real_is_single_precision(
b19ff26f 82 const bt_field_class *field_class);
40f4ba76
PP
83
84extern uint64_t bt_field_class_enumeration_get_mapping_count(
b19ff26f 85 const bt_field_class *field_class);
40f4ba76 86
8f3ccfbc
PP
87extern const bt_field_class_unsigned_enumeration_mapping *
88bt_field_class_unsigned_enumeration_borrow_mapping_by_index_const(
89 const bt_field_class *field_class, uint64_t index);
90
91extern const bt_field_class_signed_enumeration_mapping *
92bt_field_class_signed_enumeration_borrow_mapping_by_index_const(
93 const bt_field_class *field_class, uint64_t index);
94
95static inline
96const bt_field_class_enumeration_mapping *
97bt_field_class_unsigned_enumeration_mapping_as_mapping_const(
98 const bt_field_class_unsigned_enumeration_mapping *mapping)
99{
005f1204 100 return __BT_UPCAST_CONST(bt_field_class_enumeration_mapping, mapping);
8f3ccfbc 101}
40f4ba76 102
8f3ccfbc
PP
103static inline
104const bt_field_class_enumeration_mapping *
105bt_field_class_signed_enumeration_mapping_as_mapping_const(
106 const bt_field_class_signed_enumeration_mapping *mapping)
107{
005f1204 108 return __BT_UPCAST_CONST(bt_field_class_enumeration_mapping, mapping);
8f3ccfbc 109}
40f4ba76 110
8f3ccfbc
PP
111extern const char *bt_field_class_enumeration_mapping_get_label(
112 const bt_field_class_enumeration_mapping *mapping);
40f4ba76 113
8f3ccfbc
PP
114extern uint64_t bt_field_class_enumeration_mapping_get_range_count(
115 const bt_field_class_enumeration_mapping *mapping);
40f4ba76
PP
116
117extern void
8f3ccfbc
PP
118bt_field_class_unsigned_enumeration_mapping_get_range_by_index(
119 const bt_field_class_unsigned_enumeration_mapping *mapping,
40f4ba76
PP
120 uint64_t index, uint64_t *lower, uint64_t *upper);
121
122extern void
8f3ccfbc
PP
123bt_field_class_signed_enumeration_mapping_get_range_by_index(
124 const bt_field_class_signed_enumeration_mapping *mapping,
40f4ba76
PP
125 uint64_t index, int64_t *lower, int64_t *upper);
126
4cdfc5e8 127extern bt_field_class_status
4295b9e0 128bt_field_class_unsigned_enumeration_get_mapping_labels_by_value(
b19ff26f 129 const bt_field_class *field_class, uint64_t value,
40f4ba76
PP
130 bt_field_class_enumeration_mapping_label_array *label_array,
131 uint64_t *count);
132
4cdfc5e8 133extern bt_field_class_status
4295b9e0 134bt_field_class_signed_enumeration_get_mapping_labels_by_value(
b19ff26f 135 const bt_field_class *field_class, int64_t value,
40f4ba76
PP
136 bt_field_class_enumeration_mapping_label_array *label_array,
137 uint64_t *count);
138
139extern uint64_t bt_field_class_structure_get_member_count(
b19ff26f 140 const bt_field_class *field_class);
40f4ba76 141
1e6fd1d7
PP
142extern const bt_field_class_structure_member *
143bt_field_class_structure_borrow_member_by_index_const(
144 const bt_field_class *field_class, uint64_t index);
40f4ba76 145
1e6fd1d7
PP
146extern const bt_field_class_structure_member *
147bt_field_class_structure_borrow_member_by_name_const(
b19ff26f 148 const bt_field_class *field_class, const char *name);
40f4ba76 149
1e6fd1d7
PP
150extern const char *bt_field_class_structure_member_get_name(
151 const bt_field_class_structure_member *member);
152
153extern const bt_field_class *
154bt_field_class_structure_member_borrow_field_class_const(
155 const bt_field_class_structure_member *member);
156
b19ff26f 157extern const bt_field_class *
40f4ba76 158bt_field_class_array_borrow_element_field_class_const(
b19ff26f 159 const bt_field_class *field_class);
40f4ba76
PP
160
161extern uint64_t bt_field_class_static_array_get_length(
b19ff26f 162 const bt_field_class *field_class);
40f4ba76 163
b19ff26f 164extern const bt_field_path *
40f4ba76 165bt_field_class_dynamic_array_borrow_length_field_path_const(
b19ff26f 166 const bt_field_class *field_class);
40f4ba76 167
b19ff26f 168extern const bt_field_path *
40f4ba76 169bt_field_class_variant_borrow_selector_field_path_const(
b19ff26f 170 const bt_field_class *field_class);
40f4ba76
PP
171
172extern uint64_t bt_field_class_variant_get_option_count(
b19ff26f 173 const bt_field_class *field_class);
40f4ba76 174
1e6fd1d7
PP
175extern const bt_field_class_variant_option *
176bt_field_class_variant_borrow_option_by_index_const(
177 const bt_field_class *field_class, uint64_t index);
40f4ba76 178
1e6fd1d7
PP
179extern const bt_field_class_variant_option *
180bt_field_class_variant_borrow_option_by_name_const(
181 const bt_field_class *field_class, const char *name);
182
183extern const char *bt_field_class_variant_option_get_name(
184 const bt_field_class_variant_option *option);
185
186extern const bt_field_class *
187bt_field_class_variant_option_borrow_field_class_const(
188 const bt_field_class_variant_option *option);
40f4ba76 189
b19ff26f 190extern void bt_field_class_get_ref(const bt_field_class *field_class);
c5b9b441 191
b19ff26f 192extern void bt_field_class_put_ref(const bt_field_class *field_class);
c5b9b441
PP
193
194#define BT_FIELD_CLASS_PUT_REF_AND_RESET(_var) \
195 do { \
196 bt_field_class_put_ref(_var); \
197 (_var) = NULL; \
198 } while (0)
199
200#define BT_FIELD_CLASS_MOVE_REF(_var_dst, _var_src) \
201 do { \
202 bt_field_class_put_ref(_var_dst); \
203 (_var_dst) = (_var_src); \
204 (_var_src) = NULL; \
205 } while (0)
206
207
40f4ba76
PP
208#ifdef __cplusplus
209}
210#endif
211
212#endif /* BABELTRACE_TRACE_IR_FIELD_CLASSES_CONST_H */
This page took 0.035051 seconds and 4 git commands to generate.