lib: rename include dir to babeltrace2
[babeltrace.git] / include / babeltrace2 / ctf-writer / field-types.h
1 #ifndef BABELTRACE_CTF_WRITER_FIELD_TYPES_H
2 #define BABELTRACE_CTF_WRITER_FIELD_TYPES_H
3
4 /*
5 * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 *
7 * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 *
9 * Permission is hereby granted, free of charge, to any person obtaining a copy
10 * of this software and associated documentation files (the "Software"), to deal
11 * in the Software without restriction, including without limitation the rights
12 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 * copies of the Software, and to permit persons to whom the Software is
14 * furnished to do so, subject to the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be included in
17 * all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 * SOFTWARE.
26 *
27 * The Common Trace Format (CTF) Specification is available at
28 * http://www.efficios.com/ctf
29 */
30
31 #include <stdint.h>
32 #include <stddef.h>
33
34 #include <babeltrace2/types.h>
35
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39
40 struct bt_ctf_field;
41 struct bt_ctf_field_type;
42
43 enum bt_ctf_scope {
44 /// Unknown, used for errors.
45 BT_CTF_SCOPE_UNKNOWN = -1,
46
47 /// Trace packet header.
48 BT_CTF_SCOPE_TRACE_PACKET_HEADER = 1,
49
50 /// Stream packet context.
51 BT_CTF_SCOPE_STREAM_PACKET_CONTEXT = 2,
52
53 /// Stream event header.
54 BT_CTF_SCOPE_STREAM_EVENT_HEADER = 3,
55
56 /// Stream event context.
57 BT_CTF_SCOPE_STREAM_EVENT_CONTEXT = 4,
58
59 /// Event context.
60 BT_CTF_SCOPE_EVENT_CONTEXT = 5,
61
62 /// Event payload.
63 BT_CTF_SCOPE_EVENT_PAYLOAD = 6,
64
65 /// @cond DOCUMENT
66 BT_CTF_SCOPE_ENV = 0,
67 BT_CTF_SCOPE_EVENT_FIELDS = 6,
68 /// @endcond
69 };
70
71 enum bt_ctf_field_type_id {
72 BT_CTF_FIELD_TYPE_ID_UNKNOWN = -1,
73 BT_CTF_FIELD_TYPE_ID_INTEGER = 0,
74 BT_CTF_FIELD_TYPE_ID_FLOAT = 1,
75 BT_CTF_FIELD_TYPE_ID_ENUM = 2,
76 BT_CTF_FIELD_TYPE_ID_STRING = 3,
77 BT_CTF_FIELD_TYPE_ID_STRUCT = 4,
78 BT_CTF_FIELD_TYPE_ID_ARRAY = 5,
79 BT_CTF_FIELD_TYPE_ID_SEQUENCE = 6,
80 BT_CTF_FIELD_TYPE_ID_VARIANT = 7,
81 BT_CTF_FIELD_TYPE_ID_NR,
82 };
83
84 extern enum bt_ctf_field_type_id bt_ctf_field_type_get_type_id(
85 struct bt_ctf_field_type *field_type);
86
87 enum bt_ctf_byte_order {
88 BT_CTF_BYTE_ORDER_UNKNOWN = -1,
89 BT_CTF_BYTE_ORDER_NATIVE = 0,
90 BT_CTF_BYTE_ORDER_UNSPECIFIED,
91 BT_CTF_BYTE_ORDER_LITTLE_ENDIAN,
92 BT_CTF_BYTE_ORDER_BIG_ENDIAN,
93 BT_CTF_BYTE_ORDER_NETWORK,
94 };
95
96 enum bt_ctf_string_encoding {
97 BT_CTF_STRING_ENCODING_UNKNOWN = -1,
98 BT_CTF_STRING_ENCODING_NONE,
99 BT_CTF_STRING_ENCODING_UTF8,
100 BT_CTF_STRING_ENCODING_ASCII,
101 };
102
103 /* Pre-2.0 CTF writer compatibility */
104 #define ctf_string_encoding bt_ctf_string_encoding
105
106 extern int bt_ctf_field_type_get_alignment(
107 struct bt_ctf_field_type *field_type);
108
109 extern int bt_ctf_field_type_set_alignment(struct bt_ctf_field_type *field_type,
110 unsigned int alignment);
111
112 extern enum bt_ctf_byte_order bt_ctf_field_type_get_byte_order(
113 struct bt_ctf_field_type *field_type);
114
115 extern int bt_ctf_field_type_set_byte_order(
116 struct bt_ctf_field_type *field_type,
117 enum bt_ctf_byte_order byte_order);
118
119 enum bt_ctf_integer_base {
120 /// Unknown, used for errors.
121 BT_CTF_INTEGER_BASE_UNKNOWN = -1,
122
123 /// Unspecified by the tracer.
124 BT_CTF_INTEGER_BASE_UNSPECIFIED = 0,
125
126 /// Binary.
127 BT_CTF_INTEGER_BASE_BINARY = 2,
128
129 /// Octal.
130 BT_CTF_INTEGER_BASE_OCTAL = 8,
131
132 /// Decimal.
133 BT_CTF_INTEGER_BASE_DECIMAL = 10,
134
135 /// Hexadecimal.
136 BT_CTF_INTEGER_BASE_HEXADECIMAL = 16,
137 };
138
139 extern struct bt_ctf_field_type *bt_ctf_field_type_integer_create(
140 unsigned int size);
141
142 extern int bt_ctf_field_type_integer_get_size(
143 struct bt_ctf_field_type *int_field_type);
144
145 extern int bt_ctf_field_type_integer_set_size(
146 struct bt_ctf_field_type *int_field_type, unsigned int size);
147
148 extern bt_bool bt_ctf_field_type_integer_is_signed(
149 struct bt_ctf_field_type *int_field_type);
150
151 /* Pre-2.0 CTF writer compatibility */
152 static inline
153 int bt_ctf_field_type_integer_get_signed(
154 struct bt_ctf_field_type *int_field_type)
155 {
156 return bt_ctf_field_type_integer_is_signed(int_field_type) ? 1 : 0;
157 }
158
159 extern int bt_ctf_field_type_integer_set_is_signed(
160 struct bt_ctf_field_type *int_field_type, bt_bool is_signed);
161
162 /* Pre-2.0 CTF writer compatibility */
163 static inline
164 int bt_ctf_field_type_integer_set_signed(
165 struct bt_ctf_field_type *int_field_type, int is_signed)
166 {
167 return bt_ctf_field_type_integer_set_is_signed(int_field_type,
168 is_signed ? BT_TRUE : BT_FALSE);
169 }
170
171 extern enum bt_ctf_integer_base bt_ctf_field_type_integer_get_base(
172 struct bt_ctf_field_type *int_field_type);
173
174 extern int bt_ctf_field_type_integer_set_base(
175 struct bt_ctf_field_type *int_field_type,
176 enum bt_ctf_integer_base base);
177
178 extern enum bt_ctf_string_encoding bt_ctf_field_type_integer_get_encoding(
179 struct bt_ctf_field_type *int_field_type);
180
181 extern int bt_ctf_field_type_integer_set_encoding(
182 struct bt_ctf_field_type *int_field_type,
183 enum bt_ctf_string_encoding encoding);
184
185 extern struct bt_ctf_clock_class *bt_ctf_field_type_integer_get_mapped_clock_class(
186 struct bt_ctf_field_type *int_field_type);
187
188 extern int bt_ctf_field_type_integer_set_mapped_clock_class(
189 struct bt_ctf_field_type *int_field_type,
190 struct bt_ctf_clock_class *clock_class);
191
192 extern struct bt_ctf_field_type *bt_ctf_field_type_floating_point_create(void);
193
194 extern int bt_ctf_field_type_floating_point_get_exponent_digits(
195 struct bt_ctf_field_type *float_field_type);
196
197 extern int bt_ctf_field_type_floating_point_set_exponent_digits(
198 struct bt_ctf_field_type *float_field_type,
199 unsigned int exponent_size);
200
201 extern int bt_ctf_field_type_floating_point_get_mantissa_digits(
202 struct bt_ctf_field_type *float_field_type);
203
204 extern int bt_ctf_field_type_floating_point_set_mantissa_digits(
205 struct bt_ctf_field_type *float_field_type,
206 unsigned int mantissa_sign_size);
207
208 extern struct bt_ctf_field_type *bt_ctf_field_type_enumeration_create(
209 struct bt_ctf_field_type *int_field_type);
210
211 extern
212 struct bt_ctf_field_type *bt_ctf_field_type_enumeration_get_container_field_type(
213 struct bt_ctf_field_type *enum_field_type);
214
215 extern int64_t bt_ctf_field_type_enumeration_get_mapping_count(
216 struct bt_ctf_field_type *enum_field_type);
217
218 extern int bt_ctf_field_type_enumeration_signed_get_mapping_by_index(
219 struct bt_ctf_field_type *enum_field_type, uint64_t index,
220 const char **name, int64_t *range_begin, int64_t *range_end);
221
222 extern int bt_ctf_field_type_enumeration_unsigned_get_mapping_by_index(
223 struct bt_ctf_field_type *enum_field_type, uint64_t index,
224 const char **name, uint64_t *range_begin,
225 uint64_t *range_end);
226
227 extern int bt_ctf_field_type_enumeration_signed_add_mapping(
228 struct bt_ctf_field_type *enum_field_type,
229 const char *name, int64_t range_begin, int64_t range_end);
230
231 extern int bt_ctf_field_type_enumeration_unsigned_add_mapping(
232 struct bt_ctf_field_type *enum_field_type,
233 const char *name, uint64_t range_begin, uint64_t range_end);
234
235 /* Pre-2.0 CTF writer compatibility */
236 static inline
237 int bt_ctf_field_type_enumeration_add_mapping(
238 struct bt_ctf_field_type *enumeration, const char *name,
239 int64_t range_start, int64_t range_end)
240 {
241 return bt_ctf_field_type_enumeration_signed_add_mapping(enumeration,
242 name, range_start, range_end);
243 }
244
245 extern struct bt_ctf_field_type *bt_ctf_field_type_string_create(void);
246
247 extern enum bt_ctf_string_encoding bt_ctf_field_type_string_get_encoding(
248 struct bt_ctf_field_type *string_field_type);
249
250 extern int bt_ctf_field_type_string_set_encoding(
251 struct bt_ctf_field_type *string_field_type,
252 enum bt_ctf_string_encoding encoding);
253
254 extern struct bt_ctf_field_type *bt_ctf_field_type_structure_create(void);
255
256 extern int64_t bt_ctf_field_type_structure_get_field_count(
257 struct bt_ctf_field_type *struct_field_type);
258
259 extern int bt_ctf_field_type_structure_get_field_by_index(
260 struct bt_ctf_field_type *struct_field_type,
261 const char **field_name, struct bt_ctf_field_type **field_type,
262 uint64_t index);
263
264 /* Pre-2.0 CTF writer compatibility */
265 static inline
266 int bt_ctf_field_type_structure_get_field(struct bt_ctf_field_type *structure,
267 const char **field_name, struct bt_ctf_field_type **field_type,
268 int index)
269 {
270 return bt_ctf_field_type_structure_get_field_by_index(structure,
271 field_name, field_type, (uint64_t) index);
272 }
273
274 extern
275 struct bt_ctf_field_type *bt_ctf_field_type_structure_get_field_type_by_name(
276 struct bt_ctf_field_type *struct_field_type,
277 const char *field_name);
278
279 extern int bt_ctf_field_type_structure_add_field(
280 struct bt_ctf_field_type *struct_field_type,
281 struct bt_ctf_field_type *field_type,
282 const char *field_name);
283
284 extern struct bt_ctf_field_type *bt_ctf_field_type_array_create(
285 struct bt_ctf_field_type *element_field_type,
286 unsigned int length);
287
288 extern struct bt_ctf_field_type *bt_ctf_field_type_array_get_element_field_type(
289 struct bt_ctf_field_type *array_field_type);
290
291 extern int64_t bt_ctf_field_type_array_get_length(
292 struct bt_ctf_field_type *array_field_type);
293
294 extern struct bt_ctf_field_type *bt_ctf_field_type_sequence_create(
295 struct bt_ctf_field_type *element_field_type,
296 const char *length_name);
297
298 extern struct bt_ctf_field_type *bt_ctf_field_type_sequence_get_element_field_type(
299 struct bt_ctf_field_type *sequence_field_type);
300
301 extern const char *bt_ctf_field_type_sequence_get_length_field_name(
302 struct bt_ctf_field_type *sequence_field_type);
303
304 extern struct bt_ctf_field_type *bt_ctf_field_type_variant_create(
305 struct bt_ctf_field_type *tag_field_type,
306 const char *tag_name);
307
308 extern struct bt_ctf_field_type *bt_ctf_field_type_variant_get_tag_field_type(
309 struct bt_ctf_field_type *variant_field_type);
310
311 extern const char *bt_ctf_field_type_variant_get_tag_name(
312 struct bt_ctf_field_type *variant_field_type);
313
314 extern int bt_ctf_field_type_variant_set_tag_name(
315 struct bt_ctf_field_type *variant_field_type,
316 const char *tag_name);
317
318 extern int64_t bt_ctf_field_type_variant_get_field_count(
319 struct bt_ctf_field_type *variant_field_type);
320
321 extern int bt_ctf_field_type_variant_get_field_by_index(
322 struct bt_ctf_field_type *variant_field_type,
323 const char **field_name,
324 struct bt_ctf_field_type **field_type, uint64_t index);
325
326 extern
327 struct bt_ctf_field_type *bt_ctf_field_type_variant_get_field_type_by_name(
328 struct bt_ctf_field_type *variant_field_type,
329 const char *field_name);
330
331 extern
332 struct bt_ctf_field_type *bt_ctf_field_type_variant_get_field_type_from_tag(
333 struct bt_ctf_field_type *variant_field_type,
334 struct bt_ctf_field *tag_field);
335
336 extern int bt_ctf_field_type_variant_add_field(
337 struct bt_ctf_field_type *variant_field_type,
338 struct bt_ctf_field_type *field_type,
339 const char *field_name);
340
341 #ifdef __cplusplus
342 }
343 #endif
344
345 #endif /* BABELTRACE_CTF_WRITER_FIELD_TYPES_H */
This page took 0.036539 seconds and 4 git commands to generate.