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
33 #include <babeltrace/types.h>
42 @defgroup ctfirfieldtypes CTF IR field types
44 @brief CTF IR field types.
47 #include <babeltrace/ctf-ir/field-types.h>
50 A CTF IR <strong><em>field type</em></strong> is a field type that you
51 can use to create concrete @fields.
53 You can create a @field object from a CTF IR field type object
54 with bt_ctf_field_create().
56 In the CTF IR hierarchy, you can set the root field types of three
59 - \ref ctfirtraceclass
60 - Trace packet header field type: bt_ctf_trace_set_packet_header_type().
61 - \ref ctfirstreamclass
62 - Stream packet context field type:
63 bt_ctf_stream_class_set_packet_context_type().
64 - Stream event header field type:
65 bt_ctf_stream_class_set_event_header_type().
66 - Stream event context field type:
67 bt_ctf_stream_class_set_event_context_type().
68 - \ref ctfireventclass
69 - Event context field type: bt_ctf_event_class_set_context_type().
70 - Event payload field type: bt_ctf_event_class_set_payload_type().
72 As of Babeltrace \btversion, those six previous "root" field types
73 \em must be @structft objects.
75 If, at any level within a given root field type, you add a @seqft or a
76 @varft, you do not need to specify its associated length
77 or tag field type: the length or tag string is enough for the Babeltrace
78 system to resolve the needed field type depending on where this
79 dynamic field type is located within the whole hierarchy. It is
80 guaranteed that this automatic resolving is performed for all the field
81 types contained in a given
82 \link ctfirstreamclass CTF IR stream class\endlink (and in its
83 children \link ctfireventclass CTF IR event classes\endlink) once you
84 add it to a \link ctfirtraceclass CTF IR trace class\endlink with
85 bt_ctf_trace_add_stream_class(). Once a stream class is the child of
86 a trace class, this automatic resolving is performed for the field
87 types of an event class when you add it with
88 bt_ctf_stream_class_add_event_class(). If the system cannot find a path
89 to a field in the hierarchy for a dynamic field type, the adding
92 The standard CTF field types are:
98 <th>CTF IR field which you can create from this field type
101 <td>#BT_CTF_FIELD_TYPE_ID_INTEGER
102 <td>\ref ctfirintfieldtype
103 <td>\ref ctfirintfield
106 <td>#BT_CTF_FIELD_TYPE_ID_FLOAT
107 <td>\ref ctfirfloatfieldtype
108 <td>\ref ctfirfloatfield
111 <td>#BT_CTF_FIELD_TYPE_ID_ENUM
112 <td>\ref ctfirenumfieldtype
113 <td>\ref ctfirenumfield
116 <td>#BT_CTF_FIELD_TYPE_ID_STRING
117 <td>\ref ctfirstringfieldtype
118 <td>\ref ctfirstringfield
121 <td>#BT_CTF_FIELD_TYPE_ID_STRUCT
122 <td>\ref ctfirstructfieldtype
123 <td>\ref ctfirstructfield
126 <td>#BT_CTF_FIELD_TYPE_ID_ARRAY
127 <td>\ref ctfirarrayfieldtype
128 <td>\ref ctfirarrayfield
131 <td>#BT_CTF_FIELD_TYPE_ID_SEQUENCE
132 <td>\ref ctfirseqfieldtype
133 <td>\ref ctfirseqfield
136 <td>#BT_CTF_FIELD_TYPE_ID_VARIANT
137 <td>\ref ctfirvarfieldtype
138 <td>\ref ctfirvarfield
142 Each field type has its own <strong>type ID</strong> (see
143 #bt_ctf_field_type_id). You get the type ID of a field type object
144 with bt_ctf_field_type_get_type_id().
146 You can get a deep copy of a field type with bt_ctf_field_type_copy().
147 This function resets, in the field type copy, the resolved field type
148 of the dynamic field types. The automatic resolving can be done again
149 when you eventually call bt_ctf_event_create(),
150 bt_ctf_stream_class_add_event_class(), or
151 bt_ctf_trace_add_stream_class().
153 You \em must always use bt_ctf_field_type_compare() to compare two
154 field types. Since some parts of the Babeltrace system can copy field
155 types behind the scenes, you \em cannot rely on a simple field type
158 As with any Babeltrace object, CTF IR field type objects have
159 <a href="https://en.wikipedia.org/wiki/Reference_counting">reference
160 counts</a>. See \ref refs to learn more about the reference counting
161 management of Babeltrace objects.
163 The following functions can \em freeze field type objects:
165 - bt_ctf_field_create() freezes its field type parameter.
166 - bt_ctf_stream_class_add_event_class(), if its
167 \link ctfirstreamclass CTF IR stream class\endlink parameter has a
168 \link ctfirtraceclass CTF IR trace class\endlink parent, freezes
169 the root field types of its
170 \link ctfireventclass CTF IR event class\endlink parameter.
171 - bt_ctf_trace_add_stream_class() freezes the root field types of the
172 whole trace class hierarchy (trace class, children stream classes,
173 and their children event classes).
174 - bt_ctf_writer_create_stream() freezes the root field types of the
175 whole CTF writer's trace class hierarchy.
176 - bt_ctf_event_create() freezes the root field types of its event class
177 parameter and of ther parent stream class of this event class.
179 You cannot modify a frozen field type object: it is considered
180 immutable, except for \link refs reference counting\endlink.
183 @sa \ref ctfirfieldtypesexamples "Examples"
186 @brief CTF IR field types type and functions.
189 @addtogroup ctfirfieldtypes
194 @struct bt_ctf_field_type
195 @brief A CTF IR field type.
198 struct bt_ctf_field_type
;
199 struct bt_ctf_event_class
;
202 struct bt_ctf_field_path
;
203 struct bt_ctf_field_type_enumeration_mapping_iterator
;
205 /** @cond DOCUMENT */
208 * Babeltrace 1.x enumerations that were also used in CTF writer's API.
209 * They are left here for backward compatibility reasons, but
210 * enum bt_ctf_field_type_id and enum bt_ctf_string_encoding should be used
211 * in new code. Both new enumerations are compatible with their legacy
215 CTF_TYPE_UNKNOWN
= -1,
216 CTF_TYPE_INTEGER
= 0,
221 CTF_TYPE_UNTAGGED_VARIANT
= 5,
222 CTF_TYPE_VARIANT
= 5,
224 CTF_TYPE_SEQUENCE
= 7,
231 enum ctf_string_encoding
{
244 /// Unknown, used for errors.
245 BT_CTF_SCOPE_UNKNOWN
= -1,
247 /// Trace packet header.
248 BT_CTF_SCOPE_TRACE_PACKET_HEADER
= 1,
250 /// Stream packet context.
251 BT_CTF_SCOPE_STREAM_PACKET_CONTEXT
= 2,
253 /// Stream event header.
254 BT_CTF_SCOPE_STREAM_EVENT_HEADER
= 3,
256 /// Stream event context.
257 BT_CTF_SCOPE_STREAM_EVENT_CONTEXT
= 4,
260 BT_CTF_SCOPE_EVENT_CONTEXT
= 5,
263 BT_CTF_SCOPE_EVENT_PAYLOAD
= 6,
266 BT_CTF_SCOPE_ENV
= 0,
267 BT_CTF_SCOPE_EVENT_FIELDS
= 6,
272 @name Type information
277 @brief Type ID of a @ft.
279 enum bt_ctf_field_type_id
{
280 /// Unknown, used for errors.
281 BT_CTF_FIELD_TYPE_ID_UNKNOWN
= CTF_TYPE_UNKNOWN
,
283 /// \ref ctfirintfieldtype
284 BT_CTF_FIELD_TYPE_ID_INTEGER
= CTF_TYPE_INTEGER
,
286 /// \ref ctfirfloatfieldtype
287 BT_CTF_FIELD_TYPE_ID_FLOAT
= CTF_TYPE_FLOAT
,
289 /// \ref ctfirenumfieldtype
290 BT_CTF_FIELD_TYPE_ID_ENUM
= CTF_TYPE_ENUM
,
292 /// \ref ctfirstringfieldtype
293 BT_CTF_FIELD_TYPE_ID_STRING
= CTF_TYPE_STRING
,
295 /// \ref ctfirstructfieldtype
296 BT_CTF_FIELD_TYPE_ID_STRUCT
= CTF_TYPE_STRUCT
,
298 /// \ref ctfirarrayfieldtype
299 BT_CTF_FIELD_TYPE_ID_ARRAY
= CTF_TYPE_ARRAY
,
301 /// \ref ctfirseqfieldtype
302 BT_CTF_FIELD_TYPE_ID_SEQUENCE
= CTF_TYPE_SEQUENCE
,
304 /// \ref ctfirvarfieldtype
305 BT_CTF_FIELD_TYPE_ID_VARIANT
= CTF_TYPE_VARIANT
,
307 /// Number of enumeration entries.
308 BT_CTF_NR_TYPE_IDS
= NR_CTF_TYPES
,
312 @brief Returns the type ID of the @ft \p field_type.
314 @param[in] field_type Field type of which to get the type ID.
315 @returns Type ID of \p field_type,
316 or #BT_CTF_FIELD_TYPE_ID_UNKNOWN on error.
318 @prenotnull{field_type}
319 @postrefcountsame{field_type}
321 @sa #bt_ctf_field_type_id: CTF IR field type ID.
322 @sa bt_ctf_field_type_is_integer(): Returns whether or not a given
323 field type is a @intft.
324 @sa bt_ctf_field_type_is_floating_point(): Returns whether or not a
325 given field type is a @floatft.
326 @sa bt_ctf_field_type_is_enumeration(): Returns whether or not a given
327 field type is a @enumft.
328 @sa bt_ctf_field_type_is_string(): Returns whether or not a given
329 field type is a @stringft.
330 @sa bt_ctf_field_type_is_structure(): Returns whether or not a given
331 field type is a @structft.
332 @sa bt_ctf_field_type_is_array(): Returns whether or not a given
333 field type is a @arrayft.
334 @sa bt_ctf_field_type_is_sequence(): Returns whether or not a given
335 field type is a @seqft.
336 @sa bt_ctf_field_type_is_variant(): Returns whether or not a given
337 field type is a @varft.
339 extern enum bt_ctf_field_type_id
bt_ctf_field_type_get_type_id(
340 struct bt_ctf_field_type
*field_type
);
343 @brief Returns whether or not the @ft \p field_type is a @intft.
345 @param[in] field_type Field type to check (can be \c NULL).
346 @returns #BT_TRUE if \p field_type is an integer field type,
347 or #BT_FALSE otherwise (including if \p field_type is
350 @prenotnull{field_type}
351 @postrefcountsame{field_type}
353 @sa bt_ctf_field_type_get_type_id(): Returns the type ID of a given
356 extern bt_bool
bt_ctf_field_type_is_integer(
357 struct bt_ctf_field_type
*field_type
);
360 @brief Returns whether or not the @ft \p field_type is a @floatft.
362 @param[in] field_type Field type to check (can be \c NULL).
363 @returns #BT_TRUE if \p field_type is a floating point
364 #BT_FALSE field type,
365 or 0 otherwise (including if \p field_type is
368 @postrefcountsame{field_type}
370 @sa bt_ctf_field_type_get_type_id(): Returns the type ID of a given
373 extern bt_bool
bt_ctf_field_type_is_floating_point(
374 struct bt_ctf_field_type
*field_type
);
377 @brief Returns whether or not the @ft \p field_type is a @enumft.
379 @param[in] field_type Field type to check (can be \c NULL).
380 @returns #BT_TRUE if \p field_type is an enumeration field type,
381 or #BT_FALSE otherwise (including if \p field_type is
384 @postrefcountsame{field_type}
386 @sa bt_ctf_field_type_get_type_id(): Returns the type ID of a given
389 extern bt_bool
bt_ctf_field_type_is_enumeration(
390 struct bt_ctf_field_type
*field_type
);
393 @brief Returns whether or not the @ft \p field_type is a @stringft.
395 @param[in] field_type Field type to check (can be \c NULL).
396 @returns #BT_TRUE if \p field_type is a string field type,
397 or #BT_FALSE otherwise (including if \p field_type is
400 @postrefcountsame{field_type}
402 @sa bt_ctf_field_type_get_type_id(): Returns the type ID of a given
405 extern bt_bool
bt_ctf_field_type_is_string(
406 struct bt_ctf_field_type
*field_type
);
409 @brief Returns whether or not the @ft \p field_type is a @structft.
411 @param[in] field_type Field type to check (can be \c NULL).
412 @returns #BT_TRUE if \p field_type is a structure field type,
413 or #BT_FALSE otherwise (including if \p field_type is
416 @postrefcountsame{field_type}
418 @sa bt_ctf_field_type_get_type_id(): Returns the type ID of a given
421 extern bt_bool
bt_ctf_field_type_is_structure(
422 struct bt_ctf_field_type
*field_type
);
425 @brief Returns whether or not the @ft \p field_type is a @arrayft.
427 @param[in] field_type Field type to check (can be \c NULL).
428 @returns #BT_TRUE if \p field_type is an array field type,
429 or #BT_FALSE otherwise (including if \p field_type is
432 @postrefcountsame{field_type}
434 @sa bt_ctf_field_type_get_type_id(): Returns the type ID of a given
437 extern bt_bool
bt_ctf_field_type_is_array(
438 struct bt_ctf_field_type
*field_type
);
441 @brief Returns whether or not the @ft \p field_type is a @seqft.
443 @param[in] field_type Field type to check (can be \c NULL).
444 @returns #BT_TRUE if \p field_type is a sequence field type,
445 or #BT_FALSE otherwise (including if \p field_type is
448 @postrefcountsame{field_type}
450 @sa bt_ctf_field_type_get_type_id(): Returns the type ID of a given
453 extern bt_bool
bt_ctf_field_type_is_sequence(
454 struct bt_ctf_field_type
*field_type
);
457 @brief Returns whether or not the @ft \p field_type is a @varft.
459 @param[in] field_type Field type to check (can be \c NULL).
460 @returns #BT_TRUE if \p field_type is a variant field type,
461 or #BT_FALSE otherwise (including if \p field_type is
464 @postrefcountsame{field_type}
466 @sa bt_ctf_field_type_get_type_id(): Returns the type ID of a given
469 extern bt_bool
bt_ctf_field_type_is_variant(
470 struct bt_ctf_field_type
*field_type
);
475 @name Common properties types and functions
480 @brief <a href="https://en.wikipedia.org/wiki/Endianness">Byte order</a>
483 enum bt_ctf_byte_order
{
484 /// Unknown, used for errors.
485 BT_CTF_BYTE_ORDER_UNKNOWN
= -1,
488 * Note that native, in the context of the CTF specification, is defined
489 * as "the byte order described in the trace" and does not mean that the
490 * host's endianness will be used.
492 /// Native (default) byte order.
493 BT_CTF_BYTE_ORDER_NATIVE
= 0,
496 BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
,
499 BT_CTF_BYTE_ORDER_BIG_ENDIAN
,
501 /// Network byte order (big-endian).
502 BT_CTF_BYTE_ORDER_NETWORK
,
506 @brief String encoding of a @ft.
508 enum bt_ctf_string_encoding
{
509 /// Unknown, used for errors.
510 BT_CTF_STRING_ENCODING_UNKNOWN
= CTF_STRING_UNKNOWN
,
513 BT_CTF_STRING_ENCODING_NONE
= CTF_STRING_NONE
,
515 /// <a href="https://en.wikipedia.org/wiki/UTF-8">UTF-8</a>.
516 BT_CTF_STRING_ENCODING_UTF8
= CTF_STRING_UTF8
,
518 /// <a href="https://en.wikipedia.org/wiki/ASCII">ASCII</a>.
519 BT_CTF_STRING_ENCODING_ASCII
= CTF_STRING_ASCII
,
523 @brief Returns the alignment of the @fields described by
524 the @ft \p field_type.
526 @param[in] field_type Field type which describes the
527 fields of which to get the alignment.
528 @returns Alignment of the fields described by
529 \p field_type, or a negative value on error.
531 @prenotnull{field_type}
532 @postrefcountsame{field_type}
534 @sa bt_ctf_field_type_set_alignment(): Sets the alignment
535 of the fields described by a given field type.
537 extern int bt_ctf_field_type_get_alignment(
538 struct bt_ctf_field_type
*field_type
);
541 @brief Sets the alignment of the @fields described by the
542 @ft \p field_type to \p alignment.
544 \p alignment \em must be greater than 0 and a power of two.
546 @param[in] field_type Field type which describes the fields of
547 which to set the alignment.
548 @param[in] alignment Alignment of the fields described by
550 @returns 0 on success, or a negative value on error.
552 @prenotnull{field_type}
554 @pre \p alignment is greater than 0 and a power of two.
555 @postrefcountsame{field_type}
557 @sa bt_ctf_field_type_get_alignment(): Returns the alignment of the
558 fields described by a given field type.
560 extern int bt_ctf_field_type_set_alignment(struct bt_ctf_field_type
*field_type
,
561 unsigned int alignment
);
564 @brief Returns the byte order of the @fields described by
565 the @ft \p field_type.
567 You can only call this function if \p field_type is a @intft, a
568 @floatft, or a @enumft.
570 @param[in] field_type Field type which describes the
571 fields of which to get the byte order.
572 @returns Byte order of the fields described by
573 \p field_type, or #BT_CTF_BYTE_ORDER_UNKNOWN on
576 @prenotnull{field_type}
577 @pre \p field_type is a @intft, a @floatft, or a @enumft.
578 @postrefcountsame{field_type}
580 @sa bt_ctf_field_type_set_byte_order(): Sets the byte order
581 of the fields described by a given field type.
583 extern enum bt_ctf_byte_order
bt_ctf_field_type_get_byte_order(
584 struct bt_ctf_field_type
*field_type
);
587 @brief Sets the byte order of the @fields described by the
588 @ft \p field_type to \p byte_order.
590 If \p field_type is a compound field type, this function also
591 recursively sets the byte order of its children to \p byte_order.
593 @param[in] field_type Field type which describes the fields of
594 which to set the byte order.
595 @param[in] byte_order Alignment of the fields described by
597 @returns 0 on success, or a negative value on error.
599 @prenotnull{field_type}
601 @pre \p byte_order is #BT_CTF_BYTE_ORDER_NATIVE,
602 #BT_CTF_BYTE_ORDER_LITTLE_ENDIAN, #BT_CTF_BYTE_ORDER_BIG_ENDIAN,
603 or #BT_CTF_BYTE_ORDER_NETWORK.
604 @postrefcountsame{field_type}
606 @sa bt_ctf_field_type_get_byte_order(): Returns the byte order of the
607 fields described by a given field type.
609 extern int bt_ctf_field_type_set_byte_order(
610 struct bt_ctf_field_type
*field_type
,
611 enum bt_ctf_byte_order byte_order
);
616 @name Utility functions
621 @brief Returns whether or not the @ft \p field_type_a
622 is equivalent to the field type \p field_type_b.
624 You \em must use this function to compare two field types: it is not
625 safe to compare two pointer values directly, because, for internal
626 reasons, some parts of the Babeltrace system can copy user field types
627 and discard the original ones.
629 @param[in] field_type_a Field type to compare to \p field_type_b.
630 @param[in] field_type_b Field type to compare to \p field_type_a.
631 @returns 0 if \p field_type_a is equivalent to
632 \p field_type_b, 1 if they are not equivalent,
633 or a negative value on error.
635 @prenotnull{field_type_a}
636 @prenotnull{field_type_b}
637 @postrefcountsame{field_type_a}
638 @postrefcountsame{field_type_b}
640 extern int bt_ctf_field_type_compare(struct bt_ctf_field_type
*field_type_a
,
641 struct bt_ctf_field_type
*field_type_b
);
644 @brief Creates a \em deep copy of the @ft \p field_type.
646 You can copy a frozen field type: the resulting copy is
649 This function resets the tag field type of a copied @varft. The
650 automatic field resolving which some functions of the API perform
651 can set it again when the returned field type is used (learn more
652 in the detailed description of this module).
654 @param[in] field_type Field type to copy.
655 @returns Deep copy of \p field_type on success,
658 @prenotnull{field_type}
659 @postrefcountsame{field_type}
660 @postsuccessrefcountret1
661 @post <strong>On success</strong>, the returned field type is not frozen.
663 extern struct bt_ctf_field_type
*bt_ctf_field_type_copy(
664 struct bt_ctf_field_type
*field_type
);
671 @defgroup ctfirintfieldtype CTF IR integer field type
672 @ingroup ctfirfieldtypes
673 @brief CTF IR integer field type.
676 #include <babeltrace/ctf-ir/field-types.h>
679 A CTF IR <strong><em>integer field type</em></strong> is a field type that
680 you can use to create concrete @intfield objects.
682 You can create an integer field type
683 with bt_ctf_field_type_integer_create().
685 An integer field type has the following properties:
690 <th>Value at creation
695 <td>\b Alignment (bits) of the described integer fields
697 <td>bt_ctf_field_type_get_alignment()
698 <td>bt_ctf_field_type_set_alignment()
701 <td><strong>Byte order</strong> of the described integer fields
702 <td>#BT_CTF_BYTE_ORDER_NATIVE
703 <td>bt_ctf_field_type_get_byte_order()
704 <td>bt_ctf_field_type_set_byte_order()
707 <td><strong>Storage size</strong> (bits) of the described
709 <td>Specified at creation
710 <td>bt_ctf_field_type_integer_get_size()
711 <td>bt_ctf_field_type_integer_set_size()
714 <td><strong>Signedness</strong> of the described integer fields
716 <td>bt_ctf_field_type_integer_is_signed()
717 <td>bt_ctf_field_type_integer_set_is_signed()
720 <td><strong>Preferred display base</strong> of the described
722 <td>#BT_CTF_INTEGER_BASE_DECIMAL
723 <td>bt_ctf_field_type_integer_get_base()
724 <td>bt_ctf_field_type_integer_set_base()
727 <td>\b Encoding of the described integer fields
728 <td>#BT_CTF_STRING_ENCODING_NONE
729 <td>bt_ctf_field_type_integer_get_encoding()
730 <td>bt_ctf_field_type_integer_set_encoding()
734 \link ctfirclockclass CTF IR clock class\endlink</strong>
736 <td>bt_ctf_field_type_integer_get_mapped_clock_class()
737 <td>bt_ctf_field_type_integer_set_mapped_clock_class()
743 @sa \ref ctfirfieldtypesexamples_intfieldtype "Examples"
745 @addtogroup ctfirintfieldtype
750 @brief Preferred display base (radix) of a @intft.
752 enum bt_ctf_integer_base
{
753 /// Unknown, used for errors.
754 BT_CTF_INTEGER_BASE_UNKNOWN
= -1,
757 BT_CTF_INTEGER_BASE_BINARY
= 2,
760 BT_CTF_INTEGER_BASE_OCTAL
= 8,
763 BT_CTF_INTEGER_BASE_DECIMAL
= 10,
766 BT_CTF_INTEGER_BASE_HEXADECIMAL
= 16,
770 @brief Creates a default @intft with \p size bits as the storage size
771 of the @intfields it describes.
773 You can change the storage size of the integer fields described by
774 the created integer field type later with
775 bt_ctf_field_type_integer_set_size().
777 @param[in] size Storage size (bits) of the described integer fields.
778 @returns Created integer field type, or \c NULL on error.
780 @pre \p size is greater than 0 and lesser than or equal to 64.
781 @postsuccessrefcountret1
783 extern struct bt_ctf_field_type
*bt_ctf_field_type_integer_create(
787 @brief Returns the storage size, in bits, of the @intfields
788 described by the @intft \p int_field_type.
790 @param[in] int_field_type Integer field type which describes the
791 integer fields of which to get the
793 @returns Storage size (bits) of the integer
794 fields described by \p int_field_type,
795 or a negative value on error.
797 @prenotnull{int_field_type}
798 @preisintft{int_field_type}
799 @postrefcountsame{int_field_type}
801 @sa bt_ctf_field_type_integer_set_size(): Sets the storage size of the
802 integer fields described by a given integer field type.
804 extern int bt_ctf_field_type_integer_get_size(
805 struct bt_ctf_field_type
*int_field_type
);
808 @brief Sets the storage size, in bits, of the @intfields described by
809 the @intft \p int_field_type.
811 @param[in] int_field_type Integer field type which describes the
812 integer fields of which to set the
814 @param[in] size Storage size (bits) of the integer fields
815 described by \p int_field_type.
816 @returns 0 on success, or a negative value on error.
818 @prenotnull{int_field_type}
819 @preisintft{int_field_type}
820 @prehot{int_field_type}
821 @pre \p size is greater than 0 and lesser than or equal to 64.
822 @postrefcountsame{int_field_type}
824 @sa bt_ctf_field_type_integer_get_size(): Returns the storage size of
825 the integer fields described by a given integer field type.
827 extern int bt_ctf_field_type_integer_set_size(
828 struct bt_ctf_field_type
*int_field_type
, size_t size
);
831 @brief Returns whether or not the @intfields described by the @intft
832 \p int_field_type are signed.
834 @param[in] int_field_type Integer field type which describes the
835 integer fields of which to get the
837 @returns #BT_TRUE if the integer fields described by
838 \p int_field_type are signed, #BT_FALSE if they
841 @prenotnull{int_field_type}
842 @preisintft{int_field_type}
843 @postrefcountsame{int_field_type}
845 @sa bt_ctf_field_type_integer_set_is_signed(): Sets the signedness of the
846 integer fields described by a given integer field type.
848 extern bt_bool
bt_ctf_field_type_integer_is_signed(
849 struct bt_ctf_field_type
*int_field_type
);
851 /** @cond DOCUMENT */
853 extern int bt_ctf_field_type_integer_get_signed(
854 struct bt_ctf_field_type
*int_field_type
);
859 @brief Sets whether or not the @intfields described by
860 the @intft \p int_field_type are signed.
862 @param[in] int_field_type Integer field type which describes the
863 integer fields of which to set the
865 @param[in] is_signed Signedness of the integer fields
866 described by \p int_field_type; #BT_FALSE means
867 \em unsigned, #BT_TRUE means \em signed.
868 @returns 0 on success, or a negative value on error.
870 @prenotnull{int_field_type}
871 @preisintft{int_field_type}
872 @prehot{int_field_type}
873 @postrefcountsame{int_field_type}
875 @sa bt_ctf_field_type_integer_is_signed(): Returns the signedness of
876 the integer fields described by a given integer field type.
878 extern int bt_ctf_field_type_integer_set_is_signed(
879 struct bt_ctf_field_type
*int_field_type
, bt_bool is_signed
);
881 /* Pre-2.0 CTF writer compatibility */
882 #define bt_ctf_field_type_integer_set_signed bt_ctf_field_type_integer_set_is_signed
885 @brief Returns the preferred display base (radix) of the @intfields
886 described by the @intft \p int_field_type.
888 @param[in] int_field_type Integer field type which describes the
889 integer fields of which to get the
890 preferred display base.
891 @returns Preferred display base of the integer
892 fields described by \p int_field_type,
893 or #BT_CTF_INTEGER_BASE_UNKNOWN on
896 @prenotnull{int_field_type}
897 @preisintft{int_field_type}
898 @postrefcountsame{int_field_type}
900 @sa bt_ctf_field_type_integer_set_base(): Sets the preferred display
901 base of the integer fields described by a given integer field
904 extern enum bt_ctf_integer_base
bt_ctf_field_type_integer_get_base(
905 struct bt_ctf_field_type
*int_field_type
);
908 @brief Sets the preferred display base (radix) of the @intfields
909 described by the @intft \p int_field_type to \p base.
911 @param[in] int_field_type Integer field type which describes the
912 integer fields of which to set the
913 preferred display base.
914 @param[in] base Preferred display base of the integer
915 fields described by \p int_field_type.
916 @returns 0 on success, or a negative value on error.
918 @prenotnull{int_field_type}
919 @preisintft{int_field_type}
920 @prehot{int_field_type}
921 @pre \p base is #BT_CTF_INTEGER_BASE_BINARY, #BT_CTF_INTEGER_BASE_OCTAL,
922 #BT_CTF_INTEGER_BASE_DECIMAL, or
923 #BT_CTF_INTEGER_BASE_HEXADECIMAL.
924 @postrefcountsame{int_field_type}
926 @sa bt_ctf_field_type_integer_get_base(): Returns the preferred display
927 base of the integer fields described by a given
930 extern int bt_ctf_field_type_integer_set_base(
931 struct bt_ctf_field_type
*int_field_type
,
932 enum bt_ctf_integer_base base
);
935 @brief Returns the encoding of the @intfields described by
936 the @intft \p int_field_type.
938 @param[in] int_field_type Integer field type which describes the
939 integer fields of which to get the
941 @returns Encoding of the integer
942 fields described by \p int_field_type,
943 or #BT_CTF_STRING_ENCODING_UNKNOWN on
946 @prenotnull{int_field_type}
947 @preisintft{int_field_type}
948 @postrefcountsame{int_field_type}
950 @sa bt_ctf_field_type_integer_set_encoding(): Sets the encoding
951 of the integer fields described by a given integer field type.
953 extern enum bt_ctf_string_encoding
bt_ctf_field_type_integer_get_encoding(
954 struct bt_ctf_field_type
*int_field_type
);
957 @brief Sets the encoding of the @intfields described by the @intft
958 \p int_field_type to \p encoding.
960 You can use this property, in CTF IR, to create "text" @arrayfts or
961 @seqfts. A text array field type is array field type with an unsigned,
962 8-bit integer field type having an encoding as its element field type.
964 @param[in] int_field_type Integer field type which describes the
965 integer fields of which to set the
967 @param[in] encoding Encoding of the integer
968 fields described by \p int_field_type.
969 @returns 0 on success, or a negative value on error.
971 @prenotnull{int_field_type}
972 @preisintft{int_field_type}
973 @prehot{int_field_type}
974 @pre \p encoding is #BT_CTF_STRING_ENCODING_NONE,
975 #BT_CTF_STRING_ENCODING_ASCII, or
976 #BT_CTF_STRING_ENCODING_UTF8.
977 @postrefcountsame{int_field_type}
979 @sa bt_ctf_field_type_integer_get_encoding(): Returns the encoding of
980 the integer fields described by a given integer field type.
982 extern int bt_ctf_field_type_integer_set_encoding(
983 struct bt_ctf_field_type
*int_field_type
,
984 enum bt_ctf_string_encoding encoding
);
987 @brief Returns the \link ctfirclockclass CTF IR clock class\endlink
988 mapped to the @intft \p int_field_type.
990 The mapped clock class, if any, indicates the class of the clock which
991 an @intfield described by \p int_field_type should sample or update.
992 This mapped clock class is only indicative.
994 @param[in] int_field_type Integer field type of which to get the
996 @returns Mapped clock class of \p int_field_type,
997 or \c NULL if there's no mapped clock
1000 @prenotnull{int_field_type}
1001 @preisintft{int_field_type}
1002 @postrefcountsame{int_field_type}
1003 @postsuccessrefcountretinc
1005 @sa bt_ctf_field_type_integer_set_mapped_clock_class(): Sets the mapped
1006 clock class of a given integer field type.
1008 extern struct bt_ctf_clock_class
*bt_ctf_field_type_integer_get_mapped_clock_class(
1009 struct bt_ctf_field_type
*int_field_type
);
1012 @brief Sets the \link ctfirclockclass CTF IR clock class\endlink mapped
1013 to the @intft \p int_field_type to \p clock_class.
1015 The mapped clock class, if any, indicates the class of the clock which
1016 an integer field described by \p int_field_type should sample or update.
1017 This mapped clock class is only indicative.
1019 @param[in] int_field_type Integer field type of which to set the
1021 @param[in] clock_class Mapped clock class of \p int_field_type.
1022 @returns 0 on success, or a negative value on error.
1024 @prenotnull{int_field_type}
1025 @prenotnull{clock_class}
1026 @preisintft{int_field_type}
1027 @prehot{int_field_type}
1028 @postrefcountsame{int_field_type}
1029 @postsuccessrefcountinc{clock_class}
1031 @sa bt_ctf_field_type_integer_get_mapped_clock_class(): Returns the mapped
1032 clock class of a given integer field type.
1034 extern int bt_ctf_field_type_integer_set_mapped_clock_class(
1035 struct bt_ctf_field_type
*int_field_type
,
1036 struct bt_ctf_clock_class
*clock_class
);
1041 @defgroup ctfirfloatfieldtype CTF IR floating point number field type
1042 @ingroup ctfirfieldtypes
1043 @brief CTF IR floating point number field type.
1046 #include <babeltrace/ctf-ir/field-types.h>
1049 A CTF IR <strong><em>floating point number field type</em></strong> is
1050 a field type that you can use to create concrete @floatfields.
1052 You can create a floating point number field type
1053 with bt_ctf_field_type_floating_point_create().
1055 A floating point number field type has the following properties:
1060 <th>Value at creation
1065 <td>\b Alignment (bits) of the described floating point
1068 <td>bt_ctf_field_type_get_alignment()
1069 <td>bt_ctf_field_type_set_alignment()
1072 <td><strong>Byte order</strong> of the described floating point
1074 <td>#BT_CTF_BYTE_ORDER_NATIVE
1075 <td>bt_ctf_field_type_get_byte_order()
1076 <td>bt_ctf_field_type_set_byte_order()
1079 <td><strong>Exponent storage size</strong> (bits) of the described
1080 floating point number fields
1082 <td>bt_ctf_field_type_floating_point_get_exponent_digits()
1083 <td>bt_ctf_field_type_floating_point_set_exponent_digits()
1086 <td><strong>Mantissa and sign storage size</strong> (bits) of the
1087 described floating point number fields
1088 <td>24 (23-bit mantissa, 1-bit sign)
1089 <td>bt_ctf_field_type_floating_point_get_mantissa_digits()
1090 <td>bt_ctf_field_type_floating_point_set_mantissa_digits()
1096 @sa \ref ctfirfieldtypesexamples_floatfieldtype "Examples"
1098 @addtogroup ctfirfloatfieldtype
1103 @brief Creates a default @floatft.
1105 @returns Created floating point number field type,
1106 or \c NULL on error.
1108 @postsuccessrefcountret1
1110 extern struct bt_ctf_field_type
*bt_ctf_field_type_floating_point_create(void);
1113 @brief Returns the exponent storage size of the @floatfields
1114 described by the @floatft \p float_field_type.
1116 @param[in] float_field_type Floating point number field type which
1117 describes the floating point number
1118 fields of which to get the exponent
1120 @returns Exponent storage size of the
1121 floating point number fields
1122 described by \p float_field_type,
1123 or a negative value on error.
1125 @prenotnull{float_field_type}
1126 @preisfloatft{float_field_type}
1127 @postrefcountsame{float_field_type}
1129 @sa bt_ctf_field_type_floating_point_set_exponent_digits(): Sets the
1130 exponent storage size of the floating point number fields
1131 described by a given floating point number field type.
1133 extern int bt_ctf_field_type_floating_point_get_exponent_digits(
1134 struct bt_ctf_field_type
*float_field_type
);
1137 @brief Sets the exponent storage size of the @floatfields described by
1138 the @floatft \p float_field_type to \p exponent_size.
1140 As of Babeltrace \btversion, \p exponent_size can only be 8 or 11.
1142 @param[in] float_field_type Floating point number field type which
1143 describes the floating point number
1144 fields of which to set the exponent
1146 @param[in] exponent_size Exponent storage size of the floating
1147 point number fields described by \p
1149 @returns 0 on success, or a negative value on error.
1151 @prenotnull{float_field_type}
1152 @preisfloatft{float_field_type}
1153 @prehot{float_field_type}
1154 @pre \p exponent_size is 8 or 11.
1155 @postrefcountsame{float_field_type}
1157 @sa bt_ctf_field_type_floating_point_get_exponent_digits(): Returns the
1158 exponent storage size of the floating point number fields
1159 described by a given floating point number field type.
1161 extern int bt_ctf_field_type_floating_point_set_exponent_digits(
1162 struct bt_ctf_field_type
*float_field_type
,
1163 unsigned int exponent_size
);
1166 @brief Returns the mantissa and sign storage size of the @floatfields
1167 described by the @floatft \p float_field_type.
1169 On success, the returned value is the sum of the mantissa \em and
1172 @param[in] float_field_type Floating point number field type which
1173 describes the floating point number
1174 fields of which to get the mantissa and
1176 @returns Mantissa and sign storage size of the
1177 floating point number fields
1178 described by \p float_field_type,
1179 or a negative value on error.
1181 @prenotnull{float_field_type}
1182 @preisfloatft{float_field_type}
1183 @postrefcountsame{float_field_type}
1185 @sa bt_ctf_field_type_floating_point_set_mantissa_digits(): Sets the
1186 mantissa and size storage size of the floating point number
1187 fields described by a given floating point number field type.
1189 extern int bt_ctf_field_type_floating_point_get_mantissa_digits(
1190 struct bt_ctf_field_type
*float_field_type
);
1193 @brief Sets the mantissa and sign storage size of the @floatfields
1194 described by the @floatft \p float_field_type to \p
1197 As of Babeltrace \btversion, \p mantissa_sign_size can only be 24 or 53.
1199 @param[in] float_field_type Floating point number field type which
1200 describes the floating point number
1201 fields of which to set the mantissa and
1203 @param[in] mantissa_sign_size Mantissa and sign storage size of the
1204 floating point number fields described
1205 by \p float_field_type.
1206 @returns 0 on success, or a negative value on error.
1208 @prenotnull{float_field_type}
1209 @preisfloatft{float_field_type}
1210 @prehot{float_field_type}
1211 @pre \p mantissa_sign_size is 24 or 53.
1212 @postrefcountsame{float_field_type}
1214 @sa bt_ctf_field_type_floating_point_get_mantissa_digits(): Returns the
1215 mantissa and sign storage size of the floating point number
1216 fields described by a given floating point number field type.
1218 extern int bt_ctf_field_type_floating_point_set_mantissa_digits(
1219 struct bt_ctf_field_type
*float_field_type
,
1220 unsigned int mantissa_sign_size
);
1225 @defgroup ctfirenumfieldtype CTF IR enumeration field type
1226 @ingroup ctfirfieldtypes
1227 @brief CTF IR enumeration field type.
1230 #include <babeltrace/ctf-ir/field-types.h>
1233 A CTF IR <strong><em>enumeration field type</em></strong> is
1234 a field type that you can use to create concrete @enumfields.
1236 You can create an enumeration field type with
1237 bt_ctf_field_type_enumeration_create(). This function needs a @intft
1238 which represents the storage field type of the created enumeration field
1239 type. In other words, an enumeration field type wraps an integer field
1240 type and adds label-value mappings to it.
1242 An enumeration mapping has:
1244 - A <strong>name</strong>.
1245 - A <strong>range of values</strong> given by a beginning and an ending
1246 value, both included in the range.
1248 You can add a mapping to an enumeration field type with
1249 bt_ctf_field_type_enumeration_add_mapping() or
1250 bt_ctf_field_type_enumeration_add_mapping_unsigned(), depending on the
1251 signedness of the wrapped @intft.
1253 You can find mappings by name or by value with the following find
1256 - bt_ctf_field_type_enumeration_find_mappings_by_name(): Finds the
1257 mappings with a given name.
1258 - bt_ctf_field_type_enumeration_find_mappings_by_unsigned_value():
1259 Finds the mappings which contain a given unsigned value in their
1261 - bt_ctf_field_type_enumeration_find_mappings_by_signed_value():
1262 Finds the mappings which contain a given signed value in their range.
1264 Those functions return a @enumftiter on the result set of the find
1267 Many mappings can share the same name, and the ranges of a given
1268 enumeration field type are allowed to overlap. For example,
1269 this is a valid set of mappings:
1278 The following set of mappings is also valid:
1287 Here, the range of the second \c APPLE mapping overlaps the range of
1288 the \c CHERRY mapping.
1290 @sa ctfirenumftmappingiter
1294 @addtogroup ctfirenumfieldtype
1299 @brief Creates a default @enumft wrapping the @intft \p int_field_type.
1301 @param[in] int_field_type Integer field type wrapped by the
1302 created enumeration field type.
1303 @returns Created enumeration field type,
1304 or \c NULL on error.
1306 @prenotnull{int_field_type}
1307 @preisintft{int_field_type}
1308 @postsuccessrefcountinc{int_field_type}
1309 @postsuccessrefcountret1
1311 extern struct bt_ctf_field_type
*bt_ctf_field_type_enumeration_create(
1312 struct bt_ctf_field_type
*int_field_type
);
1315 @brief Returns the @intft wrapped by the @enumft \p enum_field_type.
1317 @param[in] enum_field_type Enumeration field type of which to get
1318 the wrapped integer field type.
1319 @returns Integer field type wrapped by
1320 \p enum_field_type, or \c NULL on
1323 @prenotnull{enum_field_type}
1324 @preisenumft{enum_field_type}
1325 @postrefcountsame{enum_field_type}
1326 @postsuccessrefcountretinc
1329 struct bt_ctf_field_type
*bt_ctf_field_type_enumeration_get_container_type(
1330 struct bt_ctf_field_type
*enum_field_type
);
1333 @brief Returns the number of mappings contained in the
1334 @enumft \p enum_field_type.
1336 @param[in] enum_field_type Enumeration field type of which to get
1337 the number of contained mappings.
1338 @returns Number of mappings contained in
1339 \p enum_field_type, or a negative
1342 @prenotnull{enum_field_type}
1343 @preisenumft{enum_field_type}
1344 @postrefcountsame{enum_field_type}
1346 extern int64_t bt_ctf_field_type_enumeration_get_mapping_count(
1347 struct bt_ctf_field_type
*enum_field_type
);
1350 @brief Returns the signed mapping of the @enumft
1351 \p enum_field_type at index \p index.
1353 The @intft wrapped by \p enum_field_type, as returned by
1354 bt_ctf_field_type_enumeration_get_container_type(), must be \b signed
1355 to use this function.
1357 On success, \p enum_field_type remains the sole owner of \p *name.
1359 @param[in] enum_field_type Enumeration field type of which to get
1360 the mapping at index \p index.
1361 @param[in] index Index of the mapping to get from
1363 @param[out] name Returned name of the mapping at index
1365 @param[out] range_begin Returned beginning of the range
1366 (included) of the mapping at index \p
1368 @param[out] range_end Returned end of the range (included) of
1369 the mapping at index \p index.
1370 @returns 0 on success, or a negative value on error.
1372 @prenotnull{enum_field_type}
1374 @prenotnull{range_begin}
1375 @prenotnull{range_end}
1376 @preisenumft{enum_field_type}
1377 @pre The wrapped @intft of \p enum_field_type is signed.
1378 @pre \p index is lesser than the number of mappings contained in the
1379 enumeration field type \p enum_field_type (see
1380 bt_ctf_field_type_enumeration_get_mapping_count()).
1381 @postrefcountsame{enum_field_type}
1383 @sa bt_ctf_field_type_enumeration_get_mapping_unsigned(): Returns the
1384 unsigned mapping contained by a given enumeration field type
1387 extern int bt_ctf_field_type_enumeration_get_mapping_signed(
1388 struct bt_ctf_field_type
*enum_field_type
, uint64_t index
,
1389 const char **name
, int64_t *range_begin
, int64_t *range_end
);
1392 @brief Returns the unsigned mapping of the @enumft
1393 \p enum_field_type at index \p index.
1395 The @intft wrapped by \p enum_field_type, as returned by
1396 bt_ctf_field_type_enumeration_get_container_type(), must be
1397 \b unsigned to use this function.
1399 On success, \p enum_field_type remains the sole owner of \p *name.
1401 @param[in] enum_field_type Enumeration field type of which to get
1402 the mapping at index \p index.
1403 @param[in] index Index of the mapping to get from
1405 @param[out] name Returned name of the mapping at index
1407 @param[out] range_begin Returned beginning of the range
1408 (included) of the mapping at index \p
1410 @param[out] range_end Returned end of the range (included) of
1411 the mapping at index \p index.
1412 @returns 0 on success, or a negative value on error.
1414 @prenotnull{enum_field_type}
1416 @prenotnull{range_begin}
1417 @prenotnull{range_end}
1418 @preisenumft{enum_field_type}
1419 @pre The wrapped @intft of \p enum_field_type is unsigned.
1420 @pre \p index is lesser than the number of mappings contained in the
1421 enumeration field type \p enum_field_type (see
1422 bt_ctf_field_type_enumeration_get_mapping_count()).
1423 @postrefcountsame{enum_field_type}
1425 @sa bt_ctf_field_type_enumeration_get_mapping_signed(): Returns the
1426 signed mapping contained by a given enumeration field type
1429 extern int bt_ctf_field_type_enumeration_get_mapping_unsigned(
1430 struct bt_ctf_field_type
*enum_field_type
, uint64_t index
,
1431 const char **name
, uint64_t *range_begin
,
1432 uint64_t *range_end
);
1435 @brief Finds the mappings of the @enumft \p enum_field_type which
1438 This function returns an iterator on the result set of this find
1439 operation. See \ref ctfirenumftmappingiter for more details.
1441 @param[in] enum_field_type Enumeration field type of which to find
1442 the mappings named \p name.
1443 @param[in] name Name of the mappings to find in
1445 @returns @enumftiter on the set of mappings named
1446 \p name in \p enum_field_type, or
1447 \c NULL if no mappings were found or
1450 @prenotnull{enum_field_type}
1452 @preisenumft{enum_field_type}
1453 @postrefcountsame{enum_field_type}
1454 @postsuccessrefcountret1
1455 @post <strong>On success</strong>, the returned @enumftiter can iterate
1456 on at least one mapping.
1458 @sa bt_ctf_field_type_enumeration_find_mappings_by_signed_value(): Finds
1459 the mappings of a given enumeration field type which contain
1460 a given signed value in their range.
1461 @sa bt_ctf_field_type_enumeration_find_mappings_by_unsigned_value(): Finds
1462 the mappings of a given enumeration field type which contain
1463 a given unsigned value in their range.
1465 extern struct bt_ctf_field_type_enumeration_mapping_iterator
*
1466 bt_ctf_field_type_enumeration_find_mappings_by_name(
1467 struct bt_ctf_field_type
*enum_field_type
,
1471 @brief Finds the mappings of the @enumft \p enum_field_type which
1472 contain the signed value \p value in their range.
1474 This function returns an iterator on the result set of this find
1475 operation. See \ref ctfirenumftmappingiter for more details.
1477 @param[in] enum_field_type Enumeration field type of which to find
1478 the mappings which contain \p value.
1479 @param[in] value Value to find in the ranges of the
1480 mappings of \p enum_field_type.
1481 @returns @enumftiter on the set of mappings of
1482 \p enum_field_type which contain
1483 \p value in their range, or \c NULL if
1484 no mappings were found or on error.
1486 @prenotnull{enum_field_type}
1487 @preisenumft{enum_field_type}
1488 @postrefcountsame{enum_field_type}
1489 @postsuccessrefcountret1
1490 @post <strong>On success</strong>, the returned @enumftiter can iterate
1491 on at least one mapping.
1493 @sa bt_ctf_field_type_enumeration_find_mappings_by_name(): Finds the
1494 mappings of a given enumeration field type which have a given
1496 @sa bt_ctf_field_type_enumeration_find_mappings_by_unsigned_value(): Finds
1497 the mappings of a given enumeration field type which contain
1498 a given unsigned value in their range.
1500 extern struct bt_ctf_field_type_enumeration_mapping_iterator
*
1501 bt_ctf_field_type_enumeration_find_mappings_by_signed_value(
1502 struct bt_ctf_field_type
*enum_field_type
,
1506 @brief Finds the mappings of the @enumft \p enum_field_type which
1507 contain the unsigned value \p value in their range.
1509 This function returns an iterator on the result set of this find
1510 operation. See \ref ctfirenumftmappingiter for more details.
1512 @param[in] enum_field_type Enumeration field type of which to find
1513 the mappings which contain \p value.
1514 @param[in] value Value to find in the ranges of the
1515 mappings of \p enum_field_type.
1516 @returns @enumftiter on the set of mappings of
1517 \p enum_field_type which contain
1518 \p value in their range, or \c NULL
1519 if no mappings were found or
1522 @prenotnull{enum_field_type}
1523 @preisenumft{enum_field_type}
1524 @postrefcountsame{enum_field_type}
1525 @postsuccessrefcountret1
1526 @post <strong>On success</strong>, the returned @enumftiter can iterate
1527 on at least one mapping.
1529 @sa bt_ctf_field_type_enumeration_find_mappings_by_name(): Finds the
1530 mappings of a given enumeration field type which have a given
1532 @sa bt_ctf_field_type_enumeration_find_mappings_by_signed_value(): Finds
1533 the mappings of a given enumeration field type which contain
1534 a given unsigned value in their range.
1536 extern struct bt_ctf_field_type_enumeration_mapping_iterator
*
1537 bt_ctf_field_type_enumeration_find_mappings_by_unsigned_value(
1538 struct bt_ctf_field_type
*enum_field_type
,
1542 @brief Adds a mapping to the @enumft \p enum_field_type which maps the
1543 name \p name to the signed range \p range_begin (included) to
1544 \p range_end (included).
1546 Make \p range_begin and \p range_end the same value to add a mapping
1549 The @intft wrapped by \p enum_field_type, as returned by
1550 bt_ctf_field_type_enumeration_get_container_type(), must be
1551 \b signed to use this function.
1553 A mapping in \p enum_field_type can exist with the name \p name.
1555 @param[in] enum_field_type Enumeration field type to which to add
1557 @param[in] name Name of the mapping to add (copied
1559 @param[in] range_begin Beginning of the range of the mapping
1561 @param[in] range_end End of the range of the mapping
1563 @returns 0 on success, or a negative value on error.
1565 @prenotnull{enum_field_type}
1567 @prehot{enum_field_type}
1568 @preisenumft{enum_field_type}
1569 @pre The wrapped @intft of \p enum_field_type is signed.
1570 @pre \p range_end is greater than or equal to \p range_begin.
1571 @postrefcountsame{enum_field_type}
1573 @sa bt_ctf_field_type_enumeration_add_mapping_unsigned(): Adds an
1574 unsigned mapping to a given enumeration field type.
1576 extern int bt_ctf_field_type_enumeration_add_mapping(
1577 struct bt_ctf_field_type
*enum_field_type
, const char *name
,
1578 int64_t range_begin
, int64_t range_end
);
1581 @brief Adds a mapping to the @enumft \p enum_field_type which maps
1582 the name \p name to the unsigned
1583 range \p range_begin (included) to \p range_end (included).
1585 Make \p range_begin and \p range_end the same value to add a mapping
1588 The @intft wrapped by \p enum_field_type, as returned by
1589 bt_ctf_field_type_enumeration_get_container_type(), must be
1590 \b unsigned to use this function.
1592 A mapping in \p enum_field_type can exist with the name \p name.
1594 @param[in] enum_field_type Enumeration field type to which to add
1596 @param[in] name Name of the mapping to add (copied
1598 @param[in] range_begin Beginning of the range of the mapping
1600 @param[in] range_end End of the range of the mapping
1602 @returns 0 on success, or a negative value on error.
1604 @prenotnull{enum_field_type}
1606 @prehot{enum_field_type}
1607 @preisenumft{enum_field_type}
1608 @pre The wrapped @intft of \p enum_field_type is unsigned.
1609 @pre \p range_end is greater than or equal to \p range_begin.
1610 @postrefcountsame{enum_field_type}
1612 @sa bt_ctf_field_type_enumeration_add_mapping(): Adds a signed
1613 mapping to a given enumeration field type.
1615 extern int bt_ctf_field_type_enumeration_add_mapping_unsigned(
1616 struct bt_ctf_field_type
*enum_field_type
, const char *name
,
1617 uint64_t range_begin
, uint64_t range_end
);
1622 @defgroup ctfirenumftmappingiter CTF IR enumeration field type mapping iterator
1623 @ingroup ctfirenumfieldtype
1624 @brief CTF IR enumeration field type mapping iterator.
1627 #include <babeltrace/ctf-ir/field-types.h>
1630 A CTF IR <strong><em>enumeration field type mapping
1631 iterator</em></strong> is an iterator on @enumft mappings.
1633 You can get an enumeration mapping iterator from one of the following
1636 - Find operations of an @enumft object:
1637 - bt_ctf_field_type_enumeration_find_mappings_by_name(): Finds the
1638 mappings with a given name.
1639 - bt_ctf_field_type_enumeration_find_mappings_by_unsigned_value():
1640 Finds the mappings which contain a given unsigned value in their
1642 - bt_ctf_field_type_enumeration_find_mappings_by_signed_value():
1643 Finds the mappings which contain a given signed value in their range.
1644 - bt_ctf_field_enumeration_get_mappings(): Finds the mappings in the
1645 @enumft of an @enumfield containing its current integral value in
1648 Those functions guarantee that the returned iterator can iterate on
1649 at least one mapping. Otherwise, they return \c NULL.
1651 You can get the name and the range of a mapping iterator's current
1653 bt_ctf_field_type_enumeration_mapping_iterator_get_signed()
1655 bt_ctf_field_type_enumeration_mapping_iterator_get_unsigned(),
1656 depending on the signedness of the @intft wrapped by the
1657 @enumft. If you only need the name of the current mapping, you can
1658 use any of the two functions and set the \p range_begin and \p range_end
1659 parameters to \c NULL.
1661 You can advance an enumeration field type mapping iterator to the next
1663 bt_ctf_field_type_enumeration_mapping_iterator_next(). This
1664 function returns a negative value when you reach the end of the
1667 As with any Babeltrace object, CTF IR enumeration field type mapping
1668 iterator objects have <a
1669 href="https://en.wikipedia.org/wiki/Reference_counting">reference
1670 counts</a>. See \ref refs to learn more about the reference counting
1671 management of Babeltrace objects.
1673 @sa ctfirenumfieldtype
1675 @addtogroup ctfirenumftmappingiter
1680 @struct bt_ctf_field_type_enumeration_mapping_iterator
1681 @brief A CTF IR enumeration field type mapping iterator.
1682 @sa ctfirenumftmappingiter
1686 @brief Returns the name and the range of the current (signed) mapping
1687 of the @enumftiter \p iter.
1689 If one of \p range_begin or \p range_end is not \c NULL, the @intft
1690 wrapped by the @enumft from which \p iter was obtained, as returned by
1691 bt_ctf_field_type_enumeration_get_container_type(), must be
1692 \b signed to use this function. Otherwise, if you only need to get the
1693 name of the current mapping, set \p range_begin and \p range_end to
1696 On success, if \p name is not \c NULL, \p *name remains valid as long
1697 as \p iter exists and
1698 bt_ctf_field_type_enumeration_mapping_iterator_next() is
1699 \em not called on \p iter.
1701 @param[in] iter Enumeration field type mapping iterator
1702 of which to get the range of the current
1704 @param[out] name Returned name of the current mapping of
1705 \p iter (can be \c NULL to ignore).
1706 @param[out] range_begin Returned beginning of the range
1707 (included) of the current mapping of
1708 \p iter (can be \c NULL to ignore).
1709 @param[out] range_end Returned end of the range
1710 (included) of the current mapping of
1711 \p iter (can be \c NULL to ignore).
1712 @returns 0 on success, or a negative value on error.
1715 @postrefcountsame{iter}
1717 @sa bt_ctf_field_type_enumeration_mapping_iterator_get_unsigned():
1718 Returns the name and the unsigned range of the current mapping
1719 of a given enumeration field type mapping iterator.
1721 extern int bt_ctf_field_type_enumeration_mapping_iterator_get_signed(
1722 struct bt_ctf_field_type_enumeration_mapping_iterator
*iter
,
1723 const char **name
, int64_t *range_begin
, int64_t *range_end
);
1726 @brief Returns the name and the range of the current (unsigned) mapping
1727 of the @enumftiter \p iter.
1729 If one of \p range_begin or \p range_end is not \c NULL, the @intft
1730 wrapped by the @enumft from which \p iter was obtained, as returned by
1731 bt_ctf_field_type_enumeration_get_container_type(), must be
1732 \b unsigned to use this function. Otherwise, if you only need to get the
1733 name of the current mapping, set \p range_begin and \p range_end to
1736 On success, if \p name is not \c NULL, \p *name remains valid as long
1737 as \p iter exists and
1738 bt_ctf_field_type_enumeration_mapping_iterator_next() is
1739 \em not called on \p iter.
1741 @param[in] iter Enumeration field type mapping iterator
1742 of which to get the range of the current
1744 @param[out] name Returned name of the current mapping of
1745 \p iter (can be \c NULL to ignore).
1746 @param[out] range_begin Returned beginning of the range
1747 (included) of the current mapping of
1748 \p iter (can be \c NULL to ignore).
1749 @param[out] range_end Returned end of the range
1750 (included) of the current mapping of
1751 \p iter (can be \c NULL to ignore).
1752 @returns 0 on success, or a negative value on error.
1755 @postrefcountsame{iter}
1758 bt_ctf_field_type_enumeration_mapping_iterator_get_signed():
1759 Returns the name and the signed range of the current mapping of
1760 a given enumeration field type mapping iterator.
1762 extern int bt_ctf_field_type_enumeration_mapping_iterator_get_unsigned(
1763 struct bt_ctf_field_type_enumeration_mapping_iterator
*iter
,
1764 const char **name
, uint64_t *range_begin
, uint64_t *range_end
);
1767 @brief Advances the @enumftiter \p iter to the next mapping.
1769 @param[in] iter Enumeration field type mapping iterator to
1771 @returns 0 on success, or a negative value on error or
1772 when you reach the end of the set.
1775 @postrefcountsame{iter}
1777 extern int bt_ctf_field_type_enumeration_mapping_iterator_next(
1778 struct bt_ctf_field_type_enumeration_mapping_iterator
*iter
);
1783 @defgroup ctfirstringfieldtype CTF IR string field type
1784 @ingroup ctfirfieldtypes
1785 @brief CTF IR string field type.
1788 #include <babeltrace/ctf-ir/field-types.h>
1791 A CTF IR <strong><em>string field type</em></strong> is a field type that
1792 you can use to create concrete @stringfields.
1794 You can create a string field type
1795 with bt_ctf_field_type_string_create().
1797 A string field type has only one property: the \b encoding of its
1798 described @stringfields. By default, the encoding of the string fields
1799 described by a string field type is #BT_CTF_STRING_ENCODING_UTF8. You
1800 can set the encoding of the string fields described by a string field
1801 type with bt_ctf_field_type_string_set_encoding().
1803 @sa ctfirstringfield
1806 @addtogroup ctfirstringfieldtype
1811 @brief Creates a default @stringft.
1813 @returns Created string field type, or \c NULL on error.
1815 @postsuccessrefcountret1
1817 extern struct bt_ctf_field_type
*bt_ctf_field_type_string_create(void);
1820 @brief Returns the encoding of the @stringfields described by
1821 the @stringft \p string_field_type.
1823 @param[in] string_field_type String field type which describes the
1824 string fields of which to get the
1826 @returns Encoding of the string
1827 fields described by \p string_field_type,
1828 or #BT_CTF_STRING_ENCODING_UNKNOWN on
1831 @prenotnull{string_field_type}
1832 @preisstringft{string_field_type}
1833 @postrefcountsame{string_field_type}
1835 @sa bt_ctf_field_type_string_set_encoding(): Sets the encoding
1836 of the string fields described by a given string field type.
1838 extern enum bt_ctf_string_encoding
bt_ctf_field_type_string_get_encoding(
1839 struct bt_ctf_field_type
*string_field_type
);
1842 @brief Sets the encoding of the @stringfields described by the
1843 @stringft \p string_field_type to \p encoding.
1845 @param[in] string_field_type String field type which describes the
1846 string fields of which to set the
1848 @param[in] encoding Encoding of the string fields described
1849 by \p string_field_type.
1850 @returns 0 on success, or a negative value on error.
1852 @prenotnull{string_field_type}
1853 @preisstringft{string_field_type}
1854 @prehot{string_field_type}
1855 @pre \p encoding is #BT_CTF_STRING_ENCODING_ASCII or
1856 #BT_CTF_STRING_ENCODING_UTF8.
1857 @postrefcountsame{string_field_type}
1859 @sa bt_ctf_field_type_string_get_encoding(): Returns the encoding of
1860 the string fields described by a given string field type.
1862 extern int bt_ctf_field_type_string_set_encoding(
1863 struct bt_ctf_field_type
*string_field_type
,
1864 enum bt_ctf_string_encoding encoding
);
1869 @defgroup ctfirstructfieldtype CTF IR structure field type
1870 @ingroup ctfirfieldtypes
1871 @brief CTF IR structure field type.
1874 #include <babeltrace/ctf-ir/field-types.h>
1877 A CTF IR <strong><em>structure field type</em></strong> is
1878 a field type that you can use to create concrete @structfields.
1880 You can create a structure field type
1881 with bt_ctf_field_type_structure_create(). This function creates
1882 an empty structure field type, with no fields.
1884 You can add a field to a structure field type with
1885 bt_ctf_field_type_structure_add_field(). Two fields in a structure
1886 field type cannot have the same name.
1888 You can set the \em minimum alignment of the structure fields described
1889 by a structure field type with the common
1890 bt_ctf_field_type_set_alignment() function. The \em effective alignment
1891 of the structure fields described by a structure field type, as per
1892 <a href="http://diamon.org/ctf/">CTF</a>, is the \em maximum value amongst
1893 the effective alignments of all its fields. Note that the effective
1894 alignment of @varfields is always 1.
1896 You can set the byte order of <em>all the contained fields</em>,
1897 recursively, of a structure field type with the common
1898 bt_ctf_field_type_set_byte_order() function.
1900 @sa ctfirstructfield
1903 @addtogroup ctfirstructfieldtype
1908 @brief Creates a default, empty @structft.
1910 @returns Created structure field type,
1911 or \c NULL on error.
1913 @postsuccessrefcountret1
1915 extern struct bt_ctf_field_type
*bt_ctf_field_type_structure_create(void);
1918 @brief Returns the number of fields contained in the
1919 @structft \p struct_field_type.
1921 @param[in] struct_field_type Structure field type of which to get
1922 the number of contained fields.
1923 @returns Number of fields contained in
1924 \p struct_field_type, or a negative
1927 @prenotnull{struct_field_type}
1928 @preisstructft{struct_field_type}
1929 @postrefcountsame{struct_field_type}
1931 extern int64_t bt_ctf_field_type_structure_get_field_count(
1932 struct bt_ctf_field_type
*struct_field_type
);
1935 @brief Returns the field of the @structft \p struct_field_type
1938 On success, the field's type is placed in \p *field_type if
1939 \p field_type is not \c NULL. The field's name is placed in
1940 \p *field_name if \p field_name is not \c NULL.
1941 \p struct_field_type remains the sole owner of \p *field_name.
1943 @param[in] struct_field_type Structure field type of which to get
1944 the field at index \p index.
1945 @param[out] field_name Returned name of the field at index
1946 \p index (can be \c NULL).
1947 @param[out] field_type Returned field type of the field
1948 at index \p index (can be \c NULL).
1949 @param[in] index Index of the field to get from
1950 \p struct_field_type.
1951 @returns 0 on success, or a negative value on error.
1953 @prenotnull{struct_field_type}
1954 @preisstructft{struct_field_type}
1955 @pre \p index is lesser than the number of fields contained in the
1956 structure field type \p struct_field_type (see
1957 bt_ctf_field_type_structure_get_field_count()).
1958 @postrefcountsame{struct_field_type}
1959 @post <strong>On success</strong>, the returned field's type is placed
1960 in \p *field_type and its reference count is incremented.
1962 @sa bt_ctf_field_type_structure_get_field_type_by_name(): Finds a
1963 structure field type's field by name.
1965 extern int bt_ctf_field_type_structure_get_field_by_index(
1966 struct bt_ctf_field_type
*struct_field_type
,
1967 const char **field_name
, struct bt_ctf_field_type
**field_type
,
1970 /* Pre-2.0 CTF writer compatibility */
1971 #define bt_ctf_field_type_structure_get_field bt_ctf_field_type_structure_get_field_by_index
1974 @brief Returns the type of the field named \p field_name found in
1975 the @structft \p struct_field_type.
1977 @param[in] struct_field_type Structure field type of which to get
1979 @param[in] field_name Name of the field to find.
1980 @returns Type of the field named \p field_name in
1981 \p struct_field_type, or
1984 @prenotnull{struct_field_type}
1985 @prenotnull{field_name}
1986 @preisstructft{struct_field_type}
1987 @postrefcountsame{struct_field_type}
1988 @postsuccessrefcountretinc
1990 @sa bt_ctf_field_type_structure_get_field_by_index(): Finds a
1991 structure field type's field by index.
1994 struct bt_ctf_field_type
*bt_ctf_field_type_structure_get_field_type_by_name(
1995 struct bt_ctf_field_type
*struct_field_type
,
1996 const char *field_name
);
1999 @brief Adds a field named \p field_name with the @ft
2000 \p field_type to the @structft \p struct_field_type.
2002 On success, \p field_type becomes the child of \p struct_field_type.
2004 This function adds the new field after the current last field of
2005 \p struct_field_type (append mode).
2007 You \em cannot add a field named \p field_name if there's already a
2008 field named \p field_name in \p struct_field_type.
2010 @param[in] struct_field_type Structure field type to which to add
2012 @param[in] field_type Field type of the field to add to
2013 \p struct_field_type.
2014 @param[in] field_name Name of the field to add to
2015 \p struct_field_type
2016 (copied on success).
2017 @returns 0 on success, or a negative value on error.
2019 @prenotnull{struct_field_type}
2020 @prenotnull{field_type}
2021 @prenotnull{field_name}
2022 @preisstructft{struct_field_type}
2023 @pre \p field_type is not and does not contain \p struct_field_type,
2024 recursively, as a field's type.
2025 @prehot{struct_field_type}
2026 @postrefcountsame{struct_field_type}
2027 @postsuccessrefcountinc{field_type}
2029 extern int bt_ctf_field_type_structure_add_field(
2030 struct bt_ctf_field_type
*struct_field_type
,
2031 struct bt_ctf_field_type
*field_type
,
2032 const char *field_name
);
2037 @defgroup ctfirarrayfieldtype CTF IR array field type
2038 @ingroup ctfirfieldtypes
2039 @brief CTF IR array field type.
2042 #include <babeltrace/ctf-ir/field-types.h>
2045 A CTF IR <strong><em>array field type</em></strong> is a field type that
2046 you can use to create concrete @arrayfields.
2048 You can create an array field type
2049 with bt_ctf_field_type_array_create(). This function needs
2050 the @ft of the fields contained by the array fields described by the
2051 array field type to create.
2056 @addtogroup ctfirarrayfieldtype
2061 @brief Creates a default @arrayft with
2062 \p element_field_type as the field type of the fields contained
2063 in its described @arrayfields of length \p length.
2065 @param[in] element_field_type Field type of the fields contained in
2066 the array fields described by the
2067 created array field type.
2068 @param[in] length Length of the array fields described by
2069 the created array field type.
2070 @returns Created array field type, or
2073 @prenotnull{element_field_type}
2074 @postsuccessrefcountinc{element_field_type}
2075 @postsuccessrefcountret1
2077 extern struct bt_ctf_field_type
*bt_ctf_field_type_array_create(
2078 struct bt_ctf_field_type
*element_field_type
,
2079 unsigned int length
);
2082 @brief Returns the @ft of the @fields contained in
2083 the @arrayfields described by the @arrayft \p array_field_type.
2085 @param[in] array_field_type Array field type of which to get
2086 the type of the fields contained in its
2087 described array fields.
2088 @returns Type of the fields contained in the
2089 array fields described by
2090 \p array_field_type, or \c NULL
2093 @prenotnull{array_field_type}
2094 @preisarrayft{array_field_type}
2095 @postrefcountsame{array_field_type}
2096 @postsuccessrefcountretinc
2098 extern struct bt_ctf_field_type
*bt_ctf_field_type_array_get_element_type(
2099 struct bt_ctf_field_type
*array_field_type
);
2102 @brief Returns the number of @fields contained in the
2103 @arrayfields described by the @arrayft \p array_field_type.
2105 @param[in] array_field_type Array field type of which to get
2106 the number of fields contained in its
2107 described array fields.
2108 @returns Number of fields contained in the
2109 array fields described by
2110 \p array_field_type, or a negative value
2113 @prenotnull{array_field_type}
2114 @preisarrayft{array_field_type}
2115 @postrefcountsame{array_field_type}
2117 extern int64_t bt_ctf_field_type_array_get_length(
2118 struct bt_ctf_field_type
*array_field_type
);
2123 @defgroup ctfirseqfieldtype CTF IR sequence field type
2124 @ingroup ctfirfieldtypes
2125 @brief CTF IR sequence field type.
2128 #include <babeltrace/ctf-ir/field-types.h>
2131 A CTF IR <strong><em>sequence field type</em></strong> is
2132 a field type that you can use to create concrete @seqfields.
2134 You can create a sequence field type with
2135 bt_ctf_field_type_sequence_create(). This function needs the @ft
2136 of the fields contained by the sequence fields described by the created
2137 sequence field type. This function also needs the length name of the
2138 sequence field type to create. The length name is used to automatically
2139 resolve the length's field type. See \ref ctfirfieldtypes to learn more
2140 about the automatic resolving.
2145 @addtogroup ctfirseqfieldtype
2150 @brief Creates a default @seqft with \p element_field_type as the
2151 @ft of the @fields contained in its described @seqfields
2152 with the length name \p length_name.
2154 \p length_name can be an absolute or relative reference. See
2155 <a href="http://diamon.org/ctf/">CTF</a> for more details.
2157 @param[in] element_field_type Field type of the fields contained in
2158 the sequence fields described by the
2159 created sequence field type.
2160 @param[in] length_name Length name (copied on success).
2161 @returns Created array field type, or
2164 @prenotnull{element_field_type}
2165 @prenotnull{length_name}
2166 @postsuccessrefcountinc{element_field_type}
2167 @postsuccessrefcountret1
2169 extern struct bt_ctf_field_type
*bt_ctf_field_type_sequence_create(
2170 struct bt_ctf_field_type
*element_field_type
,
2171 const char *length_name
);
2174 @brief Returns the @ft of the @fields contained in the @seqft
2175 described by the @seqft \p sequence_field_type.
2177 @param[in] sequence_field_type Sequence field type of which to get
2178 the type of the fields contained in its
2179 described sequence fields.
2180 @returns Type of the fields contained in the
2181 sequence fields described by
2182 \p sequence_field_type, or \c NULL
2185 @prenotnull{sequence_field_type}
2186 @preisseqft{sequence_field_type}
2187 @postrefcountsame{sequence_field_type}
2188 @postsuccessrefcountretinc
2190 extern struct bt_ctf_field_type
*bt_ctf_field_type_sequence_get_element_type(
2191 struct bt_ctf_field_type
*sequence_field_type
);
2194 @brief Returns the length name of the @seqft \p sequence_field_type.
2196 On success, \p sequence_field_type remains the sole owner of
2197 the returned string.
2199 @param[in] sequence_field_type Sequence field type of which to get the
2201 @returns Length name of \p sequence_field_type,
2202 or \c NULL on error.
2204 @prenotnull{sequence_field_type}
2205 @preisseqft{sequence_field_type}
2207 @sa bt_ctf_field_type_sequence_get_length_field_path(): Returns the
2208 length's CTF IR field path of a given sequence field type.
2210 extern const char *bt_ctf_field_type_sequence_get_length_field_name(
2211 struct bt_ctf_field_type
*sequence_field_type
);
2214 @brief Returns the length's CTF IR field path of the @seqft
2215 \p sequence_field_type.
2217 The length's field path of a sequence field type is set when automatic
2218 resolving is performed (see \ref ctfirfieldtypes).
2220 @param[in] sequence_field_type Sequence field type of which to get the
2221 length's field path.
2222 @returns Length's field path of
2223 \p sequence_field_type, or
2224 \c NULL if the length's field path is
2225 not set yet is not set or on error.
2227 @prenotnull{sequence_field_type}
2228 @preisseqft{sequence_field_type}
2229 @postsuccessrefcountretinc
2231 @sa bt_ctf_field_type_sequence_get_length_field_name(): Returns the
2232 length's name of a given sequence field type.
2234 extern struct bt_ctf_field_path
*bt_ctf_field_type_sequence_get_length_field_path(
2235 struct bt_ctf_field_type
*sequence_field_type
);
2240 @defgroup ctfirvarfieldtype CTF IR variant field type
2241 @ingroup ctfirfieldtypes
2242 @brief CTF IR variant field type.
2245 #include <babeltrace/ctf-ir/field-types.h>
2248 A CTF IR <strong><em>variant field type</em></strong> is
2249 a field type that you can use to create concrete @varfields.
2251 You can create a variant field type with
2252 bt_ctf_field_type_variant_create(). This function expects you to pass
2253 both the tag's @enumft and the tag name of the variant field type to
2254 create. The tag's field type is optional, as the Babeltrace system can
2255 automatically resolve it using the tag name. You can leave the tag name
2256 to \c NULL initially, and set it later with
2257 bt_ctf_field_type_variant_set_tag_name(). The tag name must be set when
2258 the variant field type is frozen. See \ref ctfirfieldtypes to learn more
2259 about the automatic resolving and the conditions under which a field
2262 You can add a field to a variant field type with
2263 bt_ctf_field_type_variant_add_field(). All the field names of a
2264 variant field type \em must exist as mapping names in its tag's @enumft.
2266 The effective alignment of the @varfields described by a
2267 variant field type is always 1, but the individual fields of a
2268 @varfield can have custom alignments.
2270 You can set the byte order of <em>all the contained fields</em>,
2271 recursively, of a variant field type with the common
2272 bt_ctf_field_type_set_byte_order() function.
2277 @addtogroup ctfirvarfieldtype
2282 @brief Creates a default, empty @varft with the tag's @enumft
2283 \p tag_field_type and the tag name \p tag_name.
2285 \p tag_field_type can be \c NULL; the tag's field type can be
2286 automatically resolved from the variant field type's tag name (see
2287 \ref ctfirfieldtypes). If \p tag_name is \c NULL, it \em must be set
2288 with bt_ctf_field_type_variant_set_tag_name() \em before the variant
2289 field type is frozen.
2291 \p tag_name can be an absolute or relative reference. See
2292 <a href="http://diamon.org/ctf/">CTF</a> for more details.
2294 @param[in] tag_field_type Tag's enumeration field type
2296 @param[in] tag_name Tag name (copied on success,
2298 @returns Created variant field type, or
2301 @pre \p tag_field_type is an enumeration field type or \c NULL.
2302 @post <strong>On success, if \p tag_field_type is not \c NULL</strong>,
2303 its reference count is incremented.
2304 @postsuccessrefcountret1
2306 extern struct bt_ctf_field_type
*bt_ctf_field_type_variant_create(
2307 struct bt_ctf_field_type
*tag_field_type
,
2308 const char *tag_name
);
2311 @brief Returns the tag's @enumft of the @varft \p variant_field_type.
2313 @param[in] variant_field_type Variant field type of which to get
2314 the tag's enumeration field type.
2315 @returns Tag's enumeration field type of
2316 \p variant_field_type, or \c NULL if the
2317 tag's field type is not set or on
2320 @prenotnull{variant_field_type}
2321 @preisvarft{variant_field_type}
2322 @postrefcountsame{variant_field_type}
2323 @postsuccessrefcountretinc
2325 extern struct bt_ctf_field_type
*bt_ctf_field_type_variant_get_tag_type(
2326 struct bt_ctf_field_type
*variant_field_type
);
2329 @brief Returns the tag name of the @varft \p variant_field_type.
2331 On success, \p variant_field_type remains the sole owner of
2332 the returned string.
2334 @param[in] variant_field_type Variant field type of which to get the
2336 @returns Tag name of \p variant_field_type, or
2337 \c NULL if the tag name is not set or
2340 @prenotnull{variant_field_type}
2341 @preisvarft{variant_field_type}
2343 @sa bt_ctf_field_type_variant_set_tag_name(): Sets the tag name of
2344 a given variant field type.
2345 @sa bt_ctf_field_type_variant_get_tag_field_path(): Returns the tag's
2346 CTF IR field path of a given variant field type.
2348 extern const char *bt_ctf_field_type_variant_get_tag_name(
2349 struct bt_ctf_field_type
*variant_field_type
);
2352 @brief Sets the tag name of the @varft \p variant_field_type.
2354 \p tag_name can be an absolute or relative reference. See
2355 <a href="http://diamon.org/ctf/">CTF</a> for more details.
2357 @param[in] variant_field_type Variant field type of which to set
2359 @param[in] tag_name Tag name of \p variant_field_type
2360 (copied on success).
2361 @returns 0 on success, or a negative value on error.
2363 @prenotnull{variant_field_type}
2365 @prehot{variant_field_type}
2366 @postrefcountsame{variant_field_type}
2368 @sa bt_ctf_field_type_variant_get_tag_name(): Returns the tag name of
2369 a given variant field type.
2371 extern int bt_ctf_field_type_variant_set_tag_name(
2372 struct bt_ctf_field_type
*variant_field_type
,
2373 const char *tag_name
);
2376 @brief Returns the tag's CTF IR field path of the @varft
2377 \p variant_field_type.
2379 The tag's field path of a variant field type is set when automatic
2380 resolving is performed (see \ref ctfirfieldtypes).
2382 @param[in] variant_field_type Variant field type of which to get the
2384 @returns Tag's field path of
2385 \p variant_field_type, or
2386 \c NULL if the tag's field path is not
2387 set yet is not set or on error.
2389 @prenotnull{variant_field_type}
2390 @preisvarft{variant_field_type}
2391 @postsuccessrefcountretinc
2393 @sa bt_ctf_field_type_variant_get_tag_name(): Returns the tag's
2394 name of a given variant field type.
2396 extern struct bt_ctf_field_path
*bt_ctf_field_type_variant_get_tag_field_path(
2397 struct bt_ctf_field_type
*variant_field_type
);
2400 @brief Returns the number of fields (choices) contained in the @varft
2401 \p variant_field_type.
2403 @param[in] variant_field_type Variant field type of which to get
2404 the number of contained fields.
2405 @returns Number of fields contained in
2406 \p variant_field_type, or a negative
2409 @prenotnull{variant_field_type}
2410 @preisvarft{variant_field_type}
2411 @postrefcountsame{variant_field_type}
2413 extern int64_t bt_ctf_field_type_variant_get_field_count(
2414 struct bt_ctf_field_type
*variant_field_type
);
2417 @brief Returns the field (choice) of the @varft \p variant_field_type
2420 On success, the field's type is placed in \p *field_type if
2421 \p field_type is not \c NULL. The field's name is placed in
2422 \p *field_name if \p field_name is not \c NULL.
2423 \p variant_field_type remains the sole owner of \p *field_name.
2425 @param[in] variant_field_type Variant field type of which to get
2426 the field at index \p index.
2427 @param[out] field_name Returned name of the field at index
2428 \p index (can be \c NULL).
2429 @param[out] field_type Returned field type of the field
2430 at index \p index (can be \c NULL).
2431 @param[in] index Index of the field to get from
2432 \p variant_field_type.
2433 @returns 0 on success, or a negative value on error.
2435 @prenotnull{variant_field_type}
2436 @preisvarft{variant_field_type}
2437 @pre \p index is lesser than the number of fields contained in the
2438 variant field type \p variant_field_type (see
2439 bt_ctf_field_type_variant_get_field_count()).
2440 @postrefcountsame{variant_field_type}
2441 @post <strong>On success</strong>, the returned field's type is placed
2442 in \p *field_type and its reference count is incremented.
2444 @sa bt_ctf_field_type_variant_get_field_type_by_name(): Finds a variant
2445 field type's field by name.
2446 @sa bt_ctf_field_type_variant_get_field_type_from_tag(): Finds a variant
2447 field type's field by current tag value.
2449 extern int bt_ctf_field_type_variant_get_field_by_index(
2450 struct bt_ctf_field_type
*variant_field_type
,
2451 const char **field_name
,
2452 struct bt_ctf_field_type
**field_type
, uint64_t index
);
2454 /* Pre-2.0 CTF writer compatibility */
2455 #define bt_ctf_field_type_variant_get_field bt_ctf_field_type_variant_get_field_by_index
2458 @brief Returns the type of the field (choice) named \p field_name
2459 found in the @varft \p variant_field_type.
2461 @param[in] variant_field_type Variant field type of which to get
2463 @param[in] field_name Name of the field to find.
2464 @returns Type of the field named \p field_name in
2465 \p variant_field_type, or
2468 @prenotnull{variant_field_type}
2469 @prenotnull{field_name}
2470 @preisvarft{variant_field_type}
2471 @postrefcountsame{variant_field_type}
2472 @postsuccessrefcountretinc
2474 @sa bt_ctf_field_type_variant_get_field_by_index(): Finds a variant field type's
2476 @sa bt_ctf_field_type_variant_get_field_type_from_tag(): Finds a variant
2477 field type's field by current tag value.
2480 struct bt_ctf_field_type
*bt_ctf_field_type_variant_get_field_type_by_name(
2481 struct bt_ctf_field_type
*variant_field_type
,
2482 const char *field_name
);
2485 @brief Returns the type of the field (choice) selected by the value of
2486 the @enumfield \p tag_field in the @varft \p variant_field_type.
2488 \p tag_field is the current tag value.
2490 The field type of \p tag_field, as returned by bt_ctf_field_get_type(),
2491 \em must be equivalent to the field type returned by
2492 bt_ctf_field_type_variant_get_tag_type() for \p variant_field_type.
2494 @param[in] variant_field_type Variant field type of which to get
2496 @param[in] tag_field Current tag value (variant field type's
2498 @returns Type of the field selected by
2499 \p tag_field in \p variant_field_type,
2500 or \c NULL on error.
2502 @prenotnull{variant_field_type}
2503 @prenotnull{tag_field}
2504 @preisvarft{variant_field_type}
2505 @preisenumfield{tag_field}
2506 @postrefcountsame{variant_field_type}
2507 @postrefcountsame{tag_field}
2508 @postsuccessrefcountretinc
2510 @sa bt_ctf_field_type_variant_get_field_by_index(): Finds a variant field type's
2512 @sa bt_ctf_field_type_variant_get_field_type_by_name(): Finds a variant
2513 field type's field by name.
2516 struct bt_ctf_field_type
*bt_ctf_field_type_variant_get_field_type_from_tag(
2517 struct bt_ctf_field_type
*variant_field_type
,
2518 struct bt_ctf_field
*tag_field
);
2521 @brief Adds a field (a choice) named \p field_name with the @ft
2522 \p field_type to the @varft \p variant_field_type.
2524 On success, \p field_type becomes the child of \p variant_field_type.
2526 You \em cannot add a field named \p field_name if there's already a
2527 field named \p field_name in \p variant_field_type.
2529 \p field_name \em must name an existing mapping in the tag's
2530 enumeration field type of \p variant_field_type.
2532 @param[in] variant_field_type Variant field type to which to add
2534 @param[in] field_type Field type of the field to add to
2535 \p variant_field_type.
2536 @param[in] field_name Name of the field to add to
2537 \p variant_field_type
2538 (copied on success).
2539 @returns 0 on success, or a negative value on error.
2541 @prenotnull{variant_field_type}
2542 @prenotnull{field_type}
2543 @prenotnull{field_name}
2544 @preisvarft{variant_field_type}
2545 @pre \p field_type is not and does not contain \p variant_field_type,
2546 recursively, as a field's type.
2547 @prehot{variant_field_type}
2548 @postrefcountsame{variant_field_type}
2549 @postsuccessrefcountinc{field_type}
2551 extern int bt_ctf_field_type_variant_add_field(
2552 struct bt_ctf_field_type
*variant_field_type
,
2553 struct bt_ctf_field_type
*field_type
,
2554 const char *field_name
);
2562 #endif /* BABELTRACE_CTF_IR_FIELD_TYPES_H */