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 No byte order; the initial native byte order of a
497 \link ctfirtraceclass CTF IR trace class\endlink.
499 BT_CTF_BYTE_ORDER_NONE
,
502 BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
,
505 BT_CTF_BYTE_ORDER_BIG_ENDIAN
,
507 /// Network byte order (big-endian).
508 BT_CTF_BYTE_ORDER_NETWORK
,
512 @brief String encoding of a @ft.
514 enum bt_ctf_string_encoding
{
515 /// Unknown, used for errors.
516 BT_CTF_STRING_ENCODING_UNKNOWN
= CTF_STRING_UNKNOWN
,
519 BT_CTF_STRING_ENCODING_NONE
= CTF_STRING_NONE
,
521 /// <a href="https://en.wikipedia.org/wiki/UTF-8">UTF-8</a>.
522 BT_CTF_STRING_ENCODING_UTF8
= CTF_STRING_UTF8
,
524 /// <a href="https://en.wikipedia.org/wiki/ASCII">ASCII</a>.
525 BT_CTF_STRING_ENCODING_ASCII
= CTF_STRING_ASCII
,
529 @brief Returns the alignment of the @fields described by
530 the @ft \p field_type.
532 @param[in] field_type Field type which describes the
533 fields of which to get the alignment.
534 @returns Alignment of the fields described by
535 \p field_type, or a negative value on error.
537 @prenotnull{field_type}
538 @postrefcountsame{field_type}
540 @sa bt_ctf_field_type_set_alignment(): Sets the alignment
541 of the fields described by a given field type.
543 extern int bt_ctf_field_type_get_alignment(
544 struct bt_ctf_field_type
*field_type
);
547 @brief Sets the alignment of the @fields described by the
548 @ft \p field_type to \p alignment.
550 \p alignment \em must be greater than 0 and a power of two.
552 @param[in] field_type Field type which describes the fields of
553 which to set the alignment.
554 @param[in] alignment Alignment of the fields described by
556 @returns 0 on success, or a negative value on error.
558 @prenotnull{field_type}
560 @pre \p alignment is greater than 0 and a power of two.
561 @postrefcountsame{field_type}
563 @sa bt_ctf_field_type_get_alignment(): Returns the alignment of the
564 fields described by a given field type.
566 extern int bt_ctf_field_type_set_alignment(struct bt_ctf_field_type
*field_type
,
567 unsigned int alignment
);
570 @brief Returns the byte order of the @fields described by
571 the @ft \p field_type.
573 You can only call this function if \p field_type is a @intft, a
574 @floatft, or a @enumft.
576 @param[in] field_type Field type which describes the
577 fields of which to get the byte order.
578 @returns Byte order of the fields described by
579 \p field_type, or #BT_CTF_BYTE_ORDER_UNKNOWN on
582 @prenotnull{field_type}
583 @pre \p field_type is a @intft, a @floatft, or a @enumft.
584 @postrefcountsame{field_type}
586 @sa bt_ctf_field_type_set_byte_order(): Sets the byte order
587 of the fields described by a given field type.
589 extern enum bt_ctf_byte_order
bt_ctf_field_type_get_byte_order(
590 struct bt_ctf_field_type
*field_type
);
593 @brief Sets the byte order of the @fields described by the
594 @ft \p field_type to \p byte_order.
596 If \p field_type is a compound field type, this function also
597 recursively sets the byte order of its children to \p byte_order.
599 @param[in] field_type Field type which describes the fields of
600 which to set the byte order.
601 @param[in] byte_order Alignment of the fields described by
603 @returns 0 on success, or a negative value on error.
605 @prenotnull{field_type}
607 @pre \p byte_order is #BT_CTF_BYTE_ORDER_NATIVE,
608 #BT_CTF_BYTE_ORDER_LITTLE_ENDIAN, #BT_CTF_BYTE_ORDER_BIG_ENDIAN,
609 or #BT_CTF_BYTE_ORDER_NETWORK.
610 @postrefcountsame{field_type}
612 @sa bt_ctf_field_type_get_byte_order(): Returns the byte order of the
613 fields described by a given field type.
615 extern int bt_ctf_field_type_set_byte_order(
616 struct bt_ctf_field_type
*field_type
,
617 enum bt_ctf_byte_order byte_order
);
622 @name Utility functions
627 @brief Returns whether or not the @ft \p field_type_a
628 is equivalent to the field type \p field_type_b.
630 You \em must use this function to compare two field types: it is not
631 safe to compare two pointer values directly, because, for internal
632 reasons, some parts of the Babeltrace system can copy user field types
633 and discard the original ones.
635 @param[in] field_type_a Field type to compare to \p field_type_b.
636 @param[in] field_type_b Field type to compare to \p field_type_a.
637 @returns 0 if \p field_type_a is equivalent to
638 \p field_type_b, 1 if they are not equivalent,
639 or a negative value on error.
641 @prenotnull{field_type_a}
642 @prenotnull{field_type_b}
643 @postrefcountsame{field_type_a}
644 @postrefcountsame{field_type_b}
646 extern int bt_ctf_field_type_compare(struct bt_ctf_field_type
*field_type_a
,
647 struct bt_ctf_field_type
*field_type_b
);
650 @brief Creates a \em deep copy of the @ft \p field_type.
652 You can copy a frozen field type: the resulting copy is
655 This function resets the tag field type of a copied @varft. The
656 automatic field resolving which some functions of the API perform
657 can set it again when the returned field type is used (learn more
658 in the detailed description of this module).
660 @param[in] field_type Field type to copy.
661 @returns Deep copy of \p field_type on success,
664 @prenotnull{field_type}
665 @postrefcountsame{field_type}
666 @postsuccessrefcountret1
667 @post <strong>On success</strong>, the returned field type is not frozen.
669 extern struct bt_ctf_field_type
*bt_ctf_field_type_copy(
670 struct bt_ctf_field_type
*field_type
);
677 @defgroup ctfirintfieldtype CTF IR integer field type
678 @ingroup ctfirfieldtypes
679 @brief CTF IR integer field type.
682 #include <babeltrace/ctf-ir/field-types.h>
685 A CTF IR <strong><em>integer field type</em></strong> is a field type that
686 you can use to create concrete @intfield objects.
688 You can create an integer field type
689 with bt_ctf_field_type_integer_create().
691 An integer field type has the following properties:
696 <th>Value at creation
701 <td>\b Alignment (bits) of the described integer fields
703 <td>bt_ctf_field_type_get_alignment()
704 <td>bt_ctf_field_type_set_alignment()
707 <td><strong>Byte order</strong> of the described integer fields
708 <td>#BT_CTF_BYTE_ORDER_NATIVE
709 <td>bt_ctf_field_type_get_byte_order()
710 <td>bt_ctf_field_type_set_byte_order()
713 <td><strong>Storage size</strong> (bits) of the described
715 <td>Specified at creation
716 <td>bt_ctf_field_type_integer_get_size()
717 <td>bt_ctf_field_type_integer_set_size()
720 <td><strong>Signedness</strong> of the described integer fields
722 <td>bt_ctf_field_type_integer_is_signed()
723 <td>bt_ctf_field_type_integer_set_is_signed()
726 <td><strong>Preferred display base</strong> of the described
728 <td>#BT_CTF_INTEGER_BASE_DECIMAL
729 <td>bt_ctf_field_type_integer_get_base()
730 <td>bt_ctf_field_type_integer_set_base()
733 <td>\b Encoding of the described integer fields
734 <td>#BT_CTF_STRING_ENCODING_NONE
735 <td>bt_ctf_field_type_integer_get_encoding()
736 <td>bt_ctf_field_type_integer_set_encoding()
740 \link ctfirclockclass CTF IR clock class\endlink</strong>
742 <td>bt_ctf_field_type_integer_get_mapped_clock_class()
743 <td>bt_ctf_field_type_integer_set_mapped_clock_class()
749 @sa \ref ctfirfieldtypesexamples_intfieldtype "Examples"
751 @addtogroup ctfirintfieldtype
756 @brief Preferred display base (radix) of a @intft.
758 enum bt_ctf_integer_base
{
759 /// Unknown, used for errors.
760 BT_CTF_INTEGER_BASE_UNKNOWN
= -1,
763 BT_CTF_INTEGER_BASE_BINARY
= 2,
766 BT_CTF_INTEGER_BASE_OCTAL
= 8,
769 BT_CTF_INTEGER_BASE_DECIMAL
= 10,
772 BT_CTF_INTEGER_BASE_HEXADECIMAL
= 16,
776 @brief Creates a default @intft with \p size bits as the storage size
777 of the @intfields it describes.
779 You can change the storage size of the integer fields described by
780 the created integer field type later with
781 bt_ctf_field_type_integer_set_size().
783 @param[in] size Storage size (bits) of the described integer fields.
784 @returns Created integer field type, or \c NULL on error.
786 @pre \p size is greater than 0 and lesser than or equal to 64.
787 @postsuccessrefcountret1
789 extern struct bt_ctf_field_type
*bt_ctf_field_type_integer_create(
793 @brief Returns the storage size, in bits, of the @intfields
794 described by the @intft \p int_field_type.
796 @param[in] int_field_type Integer field type which describes the
797 integer fields of which to get the
799 @returns Storage size (bits) of the integer
800 fields described by \p int_field_type,
801 or a negative value on error.
803 @prenotnull{int_field_type}
804 @preisintft{int_field_type}
805 @postrefcountsame{int_field_type}
807 @sa bt_ctf_field_type_integer_set_size(): Sets the storage size of the
808 integer fields described by a given integer field type.
810 extern int bt_ctf_field_type_integer_get_size(
811 struct bt_ctf_field_type
*int_field_type
);
814 @brief Sets the storage size, in bits, of the @intfields described by
815 the @intft \p int_field_type.
817 @param[in] int_field_type Integer field type which describes the
818 integer fields of which to set the
820 @param[in] size Storage size (bits) of the integer fields
821 described by \p int_field_type.
822 @returns 0 on success, or a negative value on error.
824 @prenotnull{int_field_type}
825 @preisintft{int_field_type}
826 @prehot{int_field_type}
827 @pre \p size is greater than 0 and lesser than or equal to 64.
828 @postrefcountsame{int_field_type}
830 @sa bt_ctf_field_type_integer_get_size(): Returns the storage size of
831 the integer fields described by a given integer field type.
833 extern int bt_ctf_field_type_integer_set_size(
834 struct bt_ctf_field_type
*int_field_type
, unsigned int size
);
837 @brief Returns whether or not the @intfields described by the @intft
838 \p int_field_type are signed.
840 @param[in] int_field_type Integer field type which describes the
841 integer fields of which to get the
843 @returns #BT_TRUE if the integer fields described by
844 \p int_field_type are signed, #BT_FALSE if they
847 @prenotnull{int_field_type}
848 @preisintft{int_field_type}
849 @postrefcountsame{int_field_type}
851 @sa bt_ctf_field_type_integer_set_is_signed(): Sets the signedness of the
852 integer fields described by a given integer field type.
854 extern bt_bool
bt_ctf_field_type_integer_is_signed(
855 struct bt_ctf_field_type
*int_field_type
);
857 /** @cond DOCUMENT */
859 extern int bt_ctf_field_type_integer_get_signed(
860 struct bt_ctf_field_type
*int_field_type
);
865 @brief Sets whether or not the @intfields described by
866 the @intft \p int_field_type are signed.
868 @param[in] int_field_type Integer field type which describes the
869 integer fields of which to set the
871 @param[in] is_signed Signedness of the integer fields
872 described by \p int_field_type; #BT_FALSE means
873 \em unsigned, #BT_TRUE means \em signed.
874 @returns 0 on success, or a negative value on error.
876 @prenotnull{int_field_type}
877 @preisintft{int_field_type}
878 @prehot{int_field_type}
879 @postrefcountsame{int_field_type}
881 @sa bt_ctf_field_type_integer_is_signed(): Returns the signedness of
882 the integer fields described by a given integer field type.
884 extern int bt_ctf_field_type_integer_set_is_signed(
885 struct bt_ctf_field_type
*int_field_type
, bt_bool is_signed
);
887 /* Pre-2.0 CTF writer compatibility */
888 #define bt_ctf_field_type_integer_set_signed bt_ctf_field_type_integer_set_is_signed
891 @brief Returns the preferred display base (radix) of the @intfields
892 described by the @intft \p int_field_type.
894 @param[in] int_field_type Integer field type which describes the
895 integer fields of which to get the
896 preferred display base.
897 @returns Preferred display base of the integer
898 fields described by \p int_field_type,
899 or #BT_CTF_INTEGER_BASE_UNKNOWN on
902 @prenotnull{int_field_type}
903 @preisintft{int_field_type}
904 @postrefcountsame{int_field_type}
906 @sa bt_ctf_field_type_integer_set_base(): Sets the preferred display
907 base of the integer fields described by a given integer field
910 extern enum bt_ctf_integer_base
bt_ctf_field_type_integer_get_base(
911 struct bt_ctf_field_type
*int_field_type
);
914 @brief Sets the preferred display base (radix) of the @intfields
915 described by the @intft \p int_field_type to \p base.
917 @param[in] int_field_type Integer field type which describes the
918 integer fields of which to set the
919 preferred display base.
920 @param[in] base Preferred display base of the integer
921 fields described by \p int_field_type.
922 @returns 0 on success, or a negative value on error.
924 @prenotnull{int_field_type}
925 @preisintft{int_field_type}
926 @prehot{int_field_type}
927 @pre \p base is #BT_CTF_INTEGER_BASE_BINARY, #BT_CTF_INTEGER_BASE_OCTAL,
928 #BT_CTF_INTEGER_BASE_DECIMAL, or
929 #BT_CTF_INTEGER_BASE_HEXADECIMAL.
930 @postrefcountsame{int_field_type}
932 @sa bt_ctf_field_type_integer_get_base(): Returns the preferred display
933 base of the integer fields described by a given
936 extern int bt_ctf_field_type_integer_set_base(
937 struct bt_ctf_field_type
*int_field_type
,
938 enum bt_ctf_integer_base base
);
941 @brief Returns the encoding of the @intfields described by
942 the @intft \p int_field_type.
944 @param[in] int_field_type Integer field type which describes the
945 integer fields of which to get the
947 @returns Encoding of the integer
948 fields described by \p int_field_type,
949 or #BT_CTF_STRING_ENCODING_UNKNOWN on
952 @prenotnull{int_field_type}
953 @preisintft{int_field_type}
954 @postrefcountsame{int_field_type}
956 @sa bt_ctf_field_type_integer_set_encoding(): Sets the encoding
957 of the integer fields described by a given integer field type.
959 extern enum bt_ctf_string_encoding
bt_ctf_field_type_integer_get_encoding(
960 struct bt_ctf_field_type
*int_field_type
);
963 @brief Sets the encoding of the @intfields described by the @intft
964 \p int_field_type to \p encoding.
966 You can use this property, in CTF IR, to create "text" @arrayfts or
967 @seqfts. A text array field type is array field type with an unsigned,
968 8-bit integer field type having an encoding as its element field type.
970 @param[in] int_field_type Integer field type which describes the
971 integer fields of which to set the
973 @param[in] encoding Encoding of the integer
974 fields described by \p int_field_type.
975 @returns 0 on success, or a negative value on error.
977 @prenotnull{int_field_type}
978 @preisintft{int_field_type}
979 @prehot{int_field_type}
980 @pre \p encoding is #BT_CTF_STRING_ENCODING_NONE,
981 #BT_CTF_STRING_ENCODING_ASCII, or
982 #BT_CTF_STRING_ENCODING_UTF8.
983 @postrefcountsame{int_field_type}
985 @sa bt_ctf_field_type_integer_get_encoding(): Returns the encoding of
986 the integer fields described by a given integer field type.
988 extern int bt_ctf_field_type_integer_set_encoding(
989 struct bt_ctf_field_type
*int_field_type
,
990 enum bt_ctf_string_encoding encoding
);
993 @brief Returns the \link ctfirclockclass CTF IR clock class\endlink
994 mapped to the @intft \p int_field_type.
996 The mapped clock class, if any, indicates the class of the clock which
997 an @intfield described by \p int_field_type should sample or update.
998 This mapped clock class is only indicative.
1000 @param[in] int_field_type Integer field type of which to get the
1002 @returns Mapped clock class of \p int_field_type,
1003 or \c NULL if there's no mapped clock
1006 @prenotnull{int_field_type}
1007 @preisintft{int_field_type}
1008 @postrefcountsame{int_field_type}
1009 @postsuccessrefcountretinc
1011 @sa bt_ctf_field_type_integer_set_mapped_clock_class(): Sets the mapped
1012 clock class of a given integer field type.
1014 extern struct bt_ctf_clock_class
*bt_ctf_field_type_integer_get_mapped_clock_class(
1015 struct bt_ctf_field_type
*int_field_type
);
1018 @brief Sets the \link ctfirclockclass CTF IR clock class\endlink mapped
1019 to the @intft \p int_field_type to \p clock_class.
1021 The mapped clock class, if any, indicates the class of the clock which
1022 an integer field described by \p int_field_type should sample or update.
1023 This mapped clock class is only indicative.
1025 @param[in] int_field_type Integer field type of which to set the
1027 @param[in] clock_class Mapped clock class of \p int_field_type.
1028 @returns 0 on success, or a negative value on error.
1030 @prenotnull{int_field_type}
1031 @prenotnull{clock_class}
1032 @preisintft{int_field_type}
1033 @prehot{int_field_type}
1034 @postrefcountsame{int_field_type}
1035 @postsuccessrefcountinc{clock_class}
1037 @sa bt_ctf_field_type_integer_get_mapped_clock_class(): Returns the mapped
1038 clock class of a given integer field type.
1040 extern int bt_ctf_field_type_integer_set_mapped_clock_class(
1041 struct bt_ctf_field_type
*int_field_type
,
1042 struct bt_ctf_clock_class
*clock_class
);
1047 @defgroup ctfirfloatfieldtype CTF IR floating point number field type
1048 @ingroup ctfirfieldtypes
1049 @brief CTF IR floating point number field type.
1052 #include <babeltrace/ctf-ir/field-types.h>
1055 A CTF IR <strong><em>floating point number field type</em></strong> is
1056 a field type that you can use to create concrete @floatfields.
1058 You can create a floating point number field type
1059 with bt_ctf_field_type_floating_point_create().
1061 A floating point number field type has the following properties:
1066 <th>Value at creation
1071 <td>\b Alignment (bits) of the described floating point
1074 <td>bt_ctf_field_type_get_alignment()
1075 <td>bt_ctf_field_type_set_alignment()
1078 <td><strong>Byte order</strong> of the described floating point
1080 <td>#BT_CTF_BYTE_ORDER_NATIVE
1081 <td>bt_ctf_field_type_get_byte_order()
1082 <td>bt_ctf_field_type_set_byte_order()
1085 <td><strong>Exponent storage size</strong> (bits) of the described
1086 floating point number fields
1088 <td>bt_ctf_field_type_floating_point_get_exponent_digits()
1089 <td>bt_ctf_field_type_floating_point_set_exponent_digits()
1092 <td><strong>Mantissa and sign storage size</strong> (bits) of the
1093 described floating point number fields
1094 <td>24 (23-bit mantissa, 1-bit sign)
1095 <td>bt_ctf_field_type_floating_point_get_mantissa_digits()
1096 <td>bt_ctf_field_type_floating_point_set_mantissa_digits()
1102 @sa \ref ctfirfieldtypesexamples_floatfieldtype "Examples"
1104 @addtogroup ctfirfloatfieldtype
1109 @brief Creates a default @floatft.
1111 @returns Created floating point number field type,
1112 or \c NULL on error.
1114 @postsuccessrefcountret1
1116 extern struct bt_ctf_field_type
*bt_ctf_field_type_floating_point_create(void);
1119 @brief Returns the exponent storage size of the @floatfields
1120 described by the @floatft \p float_field_type.
1122 @param[in] float_field_type Floating point number field type which
1123 describes the floating point number
1124 fields of which to get the exponent
1126 @returns Exponent storage size of the
1127 floating point number fields
1128 described by \p float_field_type,
1129 or a negative value on error.
1131 @prenotnull{float_field_type}
1132 @preisfloatft{float_field_type}
1133 @postrefcountsame{float_field_type}
1135 @sa bt_ctf_field_type_floating_point_set_exponent_digits(): Sets the
1136 exponent storage size of the floating point number fields
1137 described by a given floating point number field type.
1139 extern int bt_ctf_field_type_floating_point_get_exponent_digits(
1140 struct bt_ctf_field_type
*float_field_type
);
1143 @brief Sets the exponent storage size of the @floatfields described by
1144 the @floatft \p float_field_type to \p exponent_size.
1146 As of Babeltrace \btversion, \p exponent_size can only be 8 or 11.
1148 @param[in] float_field_type Floating point number field type which
1149 describes the floating point number
1150 fields of which to set the exponent
1152 @param[in] exponent_size Exponent storage size of the floating
1153 point number fields described by \p
1155 @returns 0 on success, or a negative value on error.
1157 @prenotnull{float_field_type}
1158 @preisfloatft{float_field_type}
1159 @prehot{float_field_type}
1160 @pre \p exponent_size is 8 or 11.
1161 @postrefcountsame{float_field_type}
1163 @sa bt_ctf_field_type_floating_point_get_exponent_digits(): Returns the
1164 exponent storage size of the floating point number fields
1165 described by a given floating point number field type.
1167 extern int bt_ctf_field_type_floating_point_set_exponent_digits(
1168 struct bt_ctf_field_type
*float_field_type
,
1169 unsigned int exponent_size
);
1172 @brief Returns the mantissa and sign storage size of the @floatfields
1173 described by the @floatft \p float_field_type.
1175 On success, the returned value is the sum of the mantissa \em and
1178 @param[in] float_field_type Floating point number field type which
1179 describes the floating point number
1180 fields of which to get the mantissa and
1182 @returns Mantissa and sign storage size of the
1183 floating point number fields
1184 described by \p float_field_type,
1185 or a negative value on error.
1187 @prenotnull{float_field_type}
1188 @preisfloatft{float_field_type}
1189 @postrefcountsame{float_field_type}
1191 @sa bt_ctf_field_type_floating_point_set_mantissa_digits(): Sets the
1192 mantissa and size storage size of the floating point number
1193 fields described by a given floating point number field type.
1195 extern int bt_ctf_field_type_floating_point_get_mantissa_digits(
1196 struct bt_ctf_field_type
*float_field_type
);
1199 @brief Sets the mantissa and sign storage size of the @floatfields
1200 described by the @floatft \p float_field_type to \p
1203 As of Babeltrace \btversion, \p mantissa_sign_size can only be 24 or 53.
1205 @param[in] float_field_type Floating point number field type which
1206 describes the floating point number
1207 fields of which to set the mantissa and
1209 @param[in] mantissa_sign_size Mantissa and sign storage size of the
1210 floating point number fields described
1211 by \p float_field_type.
1212 @returns 0 on success, or a negative value on error.
1214 @prenotnull{float_field_type}
1215 @preisfloatft{float_field_type}
1216 @prehot{float_field_type}
1217 @pre \p mantissa_sign_size is 24 or 53.
1218 @postrefcountsame{float_field_type}
1220 @sa bt_ctf_field_type_floating_point_get_mantissa_digits(): Returns the
1221 mantissa and sign storage size of the floating point number
1222 fields described by a given floating point number field type.
1224 extern int bt_ctf_field_type_floating_point_set_mantissa_digits(
1225 struct bt_ctf_field_type
*float_field_type
,
1226 unsigned int mantissa_sign_size
);
1231 @defgroup ctfirenumfieldtype CTF IR enumeration field type
1232 @ingroup ctfirfieldtypes
1233 @brief CTF IR enumeration field type.
1236 #include <babeltrace/ctf-ir/field-types.h>
1239 A CTF IR <strong><em>enumeration field type</em></strong> is
1240 a field type that you can use to create concrete @enumfields.
1242 You can create an enumeration field type with
1243 bt_ctf_field_type_enumeration_create(). This function needs a @intft
1244 which represents the storage field type of the created enumeration field
1245 type. In other words, an enumeration field type wraps an integer field
1246 type and adds label-value mappings to it.
1248 An enumeration mapping has:
1250 - A <strong>name</strong>.
1251 - A <strong>range of values</strong> given by a beginning and an ending
1252 value, both included in the range.
1254 You can add a mapping to an enumeration field type with
1255 bt_ctf_field_type_enumeration_add_mapping_signed() or
1256 bt_ctf_field_type_enumeration_add_mapping_unsigned(), depending on the
1257 signedness of the wrapped @intft.
1259 You can find mappings by name or by value with the following find
1262 - bt_ctf_field_type_enumeration_find_mappings_by_name(): Finds the
1263 mappings with a given name.
1264 - bt_ctf_field_type_enumeration_find_mappings_by_unsigned_value():
1265 Finds the mappings which contain a given unsigned value in their
1267 - bt_ctf_field_type_enumeration_find_mappings_by_signed_value():
1268 Finds the mappings which contain a given signed value in their range.
1270 Those functions return a @enumftiter on the result set of the find
1273 Many mappings can share the same name, and the ranges of a given
1274 enumeration field type are allowed to overlap. For example,
1275 this is a valid set of mappings:
1284 The following set of mappings is also valid:
1293 Here, the range of the second \c APPLE mapping overlaps the range of
1294 the \c CHERRY mapping.
1296 @sa ctfirenumftmappingiter
1300 @addtogroup ctfirenumfieldtype
1305 @brief Creates a default @enumft wrapping the @intft \p int_field_type.
1307 @param[in] int_field_type Integer field type wrapped by the
1308 created enumeration field type.
1309 @returns Created enumeration field type,
1310 or \c NULL on error.
1312 @prenotnull{int_field_type}
1313 @preisintft{int_field_type}
1314 @postsuccessrefcountinc{int_field_type}
1315 @postsuccessrefcountret1
1317 extern struct bt_ctf_field_type
*bt_ctf_field_type_enumeration_create(
1318 struct bt_ctf_field_type
*int_field_type
);
1321 @brief Returns the @intft wrapped by the @enumft \p enum_field_type.
1323 @param[in] enum_field_type Enumeration field type of which to get
1324 the wrapped integer field type.
1325 @returns Integer field type wrapped by
1326 \p enum_field_type, or \c NULL on
1329 @prenotnull{enum_field_type}
1330 @preisenumft{enum_field_type}
1331 @postrefcountsame{enum_field_type}
1332 @postsuccessrefcountretinc
1335 struct bt_ctf_field_type
*bt_ctf_field_type_enumeration_get_container_type(
1336 struct bt_ctf_field_type
*enum_field_type
);
1339 @brief Returns the number of mappings contained in the
1340 @enumft \p enum_field_type.
1342 @param[in] enum_field_type Enumeration field type of which to get
1343 the number of contained mappings.
1344 @returns Number of mappings contained in
1345 \p enum_field_type, or a negative
1348 @prenotnull{enum_field_type}
1349 @preisenumft{enum_field_type}
1350 @postrefcountsame{enum_field_type}
1352 extern int64_t bt_ctf_field_type_enumeration_get_mapping_count(
1353 struct bt_ctf_field_type
*enum_field_type
);
1356 @brief Returns the signed mapping of the @enumft
1357 \p enum_field_type at index \p index.
1359 The @intft wrapped by \p enum_field_type, as returned by
1360 bt_ctf_field_type_enumeration_get_container_type(), must be \b signed
1361 to use this function.
1363 On success, \p enum_field_type remains the sole owner of \p *name.
1365 @param[in] enum_field_type Enumeration field type of which to get
1366 the mapping at index \p index.
1367 @param[in] index Index of the mapping to get from
1369 @param[out] name Returned name of the mapping at index
1371 @param[out] range_begin Returned beginning of the range
1372 (included) of the mapping at index \p
1374 @param[out] range_end Returned end of the range (included) of
1375 the mapping at index \p index.
1376 @returns 0 on success, or a negative value on error.
1378 @prenotnull{enum_field_type}
1380 @prenotnull{range_begin}
1381 @prenotnull{range_end}
1382 @preisenumft{enum_field_type}
1383 @pre The wrapped @intft of \p enum_field_type is signed.
1384 @pre \p index is lesser than the number of mappings contained in the
1385 enumeration field type \p enum_field_type (see
1386 bt_ctf_field_type_enumeration_get_mapping_count()).
1387 @postrefcountsame{enum_field_type}
1389 @sa bt_ctf_field_type_enumeration_get_mapping_unsigned(): Returns the
1390 unsigned mapping contained by a given enumeration field type
1393 extern int bt_ctf_field_type_enumeration_get_mapping_signed(
1394 struct bt_ctf_field_type
*enum_field_type
, uint64_t index
,
1395 const char **name
, int64_t *range_begin
, int64_t *range_end
);
1398 @brief Returns the unsigned mapping of the @enumft
1399 \p enum_field_type at index \p index.
1401 The @intft wrapped by \p enum_field_type, as returned by
1402 bt_ctf_field_type_enumeration_get_container_type(), must be
1403 \b unsigned to use this function.
1405 On success, \p enum_field_type remains the sole owner of \p *name.
1407 @param[in] enum_field_type Enumeration field type of which to get
1408 the mapping at index \p index.
1409 @param[in] index Index of the mapping to get from
1411 @param[out] name Returned name of the mapping at index
1413 @param[out] range_begin Returned beginning of the range
1414 (included) of the mapping at index \p
1416 @param[out] range_end Returned end of the range (included) of
1417 the mapping at index \p index.
1418 @returns 0 on success, or a negative value on error.
1420 @prenotnull{enum_field_type}
1422 @prenotnull{range_begin}
1423 @prenotnull{range_end}
1424 @preisenumft{enum_field_type}
1425 @pre The wrapped @intft of \p enum_field_type is unsigned.
1426 @pre \p index is lesser than the number of mappings contained in the
1427 enumeration field type \p enum_field_type (see
1428 bt_ctf_field_type_enumeration_get_mapping_count()).
1429 @postrefcountsame{enum_field_type}
1431 @sa bt_ctf_field_type_enumeration_get_mapping_signed(): Returns the
1432 signed mapping contained by a given enumeration field type
1435 extern int bt_ctf_field_type_enumeration_get_mapping_unsigned(
1436 struct bt_ctf_field_type
*enum_field_type
, uint64_t index
,
1437 const char **name
, uint64_t *range_begin
,
1438 uint64_t *range_end
);
1441 @brief Finds the mappings of the @enumft \p enum_field_type which
1444 This function returns an iterator on the result set of this find
1445 operation. See \ref ctfirenumftmappingiter for more details.
1447 @param[in] enum_field_type Enumeration field type of which to find
1448 the mappings named \p name.
1449 @param[in] name Name of the mappings to find in
1451 @returns @enumftiter on the set of mappings named
1452 \p name in \p enum_field_type, or
1453 \c NULL if no mappings were found or
1456 @prenotnull{enum_field_type}
1458 @preisenumft{enum_field_type}
1459 @postrefcountsame{enum_field_type}
1460 @postsuccessrefcountret1
1461 @post <strong>On success</strong>, the returned @enumftiter can iterate
1462 on at least one mapping.
1464 @sa bt_ctf_field_type_enumeration_find_mappings_by_signed_value(): Finds
1465 the mappings of a given enumeration field type which contain
1466 a given signed value in their range.
1467 @sa bt_ctf_field_type_enumeration_find_mappings_by_unsigned_value(): Finds
1468 the mappings of a given enumeration field type which contain
1469 a given unsigned value in their range.
1471 extern struct bt_ctf_field_type_enumeration_mapping_iterator
*
1472 bt_ctf_field_type_enumeration_find_mappings_by_name(
1473 struct bt_ctf_field_type
*enum_field_type
,
1477 @brief Finds the mappings of the @enumft \p enum_field_type which
1478 contain the signed value \p value in their range.
1480 This function returns an iterator on the result set of this find
1481 operation. See \ref ctfirenumftmappingiter for more details.
1483 @param[in] enum_field_type Enumeration field type of which to find
1484 the mappings which contain \p value.
1485 @param[in] value Value to find in the ranges of the
1486 mappings of \p enum_field_type.
1487 @returns @enumftiter on the set of mappings of
1488 \p enum_field_type which contain
1489 \p value in their range, or \c NULL if
1490 no mappings were found or on error.
1492 @prenotnull{enum_field_type}
1493 @preisenumft{enum_field_type}
1494 @postrefcountsame{enum_field_type}
1495 @postsuccessrefcountret1
1496 @post <strong>On success</strong>, the returned @enumftiter can iterate
1497 on at least one mapping.
1499 @sa bt_ctf_field_type_enumeration_find_mappings_by_name(): Finds the
1500 mappings of a given enumeration field type which have a given
1502 @sa bt_ctf_field_type_enumeration_find_mappings_by_unsigned_value(): Finds
1503 the mappings of a given enumeration field type which contain
1504 a given unsigned value in their range.
1506 extern struct bt_ctf_field_type_enumeration_mapping_iterator
*
1507 bt_ctf_field_type_enumeration_find_mappings_by_signed_value(
1508 struct bt_ctf_field_type
*enum_field_type
,
1512 @brief Finds the mappings of the @enumft \p enum_field_type which
1513 contain the unsigned value \p value in their range.
1515 This function returns an iterator on the result set of this find
1516 operation. See \ref ctfirenumftmappingiter for more details.
1518 @param[in] enum_field_type Enumeration field type of which to find
1519 the mappings which contain \p value.
1520 @param[in] value Value to find in the ranges of the
1521 mappings of \p enum_field_type.
1522 @returns @enumftiter on the set of mappings of
1523 \p enum_field_type which contain
1524 \p value in their range, or \c NULL
1525 if no mappings were found or
1528 @prenotnull{enum_field_type}
1529 @preisenumft{enum_field_type}
1530 @postrefcountsame{enum_field_type}
1531 @postsuccessrefcountret1
1532 @post <strong>On success</strong>, the returned @enumftiter can iterate
1533 on at least one mapping.
1535 @sa bt_ctf_field_type_enumeration_find_mappings_by_name(): Finds the
1536 mappings of a given enumeration field type which have a given
1538 @sa bt_ctf_field_type_enumeration_find_mappings_by_signed_value(): Finds
1539 the mappings of a given enumeration field type which contain
1540 a given unsigned value in their range.
1542 extern struct bt_ctf_field_type_enumeration_mapping_iterator
*
1543 bt_ctf_field_type_enumeration_find_mappings_by_unsigned_value(
1544 struct bt_ctf_field_type
*enum_field_type
,
1548 @brief Adds a mapping to the @enumft \p enum_field_type which maps the
1549 name \p name to the signed range \p range_begin (included) to
1550 \p range_end (included).
1552 Make \p range_begin and \p range_end the same value to add a mapping
1555 The @intft wrapped by \p enum_field_type, as returned by
1556 bt_ctf_field_type_enumeration_get_container_type(), must be
1557 \b signed to use this function.
1559 A mapping in \p enum_field_type can exist with the name \p name.
1561 @param[in] enum_field_type Enumeration field type to which to add
1563 @param[in] name Name of the mapping to add (copied
1565 @param[in] range_begin Beginning of the range of the mapping
1567 @param[in] range_end End of the range of the mapping
1569 @returns 0 on success, or a negative value on error.
1571 @prenotnull{enum_field_type}
1573 @prehot{enum_field_type}
1574 @preisenumft{enum_field_type}
1575 @pre The wrapped @intft of \p enum_field_type is signed.
1576 @pre \p range_end is greater than or equal to \p range_begin.
1577 @postrefcountsame{enum_field_type}
1579 @sa bt_ctf_field_type_enumeration_add_mapping_unsigned(): Adds an
1580 unsigned mapping to a given enumeration field type.
1582 extern int bt_ctf_field_type_enumeration_add_mapping_signed(
1583 struct bt_ctf_field_type
*enum_field_type
, const char *name
,
1584 int64_t range_begin
, int64_t range_end
);
1586 /* Pre-2.0 CTF writer compatibility */
1587 #define bt_ctf_field_type_enumeration_add_mapping bt_ctf_field_type_enumeration_add_mapping_signed
1590 @brief Adds a mapping to the @enumft \p enum_field_type which maps
1591 the name \p name to the unsigned
1592 range \p range_begin (included) to \p range_end (included).
1594 Make \p range_begin and \p range_end the same value to add a mapping
1597 The @intft wrapped by \p enum_field_type, as returned by
1598 bt_ctf_field_type_enumeration_get_container_type(), must be
1599 \b unsigned to use this function.
1601 A mapping in \p enum_field_type can exist with the name \p name.
1603 @param[in] enum_field_type Enumeration field type to which to add
1605 @param[in] name Name of the mapping to add (copied
1607 @param[in] range_begin Beginning of the range of the mapping
1609 @param[in] range_end End of the range of the mapping
1611 @returns 0 on success, or a negative value on error.
1613 @prenotnull{enum_field_type}
1615 @prehot{enum_field_type}
1616 @preisenumft{enum_field_type}
1617 @pre The wrapped @intft of \p enum_field_type is unsigned.
1618 @pre \p range_end is greater than or equal to \p range_begin.
1619 @postrefcountsame{enum_field_type}
1621 @sa bt_ctf_field_type_enumeration_add_mapping_signed(): Adds a signed
1622 mapping to a given enumeration field type.
1624 extern int bt_ctf_field_type_enumeration_add_mapping_unsigned(
1625 struct bt_ctf_field_type
*enum_field_type
, const char *name
,
1626 uint64_t range_begin
, uint64_t range_end
);
1631 @defgroup ctfirenumftmappingiter CTF IR enumeration field type mapping iterator
1632 @ingroup ctfirenumfieldtype
1633 @brief CTF IR enumeration field type mapping iterator.
1636 #include <babeltrace/ctf-ir/field-types.h>
1639 A CTF IR <strong><em>enumeration field type mapping
1640 iterator</em></strong> is an iterator on @enumft mappings.
1642 You can get an enumeration mapping iterator from one of the following
1645 - Find operations of an @enumft object:
1646 - bt_ctf_field_type_enumeration_find_mappings_by_name(): Finds the
1647 mappings with a given name.
1648 - bt_ctf_field_type_enumeration_find_mappings_by_unsigned_value():
1649 Finds the mappings which contain a given unsigned value in their
1651 - bt_ctf_field_type_enumeration_find_mappings_by_signed_value():
1652 Finds the mappings which contain a given signed value in their range.
1653 - bt_ctf_field_enumeration_get_mappings(): Finds the mappings in the
1654 @enumft of an @enumfield containing its current integral value in
1657 Those functions guarantee that the returned iterator can iterate on
1658 at least one mapping. Otherwise, they return \c NULL.
1660 You can get the name and the range of a mapping iterator's current
1662 bt_ctf_field_type_enumeration_mapping_iterator_get_signed()
1664 bt_ctf_field_type_enumeration_mapping_iterator_get_unsigned(),
1665 depending on the signedness of the @intft wrapped by the
1666 @enumft. If you only need the name of the current mapping, you can
1667 use any of the two functions and set the \p range_begin and \p range_end
1668 parameters to \c NULL.
1670 You can advance an enumeration field type mapping iterator to the next
1672 bt_ctf_field_type_enumeration_mapping_iterator_next(). This
1673 function returns a negative value when you reach the end of the
1676 As with any Babeltrace object, CTF IR enumeration field type mapping
1677 iterator objects have <a
1678 href="https://en.wikipedia.org/wiki/Reference_counting">reference
1679 counts</a>. See \ref refs to learn more about the reference counting
1680 management of Babeltrace objects.
1682 @sa ctfirenumfieldtype
1684 @addtogroup ctfirenumftmappingiter
1689 @struct bt_ctf_field_type_enumeration_mapping_iterator
1690 @brief A CTF IR enumeration field type mapping iterator.
1691 @sa ctfirenumftmappingiter
1695 @brief Returns the name and the range of the current (signed) mapping
1696 of the @enumftiter \p iter.
1698 If one of \p range_begin or \p range_end is not \c NULL, the @intft
1699 wrapped by the @enumft from which \p iter was obtained, as returned by
1700 bt_ctf_field_type_enumeration_get_container_type(), must be
1701 \b signed to use this function. Otherwise, if you only need to get the
1702 name of the current mapping, set \p range_begin and \p range_end to
1705 On success, if \p name is not \c NULL, \p *name remains valid as long
1706 as \p iter exists and
1707 bt_ctf_field_type_enumeration_mapping_iterator_next() is
1708 \em not called on \p iter.
1710 @param[in] iter Enumeration field type mapping iterator
1711 of which to get the range of the current
1713 @param[out] name Returned name of the current mapping of
1714 \p iter (can be \c NULL to ignore).
1715 @param[out] range_begin Returned beginning of the range
1716 (included) of the current mapping of
1717 \p iter (can be \c NULL to ignore).
1718 @param[out] range_end Returned end of the range
1719 (included) of the current mapping of
1720 \p iter (can be \c NULL to ignore).
1721 @returns 0 on success, or a negative value on error.
1724 @postrefcountsame{iter}
1726 @sa bt_ctf_field_type_enumeration_mapping_iterator_get_unsigned():
1727 Returns the name and the unsigned range of the current mapping
1728 of a given enumeration field type mapping iterator.
1730 extern int bt_ctf_field_type_enumeration_mapping_iterator_get_signed(
1731 struct bt_ctf_field_type_enumeration_mapping_iterator
*iter
,
1732 const char **name
, int64_t *range_begin
, int64_t *range_end
);
1735 @brief Returns the name and the range of the current (unsigned) mapping
1736 of the @enumftiter \p iter.
1738 If one of \p range_begin or \p range_end is not \c NULL, the @intft
1739 wrapped by the @enumft from which \p iter was obtained, as returned by
1740 bt_ctf_field_type_enumeration_get_container_type(), must be
1741 \b unsigned to use this function. Otherwise, if you only need to get the
1742 name of the current mapping, set \p range_begin and \p range_end to
1745 On success, if \p name is not \c NULL, \p *name remains valid as long
1746 as \p iter exists and
1747 bt_ctf_field_type_enumeration_mapping_iterator_next() is
1748 \em not called on \p iter.
1750 @param[in] iter Enumeration field type mapping iterator
1751 of which to get the range of the current
1753 @param[out] name Returned name of the current mapping of
1754 \p iter (can be \c NULL to ignore).
1755 @param[out] range_begin Returned beginning of the range
1756 (included) of the current mapping of
1757 \p iter (can be \c NULL to ignore).
1758 @param[out] range_end Returned end of the range
1759 (included) of the current mapping of
1760 \p iter (can be \c NULL to ignore).
1761 @returns 0 on success, or a negative value on error.
1764 @postrefcountsame{iter}
1767 bt_ctf_field_type_enumeration_mapping_iterator_get_signed():
1768 Returns the name and the signed range of the current mapping of
1769 a given enumeration field type mapping iterator.
1771 extern int bt_ctf_field_type_enumeration_mapping_iterator_get_unsigned(
1772 struct bt_ctf_field_type_enumeration_mapping_iterator
*iter
,
1773 const char **name
, uint64_t *range_begin
, uint64_t *range_end
);
1776 @brief Advances the @enumftiter \p iter to the next mapping.
1778 @param[in] iter Enumeration field type mapping iterator to
1780 @returns 0 on success, or a negative value on error or
1781 when you reach the end of the set.
1784 @postrefcountsame{iter}
1786 extern int bt_ctf_field_type_enumeration_mapping_iterator_next(
1787 struct bt_ctf_field_type_enumeration_mapping_iterator
*iter
);
1792 @defgroup ctfirstringfieldtype CTF IR string field type
1793 @ingroup ctfirfieldtypes
1794 @brief CTF IR string field type.
1797 #include <babeltrace/ctf-ir/field-types.h>
1800 A CTF IR <strong><em>string field type</em></strong> is a field type that
1801 you can use to create concrete @stringfields.
1803 You can create a string field type
1804 with bt_ctf_field_type_string_create().
1806 A string field type has only one property: the \b encoding of its
1807 described @stringfields. By default, the encoding of the string fields
1808 described by a string field type is #BT_CTF_STRING_ENCODING_UTF8. You
1809 can set the encoding of the string fields described by a string field
1810 type with bt_ctf_field_type_string_set_encoding().
1812 @sa ctfirstringfield
1815 @addtogroup ctfirstringfieldtype
1820 @brief Creates a default @stringft.
1822 @returns Created string field type, or \c NULL on error.
1824 @postsuccessrefcountret1
1826 extern struct bt_ctf_field_type
*bt_ctf_field_type_string_create(void);
1829 @brief Returns the encoding of the @stringfields described by
1830 the @stringft \p string_field_type.
1832 @param[in] string_field_type String field type which describes the
1833 string fields of which to get the
1835 @returns Encoding of the string
1836 fields described by \p string_field_type,
1837 or #BT_CTF_STRING_ENCODING_UNKNOWN on
1840 @prenotnull{string_field_type}
1841 @preisstringft{string_field_type}
1842 @postrefcountsame{string_field_type}
1844 @sa bt_ctf_field_type_string_set_encoding(): Sets the encoding
1845 of the string fields described by a given string field type.
1847 extern enum bt_ctf_string_encoding
bt_ctf_field_type_string_get_encoding(
1848 struct bt_ctf_field_type
*string_field_type
);
1851 @brief Sets the encoding of the @stringfields described by the
1852 @stringft \p string_field_type to \p encoding.
1854 @param[in] string_field_type String field type which describes the
1855 string fields of which to set the
1857 @param[in] encoding Encoding of the string fields described
1858 by \p string_field_type.
1859 @returns 0 on success, or a negative value on error.
1861 @prenotnull{string_field_type}
1862 @preisstringft{string_field_type}
1863 @prehot{string_field_type}
1864 @pre \p encoding is #BT_CTF_STRING_ENCODING_ASCII or
1865 #BT_CTF_STRING_ENCODING_UTF8.
1866 @postrefcountsame{string_field_type}
1868 @sa bt_ctf_field_type_string_get_encoding(): Returns the encoding of
1869 the string fields described by a given string field type.
1871 extern int bt_ctf_field_type_string_set_encoding(
1872 struct bt_ctf_field_type
*string_field_type
,
1873 enum bt_ctf_string_encoding encoding
);
1878 @defgroup ctfirstructfieldtype CTF IR structure field type
1879 @ingroup ctfirfieldtypes
1880 @brief CTF IR structure field type.
1883 #include <babeltrace/ctf-ir/field-types.h>
1886 A CTF IR <strong><em>structure field type</em></strong> is
1887 a field type that you can use to create concrete @structfields.
1889 You can create a structure field type
1890 with bt_ctf_field_type_structure_create(). This function creates
1891 an empty structure field type, with no fields.
1893 You can add a field to a structure field type with
1894 bt_ctf_field_type_structure_add_field(). Two fields in a structure
1895 field type cannot have the same name.
1897 You can set the \em minimum alignment of the structure fields described
1898 by a structure field type with the common
1899 bt_ctf_field_type_set_alignment() function. The \em effective alignment
1900 of the structure fields described by a structure field type, as per
1901 <a href="http://diamon.org/ctf/">CTF</a>, is the \em maximum value amongst
1902 the effective alignments of all its fields. Note that the effective
1903 alignment of @varfields is always 1.
1905 You can set the byte order of <em>all the contained fields</em>,
1906 recursively, of a structure field type with the common
1907 bt_ctf_field_type_set_byte_order() function.
1909 @sa ctfirstructfield
1912 @addtogroup ctfirstructfieldtype
1917 @brief Creates a default, empty @structft.
1919 @returns Created structure field type,
1920 or \c NULL on error.
1922 @postsuccessrefcountret1
1924 extern struct bt_ctf_field_type
*bt_ctf_field_type_structure_create(void);
1927 @brief Returns the number of fields contained in the
1928 @structft \p struct_field_type.
1930 @param[in] struct_field_type Structure field type of which to get
1931 the number of contained fields.
1932 @returns Number of fields contained in
1933 \p struct_field_type, or a negative
1936 @prenotnull{struct_field_type}
1937 @preisstructft{struct_field_type}
1938 @postrefcountsame{struct_field_type}
1940 extern int64_t bt_ctf_field_type_structure_get_field_count(
1941 struct bt_ctf_field_type
*struct_field_type
);
1944 @brief Returns the field of the @structft \p struct_field_type
1947 On success, the field's type is placed in \p *field_type if
1948 \p field_type is not \c NULL. The field's name is placed in
1949 \p *field_name if \p field_name is not \c NULL.
1950 \p struct_field_type remains the sole owner of \p *field_name.
1952 @param[in] struct_field_type Structure field type of which to get
1953 the field at index \p index.
1954 @param[out] field_name Returned name of the field at index
1955 \p index (can be \c NULL).
1956 @param[out] field_type Returned field type of the field
1957 at index \p index (can be \c NULL).
1958 @param[in] index Index of the field to get from
1959 \p struct_field_type.
1960 @returns 0 on success, or a negative value on error.
1962 @prenotnull{struct_field_type}
1963 @preisstructft{struct_field_type}
1964 @pre \p index is lesser than the number of fields contained in the
1965 structure field type \p struct_field_type (see
1966 bt_ctf_field_type_structure_get_field_count()).
1967 @postrefcountsame{struct_field_type}
1968 @post <strong>On success</strong>, the returned field's type is placed
1969 in \p *field_type and its reference count is incremented.
1971 @sa bt_ctf_field_type_structure_get_field_type_by_name(): Finds a
1972 structure field type's field by name.
1974 extern int bt_ctf_field_type_structure_get_field_by_index(
1975 struct bt_ctf_field_type
*struct_field_type
,
1976 const char **field_name
, struct bt_ctf_field_type
**field_type
,
1979 /* Pre-2.0 CTF writer compatibility */
1980 #define bt_ctf_field_type_structure_get_field bt_ctf_field_type_structure_get_field_by_index
1983 @brief Returns the type of the field named \p field_name found in
1984 the @structft \p struct_field_type.
1986 @param[in] struct_field_type Structure field type of which to get
1988 @param[in] field_name Name of the field to find.
1989 @returns Type of the field named \p field_name in
1990 \p struct_field_type, or
1993 @prenotnull{struct_field_type}
1994 @prenotnull{field_name}
1995 @preisstructft{struct_field_type}
1996 @postrefcountsame{struct_field_type}
1997 @postsuccessrefcountretinc
1999 @sa bt_ctf_field_type_structure_get_field_by_index(): Finds a
2000 structure field type's field by index.
2003 struct bt_ctf_field_type
*bt_ctf_field_type_structure_get_field_type_by_name(
2004 struct bt_ctf_field_type
*struct_field_type
,
2005 const char *field_name
);
2008 @brief Adds a field named \p field_name with the @ft
2009 \p field_type to the @structft \p struct_field_type.
2011 On success, \p field_type becomes the child of \p struct_field_type.
2013 This function adds the new field after the current last field of
2014 \p struct_field_type (append mode).
2016 You \em cannot add a field named \p field_name if there's already a
2017 field named \p field_name in \p struct_field_type.
2019 @param[in] struct_field_type Structure field type to which to add
2021 @param[in] field_type Field type of the field to add to
2022 \p struct_field_type.
2023 @param[in] field_name Name of the field to add to
2024 \p struct_field_type
2025 (copied on success).
2026 @returns 0 on success, or a negative value on error.
2028 @prenotnull{struct_field_type}
2029 @prenotnull{field_type}
2030 @prenotnull{field_name}
2031 @preisstructft{struct_field_type}
2032 @pre \p field_type is not and does not contain \p struct_field_type,
2033 recursively, as a field's type.
2034 @prehot{struct_field_type}
2035 @postrefcountsame{struct_field_type}
2036 @postsuccessrefcountinc{field_type}
2038 extern int bt_ctf_field_type_structure_add_field(
2039 struct bt_ctf_field_type
*struct_field_type
,
2040 struct bt_ctf_field_type
*field_type
,
2041 const char *field_name
);
2046 @defgroup ctfirarrayfieldtype CTF IR array field type
2047 @ingroup ctfirfieldtypes
2048 @brief CTF IR array field type.
2051 #include <babeltrace/ctf-ir/field-types.h>
2054 A CTF IR <strong><em>array field type</em></strong> is a field type that
2055 you can use to create concrete @arrayfields.
2057 You can create an array field type
2058 with bt_ctf_field_type_array_create(). This function needs
2059 the @ft of the fields contained by the array fields described by the
2060 array field type to create.
2065 @addtogroup ctfirarrayfieldtype
2070 @brief Creates a default @arrayft with
2071 \p element_field_type as the field type of the fields contained
2072 in its described @arrayfields of length \p length.
2074 @param[in] element_field_type Field type of the fields contained in
2075 the array fields described by the
2076 created array field type.
2077 @param[in] length Length of the array fields described by
2078 the created array field type.
2079 @returns Created array field type, or
2082 @prenotnull{element_field_type}
2083 @postsuccessrefcountinc{element_field_type}
2084 @postsuccessrefcountret1
2086 extern struct bt_ctf_field_type
*bt_ctf_field_type_array_create(
2087 struct bt_ctf_field_type
*element_field_type
,
2088 unsigned int length
);
2091 @brief Returns the @ft of the @fields contained in
2092 the @arrayfields described by the @arrayft \p array_field_type.
2094 @param[in] array_field_type Array field type of which to get
2095 the type of the fields contained in its
2096 described array fields.
2097 @returns Type of the fields contained in the
2098 array fields described by
2099 \p array_field_type, or \c NULL
2102 @prenotnull{array_field_type}
2103 @preisarrayft{array_field_type}
2104 @postrefcountsame{array_field_type}
2105 @postsuccessrefcountretinc
2107 extern struct bt_ctf_field_type
*bt_ctf_field_type_array_get_element_type(
2108 struct bt_ctf_field_type
*array_field_type
);
2111 @brief Returns the number of @fields contained in the
2112 @arrayfields described by the @arrayft \p array_field_type.
2114 @param[in] array_field_type Array field type of which to get
2115 the number of fields contained in its
2116 described array fields.
2117 @returns Number of fields contained in the
2118 array fields described by
2119 \p array_field_type, or a negative value
2122 @prenotnull{array_field_type}
2123 @preisarrayft{array_field_type}
2124 @postrefcountsame{array_field_type}
2126 extern int64_t bt_ctf_field_type_array_get_length(
2127 struct bt_ctf_field_type
*array_field_type
);
2132 @defgroup ctfirseqfieldtype CTF IR sequence field type
2133 @ingroup ctfirfieldtypes
2134 @brief CTF IR sequence field type.
2137 #include <babeltrace/ctf-ir/field-types.h>
2140 A CTF IR <strong><em>sequence field type</em></strong> is
2141 a field type that you can use to create concrete @seqfields.
2143 You can create a sequence field type with
2144 bt_ctf_field_type_sequence_create(). This function needs the @ft
2145 of the fields contained by the sequence fields described by the created
2146 sequence field type. This function also needs the length name of the
2147 sequence field type to create. The length name is used to automatically
2148 resolve the length's field type. See \ref ctfirfieldtypes to learn more
2149 about the automatic resolving.
2154 @addtogroup ctfirseqfieldtype
2159 @brief Creates a default @seqft with \p element_field_type as the
2160 @ft of the @fields contained in its described @seqfields
2161 with the length name \p length_name.
2163 \p length_name can be an absolute or relative reference. See
2164 <a href="http://diamon.org/ctf/">CTF</a> for more details.
2166 @param[in] element_field_type Field type of the fields contained in
2167 the sequence fields described by the
2168 created sequence field type.
2169 @param[in] length_name Length name (copied on success).
2170 @returns Created array field type, or
2173 @prenotnull{element_field_type}
2174 @prenotnull{length_name}
2175 @postsuccessrefcountinc{element_field_type}
2176 @postsuccessrefcountret1
2178 extern struct bt_ctf_field_type
*bt_ctf_field_type_sequence_create(
2179 struct bt_ctf_field_type
*element_field_type
,
2180 const char *length_name
);
2183 @brief Returns the @ft of the @fields contained in the @seqft
2184 described by the @seqft \p sequence_field_type.
2186 @param[in] sequence_field_type Sequence field type of which to get
2187 the type of the fields contained in its
2188 described sequence fields.
2189 @returns Type of the fields contained in the
2190 sequence fields described by
2191 \p sequence_field_type, or \c NULL
2194 @prenotnull{sequence_field_type}
2195 @preisseqft{sequence_field_type}
2196 @postrefcountsame{sequence_field_type}
2197 @postsuccessrefcountretinc
2199 extern struct bt_ctf_field_type
*bt_ctf_field_type_sequence_get_element_type(
2200 struct bt_ctf_field_type
*sequence_field_type
);
2203 @brief Returns the length name of the @seqft \p sequence_field_type.
2205 On success, \p sequence_field_type remains the sole owner of
2206 the returned string.
2208 @param[in] sequence_field_type Sequence field type of which to get the
2210 @returns Length name of \p sequence_field_type,
2211 or \c NULL on error.
2213 @prenotnull{sequence_field_type}
2214 @preisseqft{sequence_field_type}
2216 @sa bt_ctf_field_type_sequence_get_length_field_path(): Returns the
2217 length's CTF IR field path of a given sequence field type.
2219 extern const char *bt_ctf_field_type_sequence_get_length_field_name(
2220 struct bt_ctf_field_type
*sequence_field_type
);
2223 @brief Returns the length's CTF IR field path of the @seqft
2224 \p sequence_field_type.
2226 The length's field path of a sequence field type is set when automatic
2227 resolving is performed (see \ref ctfirfieldtypes).
2229 @param[in] sequence_field_type Sequence field type of which to get the
2230 length's field path.
2231 @returns Length's field path of
2232 \p sequence_field_type, or
2233 \c NULL if the length's field path is
2234 not set yet is not set or on error.
2236 @prenotnull{sequence_field_type}
2237 @preisseqft{sequence_field_type}
2238 @postsuccessrefcountretinc
2240 @sa bt_ctf_field_type_sequence_get_length_field_name(): Returns the
2241 length's name of a given sequence field type.
2243 extern struct bt_ctf_field_path
*bt_ctf_field_type_sequence_get_length_field_path(
2244 struct bt_ctf_field_type
*sequence_field_type
);
2249 @defgroup ctfirvarfieldtype CTF IR variant field type
2250 @ingroup ctfirfieldtypes
2251 @brief CTF IR variant field type.
2254 #include <babeltrace/ctf-ir/field-types.h>
2257 A CTF IR <strong><em>variant field type</em></strong> is
2258 a field type that you can use to create concrete @varfields.
2260 You can create a variant field type with
2261 bt_ctf_field_type_variant_create(). This function expects you to pass
2262 both the tag's @enumft and the tag name of the variant field type to
2263 create. The tag's field type is optional, as the Babeltrace system can
2264 automatically resolve it using the tag name. You can leave the tag name
2265 to \c NULL initially, and set it later with
2266 bt_ctf_field_type_variant_set_tag_name(). The tag name must be set when
2267 the variant field type is frozen. See \ref ctfirfieldtypes to learn more
2268 about the automatic resolving and the conditions under which a field
2271 You can add a field to a variant field type with
2272 bt_ctf_field_type_variant_add_field(). All the field names of a
2273 variant field type \em must exist as mapping names in its tag's @enumft.
2275 The effective alignment of the @varfields described by a
2276 variant field type is always 1, but the individual fields of a
2277 @varfield can have custom alignments.
2279 You can set the byte order of <em>all the contained fields</em>,
2280 recursively, of a variant field type with the common
2281 bt_ctf_field_type_set_byte_order() function.
2286 @addtogroup ctfirvarfieldtype
2291 @brief Creates a default, empty @varft with the tag's @enumft
2292 \p tag_field_type and the tag name \p tag_name.
2294 \p tag_field_type can be \c NULL; the tag's field type can be
2295 automatically resolved from the variant field type's tag name (see
2296 \ref ctfirfieldtypes). If \p tag_name is \c NULL, it \em must be set
2297 with bt_ctf_field_type_variant_set_tag_name() \em before the variant
2298 field type is frozen.
2300 \p tag_name can be an absolute or relative reference. See
2301 <a href="http://diamon.org/ctf/">CTF</a> for more details.
2303 @param[in] tag_field_type Tag's enumeration field type
2305 @param[in] tag_name Tag name (copied on success,
2307 @returns Created variant field type, or
2310 @pre \p tag_field_type is an enumeration field type or \c NULL.
2311 @post <strong>On success, if \p tag_field_type is not \c NULL</strong>,
2312 its reference count is incremented.
2313 @postsuccessrefcountret1
2315 extern struct bt_ctf_field_type
*bt_ctf_field_type_variant_create(
2316 struct bt_ctf_field_type
*tag_field_type
,
2317 const char *tag_name
);
2320 @brief Returns the tag's @enumft of the @varft \p variant_field_type.
2322 @param[in] variant_field_type Variant field type of which to get
2323 the tag's enumeration field type.
2324 @returns Tag's enumeration field type of
2325 \p variant_field_type, or \c NULL if the
2326 tag's field type is not set or on
2329 @prenotnull{variant_field_type}
2330 @preisvarft{variant_field_type}
2331 @postrefcountsame{variant_field_type}
2332 @postsuccessrefcountretinc
2334 extern struct bt_ctf_field_type
*bt_ctf_field_type_variant_get_tag_type(
2335 struct bt_ctf_field_type
*variant_field_type
);
2338 @brief Returns the tag name of the @varft \p variant_field_type.
2340 On success, \p variant_field_type remains the sole owner of
2341 the returned string.
2343 @param[in] variant_field_type Variant field type of which to get the
2345 @returns Tag name of \p variant_field_type, or
2346 \c NULL if the tag name is not set or
2349 @prenotnull{variant_field_type}
2350 @preisvarft{variant_field_type}
2352 @sa bt_ctf_field_type_variant_set_tag_name(): Sets the tag name of
2353 a given variant field type.
2354 @sa bt_ctf_field_type_variant_get_tag_field_path(): Returns the tag's
2355 CTF IR field path of a given variant field type.
2357 extern const char *bt_ctf_field_type_variant_get_tag_name(
2358 struct bt_ctf_field_type
*variant_field_type
);
2361 @brief Sets the tag name of the @varft \p variant_field_type.
2363 \p tag_name can be an absolute or relative reference. See
2364 <a href="http://diamon.org/ctf/">CTF</a> for more details.
2366 @param[in] variant_field_type Variant field type of which to set
2368 @param[in] tag_name Tag name of \p variant_field_type
2369 (copied on success).
2370 @returns 0 on success, or a negative value on error.
2372 @prenotnull{variant_field_type}
2374 @prehot{variant_field_type}
2375 @postrefcountsame{variant_field_type}
2377 @sa bt_ctf_field_type_variant_get_tag_name(): Returns the tag name of
2378 a given variant field type.
2380 extern int bt_ctf_field_type_variant_set_tag_name(
2381 struct bt_ctf_field_type
*variant_field_type
,
2382 const char *tag_name
);
2385 @brief Returns the tag's CTF IR field path of the @varft
2386 \p variant_field_type.
2388 The tag's field path of a variant field type is set when automatic
2389 resolving is performed (see \ref ctfirfieldtypes).
2391 @param[in] variant_field_type Variant field type of which to get the
2393 @returns Tag's field path of
2394 \p variant_field_type, or
2395 \c NULL if the tag's field path is not
2396 set yet is not set or on error.
2398 @prenotnull{variant_field_type}
2399 @preisvarft{variant_field_type}
2400 @postsuccessrefcountretinc
2402 @sa bt_ctf_field_type_variant_get_tag_name(): Returns the tag's
2403 name of a given variant field type.
2405 extern struct bt_ctf_field_path
*bt_ctf_field_type_variant_get_tag_field_path(
2406 struct bt_ctf_field_type
*variant_field_type
);
2409 @brief Returns the number of fields (choices) contained in the @varft
2410 \p variant_field_type.
2412 @param[in] variant_field_type Variant field type of which to get
2413 the number of contained fields.
2414 @returns Number of fields contained in
2415 \p variant_field_type, or a negative
2418 @prenotnull{variant_field_type}
2419 @preisvarft{variant_field_type}
2420 @postrefcountsame{variant_field_type}
2422 extern int64_t bt_ctf_field_type_variant_get_field_count(
2423 struct bt_ctf_field_type
*variant_field_type
);
2426 @brief Returns the field (choice) of the @varft \p variant_field_type
2429 On success, the field's type is placed in \p *field_type if
2430 \p field_type is not \c NULL. The field's name is placed in
2431 \p *field_name if \p field_name is not \c NULL.
2432 \p variant_field_type remains the sole owner of \p *field_name.
2434 @param[in] variant_field_type Variant field type of which to get
2435 the field at index \p index.
2436 @param[out] field_name Returned name of the field at index
2437 \p index (can be \c NULL).
2438 @param[out] field_type Returned field type of the field
2439 at index \p index (can be \c NULL).
2440 @param[in] index Index of the field to get from
2441 \p variant_field_type.
2442 @returns 0 on success, or a negative value on error.
2444 @prenotnull{variant_field_type}
2445 @preisvarft{variant_field_type}
2446 @pre \p index is lesser than the number of fields contained in the
2447 variant field type \p variant_field_type (see
2448 bt_ctf_field_type_variant_get_field_count()).
2449 @postrefcountsame{variant_field_type}
2450 @post <strong>On success</strong>, the returned field's type is placed
2451 in \p *field_type and its reference count is incremented.
2453 @sa bt_ctf_field_type_variant_get_field_type_by_name(): Finds a variant
2454 field type's field by name.
2455 @sa bt_ctf_field_type_variant_get_field_type_from_tag(): Finds a variant
2456 field type's field by current tag value.
2458 extern int bt_ctf_field_type_variant_get_field_by_index(
2459 struct bt_ctf_field_type
*variant_field_type
,
2460 const char **field_name
,
2461 struct bt_ctf_field_type
**field_type
, uint64_t index
);
2463 /* Pre-2.0 CTF writer compatibility */
2464 #define bt_ctf_field_type_variant_get_field bt_ctf_field_type_variant_get_field_by_index
2467 @brief Returns the type of the field (choice) named \p field_name
2468 found in the @varft \p variant_field_type.
2470 @param[in] variant_field_type Variant field type of which to get
2472 @param[in] field_name Name of the field to find.
2473 @returns Type of the field named \p field_name in
2474 \p variant_field_type, or
2477 @prenotnull{variant_field_type}
2478 @prenotnull{field_name}
2479 @preisvarft{variant_field_type}
2480 @postrefcountsame{variant_field_type}
2481 @postsuccessrefcountretinc
2483 @sa bt_ctf_field_type_variant_get_field_by_index(): Finds a variant field type's
2485 @sa bt_ctf_field_type_variant_get_field_type_from_tag(): Finds a variant
2486 field type's field by current tag value.
2489 struct bt_ctf_field_type
*bt_ctf_field_type_variant_get_field_type_by_name(
2490 struct bt_ctf_field_type
*variant_field_type
,
2491 const char *field_name
);
2494 @brief Returns the type of the field (choice) selected by the value of
2495 the @enumfield \p tag_field in the @varft \p variant_field_type.
2497 \p tag_field is the current tag value.
2499 The field type of \p tag_field, as returned by bt_ctf_field_get_type(),
2500 \em must be equivalent to the field type returned by
2501 bt_ctf_field_type_variant_get_tag_type() for \p variant_field_type.
2503 @param[in] variant_field_type Variant field type of which to get
2505 @param[in] tag_field Current tag value (variant field type's
2507 @returns Type of the field selected by
2508 \p tag_field in \p variant_field_type,
2509 or \c NULL on error.
2511 @prenotnull{variant_field_type}
2512 @prenotnull{tag_field}
2513 @preisvarft{variant_field_type}
2514 @preisenumfield{tag_field}
2515 @postrefcountsame{variant_field_type}
2516 @postrefcountsame{tag_field}
2517 @postsuccessrefcountretinc
2519 @sa bt_ctf_field_type_variant_get_field_by_index(): Finds a variant field type's
2521 @sa bt_ctf_field_type_variant_get_field_type_by_name(): Finds a variant
2522 field type's field by name.
2525 struct bt_ctf_field_type
*bt_ctf_field_type_variant_get_field_type_from_tag(
2526 struct bt_ctf_field_type
*variant_field_type
,
2527 struct bt_ctf_field
*tag_field
);
2530 @brief Adds a field (a choice) named \p field_name with the @ft
2531 \p field_type to the @varft \p variant_field_type.
2533 On success, \p field_type becomes the child of \p variant_field_type.
2535 You \em cannot add a field named \p field_name if there's already a
2536 field named \p field_name in \p variant_field_type.
2538 \p field_name \em must name an existing mapping in the tag's
2539 enumeration field type of \p variant_field_type.
2541 @param[in] variant_field_type Variant field type to which to add
2543 @param[in] field_type Field type of the field to add to
2544 \p variant_field_type.
2545 @param[in] field_name Name of the field to add to
2546 \p variant_field_type
2547 (copied on success).
2548 @returns 0 on success, or a negative value on error.
2550 @prenotnull{variant_field_type}
2551 @prenotnull{field_type}
2552 @prenotnull{field_name}
2553 @preisvarft{variant_field_type}
2554 @pre \p field_type is not and does not contain \p variant_field_type,
2555 recursively, as a field's type.
2556 @prehot{variant_field_type}
2557 @postrefcountsame{variant_field_type}
2558 @postsuccessrefcountinc{field_type}
2560 extern int bt_ctf_field_type_variant_add_field(
2561 struct bt_ctf_field_type
*variant_field_type
,
2562 struct bt_ctf_field_type
*field_type
,
2563 const char *field_name
);
2571 #endif /* BABELTRACE_CTF_IR_FIELD_TYPES_H */