1 #ifndef BABELTRACE_CTF_IR_FIELD_TYPES_H
2 #define BABELTRACE_CTF_IR_FIELD_TYPES_H
5 * BabelTrace - CTF IR: Event field types
7 * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
9 * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
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:
18 * The above copyright notice and this permission notice shall be included in
19 * all copies or substantial portions of the Software.
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
29 * The Common Trace Format (CTF) Specification is available at
30 * http://www.efficios.com/ctf
39 struct bt_ctf_event_class
;
41 struct bt_ctf_field_type
;
43 struct bt_ctf_field_path
;
46 * Babeltrace 1.x enumerations that were also used in CTF writer's API.
47 * They are left here for backward compatibility reasons, but
48 * enum bt_ctf_type_id and enum bt_ctf_string_encoding should be used
49 * in new code. Both new enumerations are compatible with their legacy
59 CTF_TYPE_UNTAGGED_VARIANT
,
69 enum ctf_string_encoding
{
77 BT_CTF_TYPE_ID_UNKNOWN
= CTF_TYPE_UNKNOWN
,
78 BT_CTF_TYPE_ID_INTEGER
= CTF_TYPE_INTEGER
,
79 BT_CTF_TYPE_ID_FLOAT
= CTF_TYPE_FLOAT
,
80 BT_CTF_TYPE_ID_ENUM
= CTF_TYPE_ENUM
,
81 BT_CTF_TYPE_ID_STRING
= CTF_TYPE_STRING
,
82 BT_CTF_TYPE_ID_STRUCT
= CTF_TYPE_STRUCT
,
83 BT_CTF_TYPE_ID_UNTAGGED_VARIANT
= CTF_TYPE_UNTAGGED_VARIANT
,
84 BT_CTF_TYPE_ID_VARIANT
= CTF_TYPE_VARIANT
,
85 BT_CTF_TYPE_ID_ARRAY
= CTF_TYPE_ARRAY
,
86 BT_CTF_TYPE_ID_SEQUENCE
= CTF_TYPE_SEQUENCE
,
90 enum bt_ctf_integer_base
{
91 BT_CTF_INTEGER_BASE_UNKNOWN
= -1,
92 BT_CTF_INTEGER_BASE_BINARY
= 2,
93 BT_CTF_INTEGER_BASE_OCTAL
= 8,
94 BT_CTF_INTEGER_BASE_DECIMAL
= 10,
95 BT_CTF_INTEGER_BASE_HEXADECIMAL
= 16,
98 enum bt_ctf_byte_order
{
99 BT_CTF_BYTE_ORDER_UNKNOWN
= -1,
101 * Note that native, in the context of the CTF specification, is defined
102 * as "the byte order described in the trace" and does not mean that the
103 * host's endianness will be used.
105 BT_CTF_BYTE_ORDER_NATIVE
= 0,
106 BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
,
107 BT_CTF_BYTE_ORDER_BIG_ENDIAN
,
108 BT_CTF_BYTE_ORDER_NETWORK
,
111 enum bt_ctf_string_encoding
{
112 BT_CTF_STRING_ENCODING_NONE
= CTF_STRING_NONE
,
113 BT_CTF_STRING_ENCODING_UTF8
= CTF_STRING_UTF8
,
114 BT_CTF_STRING_ENCODING_ASCII
= CTF_STRING_ASCII
,
115 BT_CTF_STRING_ENCODING_UNKNOWN
= CTF_STRING_UNKNOWN
,
119 BT_CTF_SCOPE_UNKNOWN
= -1,
120 BT_CTF_SCOPE_ENV
= 0,
121 BT_CTF_SCOPE_TRACE_PACKET_HEADER
= 1,
122 BT_CTF_SCOPE_STREAM_PACKET_CONTEXT
= 2,
123 BT_CTF_SCOPE_STREAM_EVENT_HEADER
= 3,
124 BT_CTF_SCOPE_STREAM_EVENT_CONTEXT
= 4,
125 BT_CTF_SCOPE_EVENT_CONTEXT
= 5,
126 BT_CTF_SCOPE_EVENT_FIELDS
= 6,
130 * bt_ctf_field_type_integer_create: create an integer field type.
132 * Allocate a new integer field type of the given size. The creation of a field
133 * type sets its reference count to 1.
135 * @param size Integer field type size/length in bits.
137 * Returns an allocated field type on success, NULL on error.
139 extern struct bt_ctf_field_type
*bt_ctf_field_type_integer_create(
143 * bt_ctf_field_type_integer_get_size: get an integer type's size.
145 * Get an integer type's size.
147 * @param integer Integer type.
149 * Returns the integer type's size, a negative value on error.
151 extern int bt_ctf_field_type_integer_get_size(
152 struct bt_ctf_field_type
*integer
);
155 * bt_ctf_field_type_integer_get_signed: get an integer type's signedness.
157 * Get an integer type's signedness attribute.
159 * @param integer Integer type.
161 * Returns the integer's signedness, a negative value on error.
163 extern int bt_ctf_field_type_integer_get_signed(
164 struct bt_ctf_field_type
*integer
);
167 * bt_ctf_field_type_integer_set_signed: set an integer type's signedness.
169 * Set an integer type's signedness attribute.
171 * @param integer Integer type.
172 * @param is_signed Integer's signedness, defaults to FALSE.
174 * Returns 0 on success, a negative value on error.
176 extern int bt_ctf_field_type_integer_set_signed(
177 struct bt_ctf_field_type
*integer
, int is_signed
);
180 * bt_ctf_field_type_integer_get_base: get an integer type's base.
182 * Get an integer type's base used to pretty-print the resulting trace.
184 * @param integer Integer type.
186 * Returns the integer type's base on success, BT_CTF_INTEGER_BASE_UNKNOWN on
189 extern enum bt_ctf_integer_base
bt_ctf_field_type_integer_get_base(
190 struct bt_ctf_field_type
*integer
);
193 * bt_ctf_field_type_integer_set_base: set an integer type's base.
195 * Set an integer type's base used to pretty-print the resulting trace.
197 * @param integer Integer type.
198 * @param base Integer base, defaults to BT_CTF_INTEGER_BASE_DECIMAL.
200 * Returns 0 on success, a negative value on error.
202 extern int bt_ctf_field_type_integer_set_base(struct bt_ctf_field_type
*integer
,
203 enum bt_ctf_integer_base base
);
206 * bt_ctf_field_type_integer_get_encoding: get an integer type's encoding.
208 * @param integer Integer type.
210 * Returns the string field's encoding on success,
211 * BT_CTF_STRING_ENCODING_UNKNOWN on error.
213 extern enum bt_ctf_string_encoding
bt_ctf_field_type_integer_get_encoding(
214 struct bt_ctf_field_type
*integer
);
217 * bt_ctf_field_type_integer_set_encoding: set an integer type's encoding.
219 * An integer encoding may be set to signal that the integer must be printed as
222 * @param integer Integer type.
223 * @param encoding Integer output encoding, defaults to
224 * BT_CTF_STRING_ENCODING_NONE
226 * Returns 0 on success, a negative value on error.
228 extern int bt_ctf_field_type_integer_set_encoding(
229 struct bt_ctf_field_type
*integer
,
230 enum bt_ctf_string_encoding encoding
);
233 * bt_ctf_field_type_integer_get_mapped_clock: get an integer type's mapped clock.
235 * @param integer Integer type.
237 * Returns the integer's mapped clock (if any), NULL on error.
239 extern struct bt_ctf_clock
*bt_ctf_field_type_integer_get_mapped_clock(
240 struct bt_ctf_field_type
*integer
);
243 * bt_ctf_field_type_integer_set_mapped_clock: set an integer type's mapped clock.
245 * @param integer Integer type.
246 * @param clock Clock to map.
248 * Returns 0 on success, a negative value on error.
250 extern int bt_ctf_field_type_integer_set_mapped_clock(
251 struct bt_ctf_field_type
*integer
,
252 struct bt_ctf_clock
*clock
);
255 * bt_ctf_field_type_enumeration_create: create an enumeration field type.
257 * Allocate a new enumeration field type with the given underlying type. The
258 * creation of a field type sets its reference count to 1.
259 * The resulting enumeration will share the integer_container_type's ownership
260 * by increasing its reference count.
262 * @param integer_container_type Underlying integer type of the enumeration
265 * Returns an allocated field type on success, NULL on error.
267 extern struct bt_ctf_field_type
*bt_ctf_field_type_enumeration_create(
268 struct bt_ctf_field_type
*integer_container_type
);
271 * bt_ctf_field_type_enumeration_get_container_type: get underlying container.
273 * Get the enumeration type's underlying integer container type.
275 * @param enumeration Enumeration type.
277 * Returns an allocated field type on success, NULL on error.
280 struct bt_ctf_field_type
*bt_ctf_field_type_enumeration_get_container_type(
281 struct bt_ctf_field_type
*enumeration
);
284 * bt_ctf_field_type_enumeration_add_mapping: add an enumeration mapping.
286 * Add a mapping to the enumeration. The range's values are inclusive.
288 * @param enumeration Enumeration type.
289 * @param name Enumeration mapping name (will be copied).
290 * @param range_start Enumeration mapping range start.
291 * @param range_end Enumeration mapping range end.
293 * Returns 0 on success, a negative value on error.
295 extern int bt_ctf_field_type_enumeration_add_mapping(
296 struct bt_ctf_field_type
*enumeration
, const char *name
,
297 int64_t range_start
, int64_t range_end
);
300 * bt_ctf_field_type_enumeration_add_mapping_unsigned: add an enumeration
303 * Add a mapping to the enumeration. The range's values are inclusive.
305 * @param enumeration Enumeration type.
306 * @param name Enumeration mapping name (will be copied).
307 * @param range_start Enumeration mapping range start.
308 * @param range_end Enumeration mapping range end.
310 * Returns 0 on success, a negative value on error.
312 extern int bt_ctf_field_type_enumeration_add_mapping_unsigned(
313 struct bt_ctf_field_type
*enumeration
, const char *name
,
314 uint64_t range_start
, uint64_t range_end
);
317 * bt_ctf_field_type_enumeration_get_mapping_count: Get the number of mappings
318 * defined in the enumeration.
320 * @param enumeration Enumeration type.
322 * Returns the mapping count on success, a negative value on error.
324 extern int bt_ctf_field_type_enumeration_get_mapping_count(
325 struct bt_ctf_field_type
*enumeration
);
328 * bt_ctf_field_type_enumeration_get_mapping: get an enumeration mapping.
330 * @param enumeration Enumeration type.
331 * @param index Index of mapping.
332 * @param name Pointer where the mapping's name will be returned (valid for
333 * the lifetime of the enumeration).
334 * @param range_start Pointer where the enumeration mapping's range start will
336 * @param range_end Pointer where the enumeration mapping's range end will
339 * Returns 0 on success, a negative value on error.
341 extern int bt_ctf_field_type_enumeration_get_mapping(
342 struct bt_ctf_field_type
*enumeration
, int index
,
343 const char **name
, int64_t *range_start
, int64_t *range_end
);
346 * bt_ctf_field_type_enumeration_get_mapping_unsigned: get a mapping.
348 * @param enumeration Enumeration type.
349 * @param index Index of mapping.
350 * @param name Pointer where the mapping's name will be returned (valid for
351 * the lifetime of the enumeration).
352 * @param range_start Pointer where the enumeration mapping's range start will
354 * @param range_end Pointer where the enumeration mapping's range end will
357 * Returns 0 on success, a negative value on error.
359 extern int bt_ctf_field_type_enumeration_get_mapping_unsigned(
360 struct bt_ctf_field_type
*enumeration
, int index
,
361 const char **name
, uint64_t *range_start
,
362 uint64_t *range_end
);
365 * bt_ctf_field_type_enumeration_get_mapping_index_by_name: get an enumerations'
366 * mapping index by name.
368 * @param enumeration Enumeration type.
369 * @param name Mapping name.
371 * Returns mapping index on success, a negative value on error.
373 extern int bt_ctf_field_type_enumeration_get_mapping_index_by_name(
374 struct bt_ctf_field_type
*enumeration
, const char *name
);
377 * bt_ctf_field_type_enumeration_get_mapping_index_by_value: get an
378 * enumerations' mapping index by value.
380 * @param enumeration Enumeration type.
381 * @param value Value.
383 * Returns mapping index on success, a negative value on error.
385 extern int bt_ctf_field_type_enumeration_get_mapping_index_by_value(
386 struct bt_ctf_field_type
*enumeration
, int64_t value
);
389 * bt_ctf_field_type_enumeration_get_mapping_index_by_unsigned_value: get an
390 * enumerations' mapping index by value.
392 * @param enumeration Enumeration type.
393 * @param value Value.
395 * Returns 0 on success, a negative value on error.
397 extern int bt_ctf_field_type_enumeration_get_mapping_index_by_unsigned_value(
398 struct bt_ctf_field_type
*enumeration
, uint64_t value
);
401 * bt_ctf_field_type_floating_point_create: create a floating point field type.
403 * Allocate a new floating point field type. The creation of a field type sets
404 * its reference count to 1.
406 * Returns an allocated field type on success, NULL on error.
408 extern struct bt_ctf_field_type
*bt_ctf_field_type_floating_point_create(void);
411 * bt_ctf_field_type_floating_point_get_exponent_digits: get exponent digit
414 * @param floating_point Floating point type.
416 * Returns the exponent digit count on success, a negative value on error.
418 extern int bt_ctf_field_type_floating_point_get_exponent_digits(
419 struct bt_ctf_field_type
*floating_point
);
422 * bt_ctf_field_type_floating_point_set_exponent_digits: set exponent digit
425 * Set the number of exponent digits to use to store the floating point field.
426 * The only values currently supported are FLT_EXP_DIG and DBL_EXP_DIG.
428 * @param floating_point Floating point type.
429 * @param exponent_digits Number of digits to allocate to the exponent (defaults
432 * Returns 0 on success, a negative value on error.
434 extern int bt_ctf_field_type_floating_point_set_exponent_digits(
435 struct bt_ctf_field_type
*floating_point
,
436 unsigned int exponent_digits
);
439 * bt_ctf_field_type_floating_point_get_mantissa_digits: get mantissa digit
442 * @param floating_point Floating point type.
444 * Returns the mantissa digit count on success, a negative value on error.
446 extern int bt_ctf_field_type_floating_point_get_mantissa_digits(
447 struct bt_ctf_field_type
*floating_point
);
450 * bt_ctf_field_type_floating_point_set_mantissa_digits: set mantissa digit
453 * Set the number of mantissa digits to use to store the floating point field.
454 * The only values currently supported are FLT_MANT_DIG and DBL_MANT_DIG.
456 * @param floating_point Floating point type.
457 * @param mantissa_digits Number of digits to allocate to the mantissa (defaults
460 * Returns 0 on success, a negative value on error.
462 extern int bt_ctf_field_type_floating_point_set_mantissa_digits(
463 struct bt_ctf_field_type
*floating_point
,
464 unsigned int mantissa_digits
);
467 * bt_ctf_field_type_structure_create: create a structure field type.
469 * Allocate a new structure field type. The creation of a field type sets
470 * its reference count to 1.
472 * Returns an allocated field type on success, NULL on error.
474 extern struct bt_ctf_field_type
*bt_ctf_field_type_structure_create(void);
477 * bt_ctf_field_type_structure_add_field: add a field to a structure.
479 * Add a field of type "field_type" to the structure. The structure will share
480 * field_type's ownership by increasing its reference count.
482 * @param structure Structure type.
483 * @param field_type Type of the field to add to the structure type.
484 * @param field_name Name of the structure's new field (will be copied).
486 * Returns 0 on success, a negative value on error.
488 extern int bt_ctf_field_type_structure_add_field(
489 struct bt_ctf_field_type
*structure
,
490 struct bt_ctf_field_type
*field_type
,
491 const char *field_name
);
494 * bt_ctf_field_type_structure_get_field_count: Get the number of fields defined
497 * @param structure Structure type.
499 * Returns the field count on success, a negative value on error.
501 extern int bt_ctf_field_type_structure_get_field_count(
502 struct bt_ctf_field_type
*structure
);
505 * bt_ctf_field_type_structure_get_field: get a structure's field type and name.
507 * @param structure Structure type.
508 * @param field_type Pointer to a const char* where the field's name will
510 * @param field_type Pointer to a bt_ctf_field_type* where the field's type will
512 * @param index Index of field.
514 * Returns 0 on success, a negative value on error.
516 extern int bt_ctf_field_type_structure_get_field(
517 struct bt_ctf_field_type
*structure
,
518 const char **field_name
, struct bt_ctf_field_type
**field_type
,
522 * bt_ctf_field_type_structure_get_field_type_by_name: get a structure field's
525 * @param structure Structure type.
526 * @param field_name Name of the structure's field.
528 * Returns a field type instance on success, NULL on error.
531 struct bt_ctf_field_type
*bt_ctf_field_type_structure_get_field_type_by_name(
532 struct bt_ctf_field_type
*structure
, const char *field_name
);
535 * bt_ctf_field_type_variant_create: create a variant field type.
537 * Allocate a new variant field type. The creation of a field type sets
538 * its reference count to 1. tag_name must be the name of an enumeration
539 * field declared in the same scope as this variant.
541 * @param enum_tag Type of the variant's tag/selector (must be an enumeration).
542 * @param tag_name Name of the variant's tag/selector field (will be copied).
544 * Returns an allocated field type on success, NULL on error.
546 extern struct bt_ctf_field_type
*bt_ctf_field_type_variant_create(
547 struct bt_ctf_field_type
*enum_tag
, const char *tag_name
);
550 * bt_ctf_field_type_variant_get_tag_type: get a variant's tag type.
552 * @param variant Variant type.
554 * Returns a field type instance on success, NULL if unset.
556 extern struct bt_ctf_field_type
*bt_ctf_field_type_variant_get_tag_type(
557 struct bt_ctf_field_type
*variant
);
560 * bt_ctf_field_type_variant_get_tag_name: get a variant's tag name.
562 * @param variant Variant type.
564 * Returns the tag field's name, NULL if unset.
566 extern const char *bt_ctf_field_type_variant_get_tag_name(
567 struct bt_ctf_field_type
*variant
);
570 * bt_ctf_field_type_variant_set_tag_name: set a variant's tag name.
572 * @param variant Variant type.
573 * @param name Tag field name.
575 * Returns 0 on success, a negative value on error.
577 extern int bt_ctf_field_type_variant_set_tag_name(
578 struct bt_ctf_field_type
*variant
, const char *name
);
581 * bt_ctf_field_type_variant_add_field: add a field to a variant.
583 * Add a field of type "field_type" to the variant. The variant will share
584 * field_type's ownership by increasing its reference count. The "field_name"
585 * will be copied. field_name must match a mapping in the tag/selector
588 * @param variant Variant type.
589 * @param field_type Type of the variant type's new field.
590 * @param field_name Name of the variant type's new field (will be copied).
592 * Returns 0 on success, a negative value on error.
594 extern int bt_ctf_field_type_variant_add_field(
595 struct bt_ctf_field_type
*variant
,
596 struct bt_ctf_field_type
*field_type
,
597 const char *field_name
);
600 * bt_ctf_field_type_variant_get_field_type_by_name: get variant field's type.
602 * @param structure Variant type.
603 * @param field_name Name of the variant's field.
605 * Returns a field type instance on success, NULL on error.
608 struct bt_ctf_field_type
*bt_ctf_field_type_variant_get_field_type_by_name(
609 struct bt_ctf_field_type
*variant
, const char *field_name
);
612 * bt_ctf_field_type_variant_get_field_type_from_tag: get variant field's type.
614 * @param variant Variant type.
615 * @param tag Type tag (enum).
617 * Returns a field type instance on success, NULL on error.
620 struct bt_ctf_field_type
*bt_ctf_field_type_variant_get_field_type_from_tag(
621 struct bt_ctf_field_type
*variant
, struct bt_ctf_field
*tag
);
624 * bt_ctf_field_type_variant_get_field_count: Get the number of fields defined
627 * @param variant Variant type.
629 * Returns the field count on success, a negative value on error.
631 extern int bt_ctf_field_type_variant_get_field_count(
632 struct bt_ctf_field_type
*variant
);
635 * bt_ctf_field_type_variant_get_field: get a variant's field name and type.
637 * @param variant Variant type.
638 * @param field_type Pointer to a const char* where the field's name will
640 * @param field_type Pointer to a bt_ctf_field_type* where the field's type will
642 * @param index Index of field.
644 * Returns 0 on success, a negative value on error.
646 extern int bt_ctf_field_type_variant_get_field(
647 struct bt_ctf_field_type
*variant
, const char **field_name
,
648 struct bt_ctf_field_type
**field_type
, int index
);
651 * bt_ctf_field_type_array_create: create an array field type.
653 * Allocate a new array field type. The creation of a field type sets
654 * its reference count to 1.
656 * @param element_type Array's element type.
657 * @oaram length Array type's length.
659 * Returns an allocated field type on success, NULL on error.
661 extern struct bt_ctf_field_type
*bt_ctf_field_type_array_create(
662 struct bt_ctf_field_type
*element_type
, unsigned int length
);
665 * bt_ctf_field_type_array_get_element_type: get an array's element type.
667 * @param array Array type.
669 * Returns a field type instance on success, NULL on error.
671 extern struct bt_ctf_field_type
*bt_ctf_field_type_array_get_element_type(
672 struct bt_ctf_field_type
*array
);
675 * bt_ctf_field_type_array_get_length: get an array's length.
677 * @param array Array type.
679 * Returns the array's length on success, a negative value on error.
681 extern int64_t bt_ctf_field_type_array_get_length(
682 struct bt_ctf_field_type
*array
);
685 * bt_ctf_field_type_sequence_create: create a sequence field type.
687 * Allocate a new sequence field type. The creation of a field type sets
688 * its reference count to 1. "length_field_name" must match an integer field
689 * declared in the same scope.
691 * @param element_type Sequence's element type.
692 * @param length_field_name Name of the sequence's length field (will be
695 * Returns an allocated field type on success, NULL on error.
697 extern struct bt_ctf_field_type
*bt_ctf_field_type_sequence_create(
698 struct bt_ctf_field_type
*element_type
,
699 const char *length_field_name
);
702 * bt_ctf_field_type_sequence_get_element_type: get a sequence's element type.
704 * @param sequence Sequence type.
706 * Returns a field type instance on success, NULL on error.
708 extern struct bt_ctf_field_type
*bt_ctf_field_type_sequence_get_element_type(
709 struct bt_ctf_field_type
*sequence
);
712 * bt_ctf_field_type_sequence_get_length_field_name: get length field name.
714 * @param sequence Sequence type.
716 * Returns the sequence's length field on success, NULL on error.
718 extern const char *bt_ctf_field_type_sequence_get_length_field_name(
719 struct bt_ctf_field_type
*sequence
);
722 * bt_ctf_field_type_string_create: create a string field type.
724 * Allocate a new string field type. The creation of a field type sets
725 * its reference count to 1.
727 * Returns an allocated field type on success, NULL on error.
729 extern struct bt_ctf_field_type
*bt_ctf_field_type_string_create(void);
732 * bt_ctf_field_type_string_get_encoding: get a string type's encoding.
734 * Get the string type's encoding.
736 * @param string_type String type.
738 * Returns the string's encoding on success, a BT_CTF_STRING_ENCODING_UNKNOWN
741 extern enum bt_ctf_string_encoding
bt_ctf_field_type_string_get_encoding(
742 struct bt_ctf_field_type
*string_type
);
745 * bt_ctf_field_type_string_set_encoding: set a string type's encoding.
747 * Set the string type's encoding.
749 * @param string_type String type.
750 * @param encoding String field encoding, default BT_CTF_STRING_ENCODING_ASCII.
751 * Valid values are BT_CTF_STRING_ENCODING_ASCII and
752 * BT_CTF_STRING_ENCODING_UTF8.
754 * Returns 0 on success, a negative value on error.
756 extern int bt_ctf_field_type_string_set_encoding(
757 struct bt_ctf_field_type
*string_type
,
758 enum bt_ctf_string_encoding encoding
);
761 * bt_ctf_field_type_get_alignment: get a field type's alignment.
763 * Get the field type's alignment.
765 * @param type Field type.
767 * Returns the field type's alignment on success, a negative value on error and
768 * 0 if the alignment is undefined (as in the case of a variant).
770 extern int bt_ctf_field_type_get_alignment(struct bt_ctf_field_type
*type
);
773 * bt_ctf_field_type_set_alignment: set a field type's alignment.
775 * Set the field type's alignment.
777 * @param type Field type.
778 * @param alignment Type's alignment. Defaults to 1 (bit-aligned). However,
779 * some types, such as structures and string, may impose other alignment
782 * Returns 0 on success, a negative value on error.
784 extern int bt_ctf_field_type_set_alignment(struct bt_ctf_field_type
*type
,
785 unsigned int alignment
);
788 * bt_ctf_field_type_get_byte_order: get a field type's byte order.
790 * @param type Field type.
792 * Returns the field type's byte order on success, a negative value on error.
794 extern enum bt_ctf_byte_order
bt_ctf_field_type_get_byte_order(
795 struct bt_ctf_field_type
*type
);
798 * bt_ctf_field_type_set_byte_order: set a field type's byte order.
800 * Set the field type's byte order.
802 * @param type Field type.
803 * @param byte_order Field type's byte order. Defaults to
804 * BT_CTF_BYTE_ORDER_NATIVE; the trace's endianness.
806 * Returns 0 on success, a negative value on error.
808 extern int bt_ctf_field_type_set_byte_order(struct bt_ctf_field_type
*type
,
809 enum bt_ctf_byte_order byte_order
);
812 * bt_ctf_field_type_variant_get_tag_field_path: get a variant's tag's field
815 * Get the variant's tag's field path.
817 * @param type Field type.
819 * Returns the field path on success, NULL on error or if no field path is set.
821 extern struct bt_ctf_field_path
*bt_ctf_field_type_variant_get_tag_field_path(
822 struct bt_ctf_field_type
*type
);
825 * bt_ctf_field_type_sequence_get_length_field_path: get a sequence's length's
828 * Get the sequence's length's field path.
830 * @param type Field type.
832 * Returns the field path on success, NULL on error or if no field path is set.
834 extern struct bt_ctf_field_path
*bt_ctf_field_type_sequence_get_length_field_path(
835 struct bt_ctf_field_type
*type
);
838 * bt_ctf_field_type_compare: compare two field types recursively
840 * Compare two field types recursively.
842 * The registered tag field type of a variant field type is ignored:
843 * only the tag strings are compared.
845 * @param type_a Field type A.
846 * @param type_b Field type B.
848 * Returns 0 if both field types are semantically equivalent, a positive
849 * value if they are not equivalent, or a negative value on error.
851 extern int bt_ctf_field_type_compare(struct bt_ctf_field_type
*type_a
,
852 struct bt_ctf_field_type
*type_b
);
855 * bt_ctf_field_type_get_type_id: get a field type's bt_ctf_type_id.
857 * @param type Field type.
859 * Returns the field type's bt_ctf_type_id, CTF_TYPE_UNKNOWN on error.
861 extern enum bt_ctf_type_id
bt_ctf_field_type_get_type_id(
862 struct bt_ctf_field_type
*type
);
865 * bt_ctf_field_type_is_integer: returns whether or not a given field
866 * type is an integer type.
868 * @param type Field type.
870 * Returns 1 if the field type is an integer type, 0 otherwise.
872 extern int bt_ctf_field_type_is_integer(struct bt_ctf_field_type
*type
);
875 * bt_ctf_field_type_is_floating_point: returns whether or not a given field
876 * type is a floating point number type.
878 * @param type Field type.
880 * Returns 1 if the field type is a floating point number type, 0 otherwise.
882 extern int bt_ctf_field_type_is_floating_point(struct bt_ctf_field_type
*type
);
885 * bt_ctf_field_type_is_enumeration: returns whether or not a given field
886 * type is an enumeration type.
888 * @param type Field type.
890 * Returns 1 if the field type is an enumeration type, 0 otherwise.
892 extern int bt_ctf_field_type_is_enumeration(struct bt_ctf_field_type
*type
);
895 * bt_ctf_field_type_is_string: returns whether or not a given field
896 * type is a string type.
898 * @param type Field type.
900 * Returns 1 if the field type is a string type, 0 otherwise.
902 extern int bt_ctf_field_type_is_string(struct bt_ctf_field_type
*type
);
905 * bt_ctf_field_type_is_structure: returns whether or not a given field
906 * type is a structure type.
908 * @param type Field type.
910 * Returns 1 if the field type is a structure type, 0 otherwise.
912 extern int bt_ctf_field_type_is_structure(struct bt_ctf_field_type
*type
);
915 * bt_ctf_field_type_is_array: returns whether or not a given field
916 * type is an array type.
918 * @param type Field type.
920 * Returns 1 if the field type is an array type, 0 otherwise.
922 extern int bt_ctf_field_type_is_array(struct bt_ctf_field_type
*type
);
925 * bt_ctf_field_type_is_sequence: returns whether or not a given field
926 * type is a sequence type.
928 * @param type Field type.
930 * Returns 1 if the field type is a sequence type, 0 otherwise.
932 extern int bt_ctf_field_type_is_sequence(struct bt_ctf_field_type
*type
);
935 * bt_ctf_field_type_is_variant: returns whether or not a given field
936 * type is a variant type.
938 * @param type Field type.
940 * Returns 1 if the field type is a variant type, 0 otherwise.
942 extern int bt_ctf_field_type_is_variant(struct bt_ctf_field_type
*type
);
945 * bt_ctf_field_type_get and bt_ctf_field_type_put: increment and decrement
946 * the field type's reference count.
948 * You may also use bt_ctf_get() and bt_ctf_put() with field type objects.
950 * These functions ensure that the field type won't be destroyed while it
951 * is in use. The same number of get and put (plus one extra put to
952 * release the initial reference done at creation) have to be done to
953 * destroy a field type.
955 * When the field type's reference count is decremented to 0 by a
956 * bt_ctf_field_type_put, the field type is freed.
958 * @param type Field type.
960 extern void bt_ctf_field_type_get(struct bt_ctf_field_type
*type
);
961 extern void bt_ctf_field_type_put(struct bt_ctf_field_type
*type
);
967 #endif /* BABELTRACE_CTF_IR_FIELD_TYPES_H */