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