Allow unset tags on variant field types
[babeltrace.git] / include / babeltrace / ctf-ir / event-types.h
1 #ifndef BABELTRACE_CTF_IR_EVENT_TYPES_H
2 #define BABELTRACE_CTF_IR_EVENT_TYPES_H
3
4 /*
5 * BabelTrace - CTF IR: Event Types
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 <babeltrace/ctf/events.h>
34 #include <stdint.h>
35
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39
40 struct bt_ctf_event_class;
41 struct bt_ctf_event;
42 struct bt_ctf_field_type;
43 struct bt_ctf_field;
44
45 enum bt_ctf_integer_base {
46 BT_CTF_INTEGER_BASE_UNKNOWN = -1,
47 BT_CTF_INTEGER_BASE_BINARY = 2,
48 BT_CTF_INTEGER_BASE_OCTAL = 8,
49 BT_CTF_INTEGER_BASE_DECIMAL = 10,
50 BT_CTF_INTEGER_BASE_HEXADECIMAL = 16,
51 };
52
53 enum bt_ctf_byte_order {
54 BT_CTF_BYTE_ORDER_UNKNOWN = -1,
55 /*
56 * Note that native, in the context of the CTF specification, is defined as
57 * "the byte order described in the trace" and does not mean that the host's
58 * endianness will be used.
59 */
60 BT_CTF_BYTE_ORDER_NATIVE = 0,
61 BT_CTF_BYTE_ORDER_LITTLE_ENDIAN,
62 BT_CTF_BYTE_ORDER_BIG_ENDIAN,
63 BT_CTF_BYTE_ORDER_NETWORK,
64 };
65
66 /*
67 * bt_ctf_field_type_integer_create: create an integer field type.
68 *
69 * Allocate a new integer field type of the given size. The creation of a field
70 * type sets its reference count to 1.
71 *
72 * @param size Integer field type size/length in bits.
73 *
74 * Returns an allocated field type on success, NULL on error.
75 */
76 extern struct bt_ctf_field_type *bt_ctf_field_type_integer_create(
77 unsigned int size);
78
79 /*
80 * bt_ctf_field_type_integer_get_size: get an integer type's size.
81 *
82 * Get an integer type's size.
83 *
84 * @param integer Integer type.
85 *
86 * Returns the integer type's size, a negative value on error.
87 */
88 extern int bt_ctf_field_type_integer_get_size(
89 struct bt_ctf_field_type *integer);
90
91 /*
92 * bt_ctf_field_type_integer_get_signed: get an integer type's signedness.
93 *
94 * Get an integer type's signedness attribute.
95 *
96 * @param integer Integer type.
97 *
98 * Returns the integer's signedness, a negative value on error.
99 */
100 extern int bt_ctf_field_type_integer_get_signed(
101 struct bt_ctf_field_type *integer);
102
103 /*
104 * bt_ctf_field_type_integer_set_signed: set an integer type's signedness.
105 *
106 * Set an integer type's signedness attribute.
107 *
108 * @param integer Integer type.
109 * @param is_signed Integer's signedness, defaults to FALSE.
110 *
111 * Returns 0 on success, a negative value on error.
112 */
113 extern int bt_ctf_field_type_integer_set_signed(
114 struct bt_ctf_field_type *integer, int is_signed);
115
116 /*
117 * bt_ctf_field_type_integer_get_base: get an integer type's base.
118 *
119 * Get an integer type's base used to pretty-print the resulting trace.
120 *
121 * @param integer Integer type.
122 *
123 * Returns the integer type's base on success, BT_CTF_INTEGER_BASE_UNKNOWN on
124 * error.
125 */
126 extern enum bt_ctf_integer_base bt_ctf_field_type_integer_get_base(
127 struct bt_ctf_field_type *integer);
128
129 /*
130 * bt_ctf_field_type_integer_set_base: set an integer type's base.
131 *
132 * Set an integer type's base used to pretty-print the resulting trace.
133 *
134 * @param integer Integer type.
135 * @param base Integer base, defaults to BT_CTF_INTEGER_BASE_DECIMAL.
136 *
137 * Returns 0 on success, a negative value on error.
138 */
139 extern int bt_ctf_field_type_integer_set_base(struct bt_ctf_field_type *integer,
140 enum bt_ctf_integer_base base);
141
142 /*
143 * bt_ctf_field_type_integer_get_encoding: get an integer type's encoding.
144 *
145 * @param integer Integer type.
146 *
147 * Returns the string field's encoding on success, CTF_STRING_UNKNOWN on error.
148 */
149 extern enum ctf_string_encoding bt_ctf_field_type_integer_get_encoding(
150 struct bt_ctf_field_type *integer);
151
152 /*
153 * bt_ctf_field_type_integer_set_encoding: set an integer type's encoding.
154 *
155 * An integer encoding may be set to signal that the integer must be printed as
156 * a text character.
157 *
158 * @param integer Integer type.
159 * @param encoding Integer output encoding, defaults to CTF_STRING_ENCODING_NONE
160 *
161 * Returns 0 on success, a negative value on error.
162 */
163 extern int bt_ctf_field_type_integer_set_encoding(
164 struct bt_ctf_field_type *integer,
165 enum ctf_string_encoding encoding);
166
167 /**
168 * bt_ctf_field_type_integer_get_mapped_clock: get an integer type's mapped clock.
169 *
170 * @param integer Integer type.
171 *
172 * Returns the integer's mapped clock (if any), NULL on error.
173 */
174 extern struct bt_ctf_clock *bt_ctf_field_type_integer_get_mapped_clock(
175 struct bt_ctf_field_type *integer);
176
177 /**
178 * bt_ctf_field_type_integer_set_mapped_clock: set an integer type's mapped clock.
179 *
180 * @param integer Integer type.
181 * @param clock Clock to map.
182 *
183 * Returns 0 on success, a negative value on error.
184 */
185 extern int bt_ctf_field_type_integer_set_mapped_clock(
186 struct bt_ctf_field_type *integer,
187 struct bt_ctf_clock *clock);
188
189 /*
190 * bt_ctf_field_type_enumeration_create: create an enumeration field type.
191 *
192 * Allocate a new enumeration field type with the given underlying type. The
193 * creation of a field type sets its reference count to 1.
194 * The resulting enumeration will share the integer_container_type's ownership
195 * by increasing its reference count.
196 *
197 * @param integer_container_type Underlying integer type of the enumeration
198 * type.
199 *
200 * Returns an allocated field type on success, NULL on error.
201 */
202 extern struct bt_ctf_field_type *bt_ctf_field_type_enumeration_create(
203 struct bt_ctf_field_type *integer_container_type);
204
205 /*
206 * bt_ctf_field_type_enumeration_get_container_type: get underlying container.
207 *
208 * Get the enumeration type's underlying integer container type.
209 *
210 * @param enumeration Enumeration type.
211 *
212 * Returns an allocated field type on success, NULL on error.
213 */
214 extern
215 struct bt_ctf_field_type *bt_ctf_field_type_enumeration_get_container_type(
216 struct bt_ctf_field_type *enumeration);
217
218 /*
219 * bt_ctf_field_type_enumeration_add_mapping: add an enumeration mapping.
220 *
221 * Add a mapping to the enumeration. The range's values are inclusive.
222 *
223 * @param enumeration Enumeration type.
224 * @param name Enumeration mapping name (will be copied).
225 * @param range_start Enumeration mapping range start.
226 * @param range_end Enumeration mapping range end.
227 *
228 * Returns 0 on success, a negative value on error.
229 */
230 extern int bt_ctf_field_type_enumeration_add_mapping(
231 struct bt_ctf_field_type *enumeration, const char *name,
232 int64_t range_start, int64_t range_end);
233
234 /*
235 * bt_ctf_field_type_enumeration_add_mapping_unsigned: add an enumeration
236 * mapping.
237 *
238 * Add a mapping to the enumeration. The range's values are inclusive.
239 *
240 * @param enumeration Enumeration type.
241 * @param name Enumeration mapping name (will be copied).
242 * @param range_start Enumeration mapping range start.
243 * @param range_end Enumeration mapping range end.
244 *
245 * Returns 0 on success, a negative value on error.
246 */
247 extern int bt_ctf_field_type_enumeration_add_mapping_unsigned(
248 struct bt_ctf_field_type *enumeration, const char *name,
249 uint64_t range_start, uint64_t range_end);
250
251 /*
252 * bt_ctf_field_type_enumeration_get_mapping_count: Get the number of mappings
253 * defined in the enumeration.
254 *
255 * @param enumeration Enumeration type.
256 *
257 * Returns the mapping count on success, a negative value on error.
258 */
259 extern int bt_ctf_field_type_enumeration_get_mapping_count(
260 struct bt_ctf_field_type *enumeration);
261
262 /*
263 * bt_ctf_field_type_enumeration_get_mapping: get an enumeration mapping.
264 *
265 * @param enumeration Enumeration type.
266 * @param index Index of mapping.
267 * @param name Pointer where the mapping's name will be returned (valid for
268 * the lifetime of the enumeration).
269 * @param range_start Pointer where the enumeration mapping's range start will
270 * be returned.
271 * @param range_end Pointer where the enumeration mapping's range end will
272 * be returned.
273 *
274 * Returns 0 on success, a negative value on error.
275 */
276 extern int bt_ctf_field_type_enumeration_get_mapping(
277 struct bt_ctf_field_type *enumeration, int index,
278 const char **name, int64_t *range_start, int64_t *range_end);
279
280 /*
281 * bt_ctf_field_type_enumeration_get_mapping_unsigned: get a mapping.
282 *
283 * @param enumeration Enumeration type.
284 * @param index Index of mapping.
285 * @param name Pointer where the mapping's name will be returned (valid for
286 * the lifetime of the enumeration).
287 * @param range_start Pointer where the enumeration mapping's range start will
288 * be returned.
289 * @param range_end Pointer where the enumeration mapping's range end will
290 * be returned.
291 *
292 * Returns 0 on success, a negative value on error.
293 */
294 extern int bt_ctf_field_type_enumeration_get_mapping_unsigned(
295 struct bt_ctf_field_type *enumeration, int index,
296 const char **name, uint64_t *range_start,
297 uint64_t *range_end);
298
299 /*
300 * bt_ctf_field_type_enumeration_get_mapping_index_by_name: get an enumerations'
301 * mapping index by name.
302 *
303 * @param enumeration Enumeration type.
304 * @param name Mapping name.
305 *
306 * Returns mapping index on success, a negative value on error.
307 */
308 extern int bt_ctf_field_type_enumeration_get_mapping_index_by_name(
309 struct bt_ctf_field_type *enumeration, const char *name);
310
311 /*
312 * bt_ctf_field_type_enumeration_get_mapping_index_by_value: get an
313 * enumerations' mapping index by value.
314 *
315 * @param enumeration Enumeration type.
316 * @param value Value.
317 *
318 * Returns mapping index on success, a negative value on error.
319 */
320 extern int bt_ctf_field_type_enumeration_get_mapping_index_by_value(
321 struct bt_ctf_field_type *enumeration, int64_t value);
322
323 /*
324 * bt_ctf_field_type_enumeration_get_mapping_index_by_unsigned_value: get an
325 * enumerations' mapping index by value.
326 *
327 * @param enumeration Enumeration type.
328 * @param value Value.
329 *
330 * Returns 0 on success, a negative value on error.
331 */
332 extern int bt_ctf_field_type_enumeration_get_mapping_index_by_unsigned_value(
333 struct bt_ctf_field_type *enumeration, uint64_t value);
334
335 /*
336 * bt_ctf_field_type_floating_point_create: create a floating point field type.
337 *
338 * Allocate a new floating point field type. The creation of a field type sets
339 * its reference count to 1.
340 *
341 * Returns an allocated field type on success, NULL on error.
342 */
343 extern struct bt_ctf_field_type *bt_ctf_field_type_floating_point_create(void);
344
345 /*
346 * bt_ctf_field_type_floating_point_get_exponent_digits: get exponent digit
347 * count.
348 *
349 * @param floating_point Floating point type.
350 *
351 * Returns the exponent digit count on success, a negative value on error.
352 */
353 extern int bt_ctf_field_type_floating_point_get_exponent_digits(
354 struct bt_ctf_field_type *floating_point);
355
356 /*
357 * bt_ctf_field_type_floating_point_set_exponent_digits: set exponent digit
358 * count.
359 *
360 * Set the number of exponent digits to use to store the floating point field.
361 * The only values currently supported are FLT_EXP_DIG and DBL_EXP_DIG.
362 *
363 * @param floating_point Floating point type.
364 * @param exponent_digits Number of digits to allocate to the exponent (defaults
365 * to FLT_EXP_DIG).
366 *
367 * Returns 0 on success, a negative value on error.
368 */
369 extern int bt_ctf_field_type_floating_point_set_exponent_digits(
370 struct bt_ctf_field_type *floating_point,
371 unsigned int exponent_digits);
372
373 /*
374 * bt_ctf_field_type_floating_point_get_mantissa_digits: get mantissa digit
375 * count.
376 *
377 * @param floating_point Floating point type.
378 *
379 * Returns the mantissa digit count on success, a negative value on error.
380 */
381 extern int bt_ctf_field_type_floating_point_get_mantissa_digits(
382 struct bt_ctf_field_type *floating_point);
383
384 /*
385 * bt_ctf_field_type_floating_point_set_mantissa_digits: set mantissa digit
386 * count.
387 *
388 * Set the number of mantissa digits to use to store the floating point field.
389 * The only values currently supported are FLT_MANT_DIG and DBL_MANT_DIG.
390 *
391 * @param floating_point Floating point type.
392 * @param mantissa_digits Number of digits to allocate to the mantissa (defaults
393 * to FLT_MANT_DIG).
394 *
395 * Returns 0 on success, a negative value on error.
396 */
397 extern int bt_ctf_field_type_floating_point_set_mantissa_digits(
398 struct bt_ctf_field_type *floating_point,
399 unsigned int mantissa_digits);
400
401 /*
402 * bt_ctf_field_type_structure_create: create a structure field type.
403 *
404 * Allocate a new structure field type. The creation of a field type sets
405 * its reference count to 1.
406 *
407 * Returns an allocated field type on success, NULL on error.
408 */
409 extern struct bt_ctf_field_type *bt_ctf_field_type_structure_create(void);
410
411 /*
412 * bt_ctf_field_type_structure_add_field: add a field to a structure.
413 *
414 * Add a field of type "field_type" to the structure. The structure will share
415 * field_type's ownership by increasing its reference count.
416 *
417 * @param structure Structure type.
418 * @param field_type Type of the field to add to the structure type.
419 * @param field_name Name of the structure's new field (will be copied).
420 *
421 * Returns 0 on success, a negative value on error.
422 */
423 extern int bt_ctf_field_type_structure_add_field(
424 struct bt_ctf_field_type *structure,
425 struct bt_ctf_field_type *field_type,
426 const char *field_name);
427
428 /*
429 * bt_ctf_field_type_structure_get_field_count: Get the number of fields defined
430 * in the structure.
431 *
432 * @param structure Structure type.
433 *
434 * Returns the field count on success, a negative value on error.
435 */
436 extern int bt_ctf_field_type_structure_get_field_count(
437 struct bt_ctf_field_type *structure);
438
439 /*
440 * bt_ctf_field_type_structure_get_field: get a structure's field type and name.
441 *
442 * @param structure Structure type.
443 * @param field_type Pointer to a const char* where the field's name will
444 * be returned.
445 * @param field_type Pointer to a bt_ctf_field_type* where the field's type will
446 * be returned.
447 * @param index Index of field.
448 *
449 * Returns 0 on success, a negative value on error.
450 */
451 extern int bt_ctf_field_type_structure_get_field(
452 struct bt_ctf_field_type *structure,
453 const char **field_name, struct bt_ctf_field_type **field_type,
454 int index);
455
456 /*
457 * bt_ctf_field_type_structure_get_field_type_by_name: get a structure field's
458 * type by name.
459 *
460 * @param structure Structure type.
461 * @param field_name Name of the structure's field.
462 *
463 * Returns a field type instance on success, NULL on error.
464 */
465 extern
466 struct bt_ctf_field_type *bt_ctf_field_type_structure_get_field_type_by_name(
467 struct bt_ctf_field_type *structure, const char *field_name);
468
469 /*
470 * bt_ctf_field_type_variant_create: create a variant field type.
471 *
472 * Allocate a new variant field type. The creation of a field type sets
473 * its reference count to 1. tag_name must be the name of an enumeration
474 * field declared in the same scope as this variant.
475 *
476 * @param enum_tag Type of the variant's tag/selector (must be an enumeration).
477 * @param tag_name Name of the variant's tag/selector field (will be copied).
478 *
479 * Returns an allocated field type on success, NULL on error.
480 */
481 extern struct bt_ctf_field_type *bt_ctf_field_type_variant_create(
482 struct bt_ctf_field_type *enum_tag, const char *tag_name);
483
484 /*
485 * bt_ctf_field_type_variant_get_tag_type: get a variant's tag type.
486 *
487 * @param variant Variant type.
488 *
489 * Returns a field type instance on success, NULL if unset.
490 */
491 extern struct bt_ctf_field_type *bt_ctf_field_type_variant_get_tag_type(
492 struct bt_ctf_field_type *variant);
493
494 /*
495 * bt_ctf_field_type_variant_get_tag_name: get a variant's tag name.
496 *
497 * @param variant Variant type.
498 *
499 * Returns the tag field's name, NULL if unset.
500 */
501 extern const char *bt_ctf_field_type_variant_get_tag_name(
502 struct bt_ctf_field_type *variant);
503
504 /*
505 * bt_ctf_field_type_variant_add_field: add a field to a variant.
506 *
507 * Add a field of type "field_type" to the variant. The variant will share
508 * field_type's ownership by increasing its reference count. The "field_name"
509 * will be copied. field_name must match a mapping in the tag/selector
510 * enumeration.
511 *
512 * @param variant Variant type.
513 * @param field_type Type of the variant type's new field.
514 * @param field_name Name of the variant type's new field (will be copied).
515 *
516 * Returns 0 on success, a negative value on error.
517 */
518 extern int bt_ctf_field_type_variant_add_field(
519 struct bt_ctf_field_type *variant,
520 struct bt_ctf_field_type *field_type,
521 const char *field_name);
522
523 /*
524 * bt_ctf_field_type_variant_get_field_type_by_name: get variant field's type.
525 *
526 * @param structure Variant type.
527 * @param field_name Name of the variant's field.
528 *
529 * Returns a field type instance on success, NULL on error.
530 */
531 extern
532 struct bt_ctf_field_type *bt_ctf_field_type_variant_get_field_type_by_name(
533 struct bt_ctf_field_type *variant, const char *field_name);
534
535 /*
536 * bt_ctf_field_type_variant_get_field_type_from_tag: get variant field's type.
537 *
538 * @param variant Variant type.
539 * @param tag Type tag (enum).
540 *
541 * Returns a field type instance on success, NULL on error.
542 */
543 extern
544 struct bt_ctf_field_type *bt_ctf_field_type_variant_get_field_type_from_tag(
545 struct bt_ctf_field_type *variant, struct bt_ctf_field *tag);
546
547 /*
548 * bt_ctf_field_type_variant_get_field_count: Get the number of fields defined
549 * in the variant.
550 *
551 * @param variant Variant type.
552 *
553 * Returns the field count on success, a negative value on error.
554 */
555 extern int bt_ctf_field_type_variant_get_field_count(
556 struct bt_ctf_field_type *variant);
557
558 /*
559 * bt_ctf_field_type_variant_get_field: get a variant's field name and type.
560 *
561 * @param variant Variant type.
562 * @param field_type Pointer to a const char* where the field's name will
563 * be returned.
564 * @param field_type Pointer to a bt_ctf_field_type* where the field's type will
565 * be returned.
566 * @param index Index of field.
567 *
568 * Returns 0 on success, a negative value on error.
569 */
570 extern int bt_ctf_field_type_variant_get_field(
571 struct bt_ctf_field_type *variant, const char **field_name,
572 struct bt_ctf_field_type **field_type, int index);
573
574 /*
575 * bt_ctf_field_type_array_create: create an array field type.
576 *
577 * Allocate a new array field type. The creation of a field type sets
578 * its reference count to 1.
579 *
580 * @param element_type Array's element type.
581 * @oaram length Array type's length.
582 *
583 * Returns an allocated field type on success, NULL on error.
584 */
585 extern struct bt_ctf_field_type *bt_ctf_field_type_array_create(
586 struct bt_ctf_field_type *element_type, unsigned int length);
587
588 /*
589 * bt_ctf_field_type_array_get_element_type: get an array's element type.
590 *
591 * @param array Array type.
592 *
593 * Returns a field type instance on success, NULL on error.
594 */
595 extern struct bt_ctf_field_type *bt_ctf_field_type_array_get_element_type(
596 struct bt_ctf_field_type *array);
597
598 /*
599 * bt_ctf_field_type_array_get_length: get an array's length.
600 *
601 * @param array Array type.
602 *
603 * Returns the array's length on success, a negative value on error.
604 */
605 extern int64_t bt_ctf_field_type_array_get_length(
606 struct bt_ctf_field_type *array);
607
608 /*
609 * bt_ctf_field_type_sequence_create: create a sequence field type.
610 *
611 * Allocate a new sequence field type. The creation of a field type sets
612 * its reference count to 1. "length_field_name" must match an integer field
613 * declared in the same scope.
614 *
615 * @param element_type Sequence's element type.
616 * @param length_field_name Name of the sequence's length field (will be
617 * copied).
618 *
619 * Returns an allocated field type on success, NULL on error.
620 */
621 extern struct bt_ctf_field_type *bt_ctf_field_type_sequence_create(
622 struct bt_ctf_field_type *element_type,
623 const char *length_field_name);
624
625 /*
626 * bt_ctf_field_type_sequence_get_element_type: get a sequence's element type.
627 *
628 * @param sequence Sequence type.
629 *
630 * Returns a field type instance on success, NULL on error.
631 */
632 extern struct bt_ctf_field_type *bt_ctf_field_type_sequence_get_element_type(
633 struct bt_ctf_field_type *sequence);
634
635 /*
636 * bt_ctf_field_type_sequence_get_length_field_name: get length field name.
637 *
638 * @param sequence Sequence type.
639 *
640 * Returns the sequence's length field on success, NULL on error.
641 */
642 extern const char *bt_ctf_field_type_sequence_get_length_field_name(
643 struct bt_ctf_field_type *sequence);
644
645 /*
646 * bt_ctf_field_type_string_create: create a string field type.
647 *
648 * Allocate a new string field type. The creation of a field type sets
649 * its reference count to 1.
650 *
651 * Returns an allocated field type on success, NULL on error.
652 */
653 extern struct bt_ctf_field_type *bt_ctf_field_type_string_create(void);
654
655 /*
656 * bt_ctf_field_type_string_get_encoding: get a string type's encoding.
657 *
658 * Get the string type's encoding.
659 *
660 * @param string_type String type.
661 *
662 * Returns the string's encoding on success, a CTF_STRING_UNKNOWN on error.
663 */
664 extern enum ctf_string_encoding bt_ctf_field_type_string_get_encoding(
665 struct bt_ctf_field_type *string_type);
666
667 /*
668 * bt_ctf_field_type_string_set_encoding: set a string type's encoding.
669 *
670 * Set the string type's encoding.
671 *
672 * @param string_type String type.
673 * @param encoding String field encoding, default CTF_STRING_ENCODING_ASCII.
674 * Valid values are CTF_STRING_ENCODING_ASCII and CTF_STRING_ENCODING_UTF8.
675 *
676 * Returns 0 on success, a negative value on error.
677 */
678 extern int bt_ctf_field_type_string_set_encoding(
679 struct bt_ctf_field_type *string_type,
680 enum ctf_string_encoding encoding);
681
682 /*
683 * bt_ctf_field_type_get_alignment: get a field type's alignment.
684 *
685 * Get the field type's alignment.
686 *
687 * @param type Field type.
688 *
689 * Returns the field type's alignment on success, a negative value on error.
690 */
691 extern int bt_ctf_field_type_get_alignment(struct bt_ctf_field_type *type);
692
693 /*
694 * bt_ctf_field_type_set_alignment: set a field type's alignment.
695 *
696 * Set the field type's alignment.
697 *
698 * @param type Field type.
699 * @param alignment Type's alignment. Defaults to 1 (bit-aligned). However,
700 * some types, such as structures and string, may impose other alignment
701 * constraints.
702 *
703 * Returns 0 on success, a negative value on error.
704 */
705 extern int bt_ctf_field_type_set_alignment(struct bt_ctf_field_type *type,
706 unsigned int alignment);
707
708 /*
709 * bt_ctf_field_type_get_byte_order: get a field type's byte order.
710 *
711 * @param type Field type.
712 *
713 * Returns the field type's byte order on success, a negative value on error.
714 */
715 extern enum bt_ctf_byte_order bt_ctf_field_type_get_byte_order(
716 struct bt_ctf_field_type *type);
717
718 /*
719 * bt_ctf_field_type_set_byte_order: set a field type's byte order.
720 *
721 * Set the field type's byte order.
722 *
723 * @param type Field type.
724 * @param byte_order Field type's byte order. Defaults to
725 * BT_CTF_BYTE_ORDER_NATIVE; the trace's endianness.
726 *
727 * Returns 0 on success, a negative value on error.
728 */
729 extern int bt_ctf_field_type_set_byte_order(struct bt_ctf_field_type *type,
730 enum bt_ctf_byte_order byte_order);
731
732 /*
733 * bt_ctf_field_type_get_type_id: get a field type's ctf_type_id.
734 *
735 * @param type Field type.
736 *
737 * Returns the field type's ctf_type_id, CTF_TYPE_UNKNOWN on error.
738 */
739 extern enum ctf_type_id bt_ctf_field_type_get_type_id(
740 struct bt_ctf_field_type *type);
741
742 /*
743 * bt_ctf_field_type_get_alias_nameL get a field type's alias name
744 *
745 * A type's alias name is set if it was resolved from a typedef or
746 * typealias. Note that types that are resolved from a ypealias or
747 * typedef are distinct from the underlying type and can't be compared
748 * pointer-wise.
749 *
750 * @param type Field type.
751 *
752 * Returns a field type's alias name, NULL on error.
753 */
754 extern const char *bt_ctf_field_type_get_alias_name(
755 struct bt_ctf_field_type *type);
756
757 /*
758 * bt_ctf_field_type_get and bt_ctf_field_type_put: increment and decrement
759 * the field type's reference count.
760 *
761 * These functions ensure that the field type won't be destroyed while it
762 * is in use. The same number of get and put (plus one extra put to
763 * release the initial reference done at creation) have to be done to
764 * destroy a field type.
765 *
766 * When the field type's reference count is decremented to 0 by a
767 * bt_ctf_field_type_put, the field type is freed.
768 *
769 * @param type Field type.
770 */
771 extern void bt_ctf_field_type_get(struct bt_ctf_field_type *type);
772 extern void bt_ctf_field_type_put(struct bt_ctf_field_type *type);
773
774 #ifdef __cplusplus
775 }
776 #endif
777
778 #endif /* BABELTRACE_CTF_IR_EVENT_TYPES_H */
This page took 0.052074 seconds and 4 git commands to generate.