bt2c::Logger: remove unused cLevel() method
[babeltrace.git] / include / babeltrace2-ctf-writer / field-types.h
CommitLineData
3dca2276 1/*
0235b0db 2 * SPDX-License-Identifier: MIT
3dca2276 3 *
0235b0db 4 * Copyright (C) 2010-2019 EfficiOS Inc. and Linux Foundation
3dca2276
PP
5 */
6
0235b0db
MJ
7#ifndef BABELTRACE2_CTF_WRITER_FIELD_TYPES_H
8#define BABELTRACE2_CTF_WRITER_FIELD_TYPES_H
9
3dca2276
PP
10#include <stdint.h>
11#include <stddef.h>
217cf9d3 12#include <babeltrace2-ctf-writer/types.h>
3dca2276
PP
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
18struct bt_ctf_field;
19struct bt_ctf_field_type;
20
16ca5ff0
PP
21enum bt_ctf_scope {
22 /// Unknown, used for errors.
23 BT_CTF_SCOPE_UNKNOWN = -1,
24
25 /// Trace packet header.
26 BT_CTF_SCOPE_TRACE_PACKET_HEADER = 1,
27
28 /// Stream packet context.
29 BT_CTF_SCOPE_STREAM_PACKET_CONTEXT = 2,
30
31 /// Stream event header.
32 BT_CTF_SCOPE_STREAM_EVENT_HEADER = 3,
33
34 /// Stream event context.
35 BT_CTF_SCOPE_STREAM_EVENT_CONTEXT = 4,
36
37 /// Event context.
38 BT_CTF_SCOPE_EVENT_CONTEXT = 5,
39
40 /// Event payload.
41 BT_CTF_SCOPE_EVENT_PAYLOAD = 6,
42
43 /// @cond DOCUMENT
44 BT_CTF_SCOPE_ENV = 0,
45 BT_CTF_SCOPE_EVENT_FIELDS = 6,
46 /// @endcond
47};
48
3dca2276 49enum bt_ctf_field_type_id {
16ca5ff0
PP
50 BT_CTF_FIELD_TYPE_ID_UNKNOWN = -1,
51 BT_CTF_FIELD_TYPE_ID_INTEGER = 0,
52 BT_CTF_FIELD_TYPE_ID_FLOAT = 1,
53 BT_CTF_FIELD_TYPE_ID_ENUM = 2,
54 BT_CTF_FIELD_TYPE_ID_STRING = 3,
55 BT_CTF_FIELD_TYPE_ID_STRUCT = 4,
56 BT_CTF_FIELD_TYPE_ID_ARRAY = 5,
57 BT_CTF_FIELD_TYPE_ID_SEQUENCE = 6,
58 BT_CTF_FIELD_TYPE_ID_VARIANT = 7,
59 BT_CTF_FIELD_TYPE_ID_NR,
3dca2276
PP
60};
61
62extern enum bt_ctf_field_type_id bt_ctf_field_type_get_type_id(
63 struct bt_ctf_field_type *field_type);
64
65enum bt_ctf_byte_order {
16ca5ff0
PP
66 BT_CTF_BYTE_ORDER_UNKNOWN = -1,
67 BT_CTF_BYTE_ORDER_NATIVE = 0,
68 BT_CTF_BYTE_ORDER_UNSPECIFIED,
69 BT_CTF_BYTE_ORDER_LITTLE_ENDIAN,
70 BT_CTF_BYTE_ORDER_BIG_ENDIAN,
71 BT_CTF_BYTE_ORDER_NETWORK,
3dca2276
PP
72};
73
74enum bt_ctf_string_encoding {
16ca5ff0
PP
75 BT_CTF_STRING_ENCODING_UNKNOWN = -1,
76 BT_CTF_STRING_ENCODING_NONE,
77 BT_CTF_STRING_ENCODING_UTF8,
78 BT_CTF_STRING_ENCODING_ASCII,
3dca2276
PP
79};
80
81/* Pre-2.0 CTF writer compatibility */
82#define ctf_string_encoding bt_ctf_string_encoding
83
84extern int bt_ctf_field_type_get_alignment(
85 struct bt_ctf_field_type *field_type);
86
87extern int bt_ctf_field_type_set_alignment(struct bt_ctf_field_type *field_type,
88 unsigned int alignment);
89
90extern enum bt_ctf_byte_order bt_ctf_field_type_get_byte_order(
91 struct bt_ctf_field_type *field_type);
92
93extern int bt_ctf_field_type_set_byte_order(
94 struct bt_ctf_field_type *field_type,
95 enum bt_ctf_byte_order byte_order);
96
97enum bt_ctf_integer_base {
98 /// Unknown, used for errors.
99 BT_CTF_INTEGER_BASE_UNKNOWN = -1,
100
101 /// Unspecified by the tracer.
102 BT_CTF_INTEGER_BASE_UNSPECIFIED = 0,
103
104 /// Binary.
105 BT_CTF_INTEGER_BASE_BINARY = 2,
106
107 /// Octal.
108 BT_CTF_INTEGER_BASE_OCTAL = 8,
109
110 /// Decimal.
111 BT_CTF_INTEGER_BASE_DECIMAL = 10,
112
113 /// Hexadecimal.
114 BT_CTF_INTEGER_BASE_HEXADECIMAL = 16,
115};
116
117extern struct bt_ctf_field_type *bt_ctf_field_type_integer_create(
118 unsigned int size);
119
120extern int bt_ctf_field_type_integer_get_size(
121 struct bt_ctf_field_type *int_field_type);
122
123extern int bt_ctf_field_type_integer_set_size(
124 struct bt_ctf_field_type *int_field_type, unsigned int size);
125
00409097 126extern bt_ctf_bool bt_ctf_field_type_integer_is_signed(
3dca2276
PP
127 struct bt_ctf_field_type *int_field_type);
128
129/* Pre-2.0 CTF writer compatibility */
130static inline
131int bt_ctf_field_type_integer_get_signed(
132 struct bt_ctf_field_type *int_field_type)
133{
134 return bt_ctf_field_type_integer_is_signed(int_field_type) ? 1 : 0;
135}
136
137extern int bt_ctf_field_type_integer_set_is_signed(
00409097 138 struct bt_ctf_field_type *int_field_type, bt_ctf_bool is_signed);
3dca2276
PP
139
140/* Pre-2.0 CTF writer compatibility */
141static inline
142int bt_ctf_field_type_integer_set_signed(
143 struct bt_ctf_field_type *int_field_type, int is_signed)
144{
145 return bt_ctf_field_type_integer_set_is_signed(int_field_type,
00409097 146 is_signed ? BT_CTF_TRUE : BT_CTF_FALSE);
3dca2276
PP
147}
148
149extern enum bt_ctf_integer_base bt_ctf_field_type_integer_get_base(
150 struct bt_ctf_field_type *int_field_type);
151
152extern int bt_ctf_field_type_integer_set_base(
153 struct bt_ctf_field_type *int_field_type,
154 enum bt_ctf_integer_base base);
155
156extern enum bt_ctf_string_encoding bt_ctf_field_type_integer_get_encoding(
157 struct bt_ctf_field_type *int_field_type);
158
159extern int bt_ctf_field_type_integer_set_encoding(
160 struct bt_ctf_field_type *int_field_type,
161 enum bt_ctf_string_encoding encoding);
162
163extern struct bt_ctf_clock_class *bt_ctf_field_type_integer_get_mapped_clock_class(
164 struct bt_ctf_field_type *int_field_type);
165
166extern int bt_ctf_field_type_integer_set_mapped_clock_class(
167 struct bt_ctf_field_type *int_field_type,
168 struct bt_ctf_clock_class *clock_class);
169
170extern struct bt_ctf_field_type *bt_ctf_field_type_floating_point_create(void);
171
172extern int bt_ctf_field_type_floating_point_get_exponent_digits(
173 struct bt_ctf_field_type *float_field_type);
174
175extern int bt_ctf_field_type_floating_point_set_exponent_digits(
176 struct bt_ctf_field_type *float_field_type,
177 unsigned int exponent_size);
178
179extern int bt_ctf_field_type_floating_point_get_mantissa_digits(
180 struct bt_ctf_field_type *float_field_type);
181
182extern int bt_ctf_field_type_floating_point_set_mantissa_digits(
183 struct bt_ctf_field_type *float_field_type,
184 unsigned int mantissa_sign_size);
185
186extern struct bt_ctf_field_type *bt_ctf_field_type_enumeration_create(
187 struct bt_ctf_field_type *int_field_type);
188
189extern
190struct bt_ctf_field_type *bt_ctf_field_type_enumeration_get_container_field_type(
191 struct bt_ctf_field_type *enum_field_type);
192
193extern int64_t bt_ctf_field_type_enumeration_get_mapping_count(
194 struct bt_ctf_field_type *enum_field_type);
195
196extern int bt_ctf_field_type_enumeration_signed_get_mapping_by_index(
197 struct bt_ctf_field_type *enum_field_type, uint64_t index,
198 const char **name, int64_t *range_begin, int64_t *range_end);
199
200extern int bt_ctf_field_type_enumeration_unsigned_get_mapping_by_index(
201 struct bt_ctf_field_type *enum_field_type, uint64_t index,
202 const char **name, uint64_t *range_begin,
203 uint64_t *range_end);
204
205extern int bt_ctf_field_type_enumeration_signed_add_mapping(
206 struct bt_ctf_field_type *enum_field_type,
207 const char *name, int64_t range_begin, int64_t range_end);
208
209extern int bt_ctf_field_type_enumeration_unsigned_add_mapping(
210 struct bt_ctf_field_type *enum_field_type,
211 const char *name, uint64_t range_begin, uint64_t range_end);
212
213/* Pre-2.0 CTF writer compatibility */
214static inline
215int bt_ctf_field_type_enumeration_add_mapping(
216 struct bt_ctf_field_type *enumeration, const char *name,
217 int64_t range_start, int64_t range_end)
218{
219 return bt_ctf_field_type_enumeration_signed_add_mapping(enumeration,
220 name, range_start, range_end);
221}
222
223extern struct bt_ctf_field_type *bt_ctf_field_type_string_create(void);
224
225extern enum bt_ctf_string_encoding bt_ctf_field_type_string_get_encoding(
226 struct bt_ctf_field_type *string_field_type);
227
228extern int bt_ctf_field_type_string_set_encoding(
229 struct bt_ctf_field_type *string_field_type,
230 enum bt_ctf_string_encoding encoding);
231
232extern struct bt_ctf_field_type *bt_ctf_field_type_structure_create(void);
233
234extern int64_t bt_ctf_field_type_structure_get_field_count(
235 struct bt_ctf_field_type *struct_field_type);
236
237extern int bt_ctf_field_type_structure_get_field_by_index(
238 struct bt_ctf_field_type *struct_field_type,
239 const char **field_name, struct bt_ctf_field_type **field_type,
240 uint64_t index);
241
242/* Pre-2.0 CTF writer compatibility */
243static inline
244int bt_ctf_field_type_structure_get_field(struct bt_ctf_field_type *structure,
245 const char **field_name, struct bt_ctf_field_type **field_type,
246 int index)
247{
248 return bt_ctf_field_type_structure_get_field_by_index(structure,
249 field_name, field_type, (uint64_t) index);
250}
251
252extern
253struct bt_ctf_field_type *bt_ctf_field_type_structure_get_field_type_by_name(
254 struct bt_ctf_field_type *struct_field_type,
255 const char *field_name);
256
257extern int bt_ctf_field_type_structure_add_field(
258 struct bt_ctf_field_type *struct_field_type,
259 struct bt_ctf_field_type *field_type,
260 const char *field_name);
261
262extern struct bt_ctf_field_type *bt_ctf_field_type_array_create(
263 struct bt_ctf_field_type *element_field_type,
264 unsigned int length);
265
266extern struct bt_ctf_field_type *bt_ctf_field_type_array_get_element_field_type(
267 struct bt_ctf_field_type *array_field_type);
268
269extern int64_t bt_ctf_field_type_array_get_length(
270 struct bt_ctf_field_type *array_field_type);
271
272extern struct bt_ctf_field_type *bt_ctf_field_type_sequence_create(
273 struct bt_ctf_field_type *element_field_type,
274 const char *length_name);
275
276extern struct bt_ctf_field_type *bt_ctf_field_type_sequence_get_element_field_type(
277 struct bt_ctf_field_type *sequence_field_type);
278
279extern const char *bt_ctf_field_type_sequence_get_length_field_name(
280 struct bt_ctf_field_type *sequence_field_type);
281
282extern struct bt_ctf_field_type *bt_ctf_field_type_variant_create(
283 struct bt_ctf_field_type *tag_field_type,
284 const char *tag_name);
285
286extern struct bt_ctf_field_type *bt_ctf_field_type_variant_get_tag_field_type(
287 struct bt_ctf_field_type *variant_field_type);
288
289extern const char *bt_ctf_field_type_variant_get_tag_name(
290 struct bt_ctf_field_type *variant_field_type);
291
292extern int bt_ctf_field_type_variant_set_tag_name(
293 struct bt_ctf_field_type *variant_field_type,
294 const char *tag_name);
295
296extern int64_t bt_ctf_field_type_variant_get_field_count(
297 struct bt_ctf_field_type *variant_field_type);
298
299extern int bt_ctf_field_type_variant_get_field_by_index(
300 struct bt_ctf_field_type *variant_field_type,
301 const char **field_name,
302 struct bt_ctf_field_type **field_type, uint64_t index);
303
304extern
305struct bt_ctf_field_type *bt_ctf_field_type_variant_get_field_type_by_name(
306 struct bt_ctf_field_type *variant_field_type,
307 const char *field_name);
308
309extern
310struct bt_ctf_field_type *bt_ctf_field_type_variant_get_field_type_from_tag(
311 struct bt_ctf_field_type *variant_field_type,
312 struct bt_ctf_field *tag_field);
313
314extern int bt_ctf_field_type_variant_add_field(
315 struct bt_ctf_field_type *variant_field_type,
316 struct bt_ctf_field_type *field_type,
317 const char *field_name);
318
319#ifdef __cplusplus
320}
321#endif
322
924dc299 323#endif /* BABELTRACE2_CTF_WRITER_FIELD_TYPES_H */
This page took 0.081528 seconds and 4 git commands to generate.