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