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
40 @defgroup ctfirfieldtypes CTF IR field types
42 @brief CTF IR field types.
45 #include <babeltrace/ctf-ir/field-types.h>
48 A CTF IR <strong><em>field type</em></strong> is a field type that you
49 can use to create concrete @fields.
51 You can create a @field object from a CTF IR field type object
52 with bt_ctf_field_create().
54 In the CTF IR hierarchy, you can set the root field types of three
57 - \ref ctfirtraceclass
58 - Trace packet header field type: bt_ctf_trace_set_packet_header_type().
59 - \ref ctfirstreamclass
60 - Stream packet context field type:
61 bt_ctf_stream_class_set_packet_context_type().
62 - Stream event header field type:
63 bt_ctf_stream_class_set_event_header_type().
64 - Stream event context field type:
65 bt_ctf_stream_class_set_event_context_type().
66 - \ref ctfireventclass
67 - Event context field type: bt_ctf_event_class_set_context_type().
68 - Event payload field type: bt_ctf_event_class_set_payload_type().
70 As of Babeltrace \btversion, those six previous "root" field types
71 \em must be @structft objects.
73 If, at any level within a given root field type, you add a @seqft or a
74 @varft, you do not need to specify its associated length
75 or tag field type: the length or tag string is enough for the Babeltrace
76 system to resolve the needed field type depending on where this
77 dynamic field type is located within the whole hierarchy. It is
78 guaranteed that this automatic resolving is performed for all the field
79 types contained in a given
80 \link ctfirstreamclass CTF IR stream class\endlink (and in its
81 children \link ctfireventclass CTF IR event classes\endlink) once you
82 add it to a \link ctfirtraceclass CTF IR trace class\endlink with
83 bt_ctf_trace_add_stream_class(). Once a stream class is the child of
84 a trace class, this automatic resolving is performed for the field
85 types of an event class when you add it with
86 bt_ctf_stream_class_add_event_class(). If the system cannot find a path
87 to a field in the hierarchy for a dynamic field type, the adding
90 The standard CTF field types are:
96 <th>CTF IR field which you can create from this field type
99 <td>#BT_CTF_TYPE_ID_INTEGER
100 <td>\ref ctfirintfieldtype
101 <td>\ref ctfirintfield
104 <td>#BT_CTF_TYPE_ID_FLOAT
105 <td>\ref ctfirfloatfieldtype
106 <td>\ref ctfirfloatfield
109 <td>#BT_CTF_TYPE_ID_ENUM
110 <td>\ref ctfirenumfieldtype
111 <td>\ref ctfirenumfield
114 <td>#BT_CTF_TYPE_ID_STRING
115 <td>\ref ctfirstringfieldtype
116 <td>\ref ctfirstringfield
119 <td>#BT_CTF_TYPE_ID_STRUCT
120 <td>\ref ctfirstructfieldtype
121 <td>\ref ctfirstructfield
124 <td>#BT_CTF_TYPE_ID_ARRAY
125 <td>\ref ctfirarrayfieldtype
126 <td>\ref ctfirarrayfield
129 <td>#BT_CTF_TYPE_ID_SEQUENCE
130 <td>\ref ctfirseqfieldtype
131 <td>\ref ctfirseqfield
134 <td>#BT_CTF_TYPE_ID_VARIANT
135 <td>\ref ctfirvarfieldtype
136 <td>\ref ctfirvarfield
140 Each field type has its own <strong>type ID</strong> (see
141 #bt_ctf_type_id). You get the type ID of a field type object
142 with bt_ctf_field_type_get_type_id().
144 You can get a deep copy of a field type with bt_ctf_field_type_copy().
145 This function resets, in the field type copy, the resolved field type
146 of the dynamic field types. The automatic resolving can be done again
147 when you eventually call bt_ctf_event_create(),
148 bt_ctf_stream_class_add_event_class(), or
149 bt_ctf_trace_add_stream_class().
151 You \em must always use bt_ctf_field_type_compare() to compare two
152 field types. Since some parts of the Babeltrace system can copy field
153 types behind the scenes, you \em cannot rely on a simple field type
156 As with any Babeltrace object, CTF IR field type objects have
157 <a href="https://en.wikipedia.org/wiki/Reference_counting">reference
158 counts</a>. See \ref refs to learn more about the reference counting
159 management of Babeltrace objects.
161 The following functions can \em freeze field type objects:
163 - bt_ctf_field_create() freezes its field type parameter.
164 - bt_ctf_stream_class_add_event_class(), if its
165 \link ctfirstreamclass CTF IR stream class\endlink parameter has a
166 \link ctfirtraceclass CTF IR trace class\endlink parent, freezes
167 the root field types of its
168 \link ctfireventclass CTF IR event class\endlink parameter.
169 - bt_ctf_trace_add_stream_class() freezes the root field types of the
170 whole trace class hierarchy (trace class, children stream classes,
171 and their children event classes).
172 - bt_ctf_writer_create_stream() freezes the root field types of the
173 whole CTF writer's trace class hierarchy.
174 - bt_ctf_event_create() freezes the root field types of its event class
175 parameter and of ther parent stream class of this event class.
177 You cannot modify a frozen field type object: it is considered
178 immutable, except for \link refs reference counting\endlink.
181 @sa \ref ctfirfieldtypesexamples "Examples"
184 @brief CTF IR field types type and functions.
187 @addtogroup ctfirfieldtypes
192 @struct bt_ctf_field_type
193 @brief A CTF IR field type.
196 struct bt_ctf_field_type
;
197 struct bt_ctf_event_class
;
200 struct bt_ctf_field_path
;
202 /** @cond DOCUMENT */
205 * Babeltrace 1.x enumerations that were also used in CTF writer's API.
206 * They are left here for backward compatibility reasons, but
207 * enum bt_ctf_type_id and enum bt_ctf_string_encoding should be used
208 * in new code. Both new enumerations are compatible with their legacy
212 CTF_TYPE_UNKNOWN
= 0,
218 CTF_TYPE_UNTAGGED_VARIANT
,
228 enum ctf_string_encoding
{
241 /// Unknown, used for errors.
242 BT_CTF_SCOPE_UNKNOWN
= -1,
244 /// Trace packet header.
245 BT_CTF_SCOPE_TRACE_PACKET_HEADER
= 1,
247 /// Stream packet context.
248 BT_CTF_SCOPE_STREAM_PACKET_CONTEXT
= 2,
250 /// Stream event header.
251 BT_CTF_SCOPE_STREAM_EVENT_HEADER
= 3,
253 /// Stream event context.
254 BT_CTF_SCOPE_STREAM_EVENT_CONTEXT
= 4,
257 BT_CTF_SCOPE_EVENT_CONTEXT
= 5,
260 BT_CTF_SCOPE_EVENT_PAYLOAD
= 6,
263 BT_CTF_SCOPE_ENV
= 0,
264 BT_CTF_SCOPE_EVENT_FIELDS
= 6,
269 @name Type information
274 @brief Type ID of a @ft.
276 enum bt_ctf_type_id
{
277 /// Unknown, used for errors.
278 BT_CTF_TYPE_ID_UNKNOWN
= CTF_TYPE_UNKNOWN
,
280 /// \ref ctfirintfieldtype
281 BT_CTF_TYPE_ID_INTEGER
= CTF_TYPE_INTEGER
,
283 /// \ref ctfirfloatfieldtype
284 BT_CTF_TYPE_ID_FLOAT
= CTF_TYPE_FLOAT
,
286 /// \ref ctfirenumfieldtype
287 BT_CTF_TYPE_ID_ENUM
= CTF_TYPE_ENUM
,
289 /// \ref ctfirstringfieldtype
290 BT_CTF_TYPE_ID_STRING
= CTF_TYPE_STRING
,
292 /// \ref ctfirstructfieldtype
293 BT_CTF_TYPE_ID_STRUCT
= CTF_TYPE_STRUCT
,
296 BT_CTF_TYPE_ID_UNTAGGED_VARIANT
= CTF_TYPE_UNTAGGED_VARIANT
,
299 /// \ref ctfirarrayfieldtype
300 BT_CTF_TYPE_ID_ARRAY
= CTF_TYPE_ARRAY
,
302 /// \ref ctfirseqfieldtype
303 BT_CTF_TYPE_ID_SEQUENCE
= CTF_TYPE_SEQUENCE
,
305 /// \ref ctfirvarfieldtype
306 BT_CTF_TYPE_ID_VARIANT
= CTF_TYPE_VARIANT
,
308 /// Number of enumeration entries.
309 BT_CTF_NR_TYPE_IDS
= NR_CTF_TYPES
,
313 @brief Returns the type ID of the @ft \p field_type.
315 @param[in] field_type Field type of which to get the type ID.
316 @returns Type ID of \p field_type,
317 or #BT_CTF_TYPE_ID_UNKNOWN on error.
319 @prenotnull{field_type}
320 @postrefcountsame{field_type}
322 @sa #bt_ctf_type_id: CTF IR field type ID.
323 @sa bt_ctf_field_type_is_integer(): Returns whether or not a given
324 field type is a @intft.
325 @sa bt_ctf_field_type_is_floating_point(): Returns whether or not a
326 given field type is a @floatft.
327 @sa bt_ctf_field_type_is_enumeration(): Returns whether or not a given
328 field type is a @enumft.
329 @sa bt_ctf_field_type_is_string(): Returns whether or not a given
330 field type is a @stringft.
331 @sa bt_ctf_field_type_is_structure(): Returns whether or not a given
332 field type is a @structft.
333 @sa bt_ctf_field_type_is_array(): Returns whether or not a given
334 field type is a @arrayft.
335 @sa bt_ctf_field_type_is_sequence(): Returns whether or not a given
336 field type is a @seqft.
337 @sa bt_ctf_field_type_is_variant(): Returns whether or not a given
338 field type is a @varft.
340 extern enum bt_ctf_type_id
bt_ctf_field_type_get_type_id(
341 struct bt_ctf_field_type
*field_type
);
344 @brief Returns whether or not the @ft \p field_type is a @intft.
346 @param[in] field_type Field type to check (can be \c NULL).
347 @returns 1 if \p field_type is an integer field type,
348 or 0 otherwise (including if \p field_type is
351 @prenotnull{field_type}
352 @postrefcountsame{field_type}
354 @sa bt_ctf_field_type_get_type_id(): Returns the type ID of a given
357 extern int bt_ctf_field_type_is_integer(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 1 if \p field_type is a floating point
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 int bt_ctf_field_type_is_floating_point(struct bt_ctf_field_type
*field_type
);
376 @brief Returns whether or not the @ft \p field_type is a @enumft.
378 @param[in] field_type Field type to check (can be \c NULL).
379 @returns 1 if \p field_type is an enumeration field type,
380 or 0 otherwise (including if \p field_type is
383 @postrefcountsame{field_type}
385 @sa bt_ctf_field_type_get_type_id(): Returns the type ID of a given
388 extern int bt_ctf_field_type_is_enumeration(struct bt_ctf_field_type
*field_type
);
391 @brief Returns whether or not the @ft \p field_type is a @stringft.
393 @param[in] field_type Field type to check (can be \c NULL).
394 @returns 1 if \p field_type is a string field type,
395 or 0 otherwise (including if \p field_type is
398 @postrefcountsame{field_type}
400 @sa bt_ctf_field_type_get_type_id(): Returns the type ID of a given
403 extern int bt_ctf_field_type_is_string(struct bt_ctf_field_type
*field_type
);
406 @brief Returns whether or not the @ft \p field_type is a @structft.
408 @param[in] field_type Field type to check (can be \c NULL).
409 @returns 1 if \p field_type is a structure field type,
410 or 0 otherwise (including if \p field_type is
413 @postrefcountsame{field_type}
415 @sa bt_ctf_field_type_get_type_id(): Returns the type ID of a given
418 extern int bt_ctf_field_type_is_structure(struct bt_ctf_field_type
*field_type
);
421 @brief Returns whether or not the @ft \p field_type is a @arrayft.
423 @param[in] field_type Field type to check (can be \c NULL).
424 @returns 1 if \p field_type is an array field type,
425 or 0 otherwise (including if \p field_type is
428 @postrefcountsame{field_type}
430 @sa bt_ctf_field_type_get_type_id(): Returns the type ID of a given
433 extern int bt_ctf_field_type_is_array(struct bt_ctf_field_type
*field_type
);
436 @brief Returns whether or not the @ft \p field_type is a @seqft.
438 @param[in] field_type Field type to check (can be \c NULL).
439 @returns 1 if \p field_type is a sequence field type,
440 or 0 otherwise (including if \p field_type is
443 @postrefcountsame{field_type}
445 @sa bt_ctf_field_type_get_type_id(): Returns the type ID of a given
448 extern int bt_ctf_field_type_is_sequence(struct bt_ctf_field_type
*field_type
);
451 @brief Returns whether or not the @ft \p field_type is a @varft.
453 @param[in] field_type Field type to check (can be \c NULL).
454 @returns 1 if \p field_type is a variant field type,
455 or 0 otherwise (including if \p field_type is
458 @postrefcountsame{field_type}
460 @sa bt_ctf_field_type_get_type_id(): Returns the type ID of a given
463 extern int bt_ctf_field_type_is_variant(struct bt_ctf_field_type
*field_type
);
468 @name Common properties types and functions
473 @brief <a href="https://en.wikipedia.org/wiki/Endianness">Byte order</a>
476 enum bt_ctf_byte_order
{
477 /// Unknown, used for errors.
478 BT_CTF_BYTE_ORDER_UNKNOWN
= -1,
481 * Note that native, in the context of the CTF specification, is defined
482 * as "the byte order described in the trace" and does not mean that the
483 * host's endianness will be used.
485 /// Native (default) byte order.
486 BT_CTF_BYTE_ORDER_NATIVE
= 0,
489 BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
,
492 BT_CTF_BYTE_ORDER_BIG_ENDIAN
,
494 /// Network byte order (big-endian).
495 BT_CTF_BYTE_ORDER_NETWORK
,
499 @brief String encoding of a @ft.
501 enum bt_ctf_string_encoding
{
502 /// Unknown, used for errors.
503 BT_CTF_STRING_ENCODING_UNKNOWN
= CTF_STRING_UNKNOWN
,
506 BT_CTF_STRING_ENCODING_NONE
= CTF_STRING_NONE
,
508 /// <a href="https://en.wikipedia.org/wiki/UTF-8">UTF-8</a>.
509 BT_CTF_STRING_ENCODING_UTF8
= CTF_STRING_UTF8
,
511 /// <a href="https://en.wikipedia.org/wiki/ASCII">ASCII</a>.
512 BT_CTF_STRING_ENCODING_ASCII
= CTF_STRING_ASCII
,
516 @brief Returns the alignment of the @fields described by
517 the @ft \p field_type.
519 @param[in] field_type Field type which describes the
520 fields of which to get the alignment.
521 @returns Alignment of the fields described by
522 \p field_type, or a negative value on error.
524 @prenotnull{field_type}
525 @postrefcountsame{field_type}
527 @sa bt_ctf_field_type_set_alignment(): Sets the alignment
528 of the fields described by a given field type.
530 extern int bt_ctf_field_type_get_alignment(
531 struct bt_ctf_field_type
*field_type
);
534 @brief Sets the alignment of the @fields described by the
535 @ft \p field_type to \p alignment.
537 \p alignment \em must be greater than 0 and a power of two.
539 @param[in] field_type Field type which describes the fields of
540 which to set the alignment.
541 @param[in] alignment Alignment of the fields described by
543 @returns 0 on success, or a negative value on error.
545 @prenotnull{field_type}
547 @pre \p alignment is greater than 0 and a power of two.
548 @postrefcountsame{field_type}
550 @sa bt_ctf_field_type_get_alignment(): Returns the alignment of the
551 fields described by a given field type.
553 extern int bt_ctf_field_type_set_alignment(struct bt_ctf_field_type
*field_type
,
554 unsigned int alignment
);
557 @brief Returns the byte order of the @fields described by
558 the @ft \p field_type.
560 You can only call this function if \p field_type is a @intft, a
561 @floatft, or a @enumft.
563 @param[in] field_type Field type which describes the
564 fields of which to get the byte order.
565 @returns Byte order of the fields described by
566 \p field_type, or #BT_CTF_BYTE_ORDER_UNKNOWN on
569 @prenotnull{field_type}
570 @pre \p field_type is a @intft, a @floatft, or a @enumft.
571 @postrefcountsame{field_type}
573 @sa bt_ctf_field_type_set_byte_order(): Sets the byte order
574 of the fields described by a given field type.
576 extern enum bt_ctf_byte_order
bt_ctf_field_type_get_byte_order(
577 struct bt_ctf_field_type
*field_type
);
580 @brief Sets the byte order of the @fields described by the
581 @ft \p field_type to \p byte_order.
583 If \p field_type is a compound field type, this function also
584 recursively sets the byte order of its children to \p byte_order.
586 @param[in] field_type Field type which describes the fields of
587 which to set the byte order.
588 @param[in] byte_order Alignment of the fields described by
590 @returns 0 on success, or a negative value on error.
592 @prenotnull{field_type}
594 @pre \p byte_order is #BT_CTF_BYTE_ORDER_NATIVE,
595 #BT_CTF_BYTE_ORDER_LITTLE_ENDIAN, #BT_CTF_BYTE_ORDER_BIG_ENDIAN,
596 or #BT_CTF_BYTE_ORDER_NETWORK.
597 @postrefcountsame{field_type}
599 @sa bt_ctf_field_type_get_byte_order(): Returns the byte order of the
600 fields described by a given field type.
602 extern int bt_ctf_field_type_set_byte_order(
603 struct bt_ctf_field_type
*field_type
,
604 enum bt_ctf_byte_order byte_order
);
609 @name Utility functions
614 @brief Returns whether or not the @ft \p field_type_a
615 is equivalent to the field type \p field_type_b.
617 You \em must use this function to compare two field types: it is not
618 safe to compare two pointer values directly, because, for internal
619 reasons, some parts of the Babeltrace system can copy user field types
620 and discard the original ones.
622 @param[in] field_type_a Field type to compare to \p field_type_b.
623 @param[in] field_type_b Field type to compare to \p field_type_a.
624 @returns 0 if \p field_type_a is equivalent to
625 \p field_type_b, 1 if they are not equivalent,
626 or a negative value on error.
628 @prenotnull{field_type_a}
629 @prenotnull{field_type_b}
630 @postrefcountsame{field_type_a}
631 @postrefcountsame{field_type_b}
633 extern int bt_ctf_field_type_compare(struct bt_ctf_field_type
*field_type_a
,
634 struct bt_ctf_field_type
*field_type_b
);
637 @brief Creates a \em deep copy of the @ft \p field_type.
639 You can copy a frozen field type: the resulting copy is
642 This function resets the tag field type of a copied @varft. The
643 automatic field resolving which some functions of the API perform
644 can set it again when the returned field type is used (learn more
645 in the detailed description of this module).
647 @param[in] field_type Field type to copy.
648 @returns Deep copy of \p field_type on success,
651 @prenotnull{field_type}
652 @postrefcountsame{field_type}
653 @postsuccessrefcountret1
654 @post <strong>On success</strong>, the returned field type is not frozen.
656 extern struct bt_ctf_field_type
*bt_ctf_field_type_copy(
657 struct bt_ctf_field_type
*field_type
);
664 @defgroup ctfirintfieldtype CTF IR integer field type
665 @ingroup ctfirfieldtypes
666 @brief CTF IR integer field type.
669 #include <babeltrace/ctf-ir/field-types.h>
672 A CTF IR <strong><em>integer field type</em></strong> is a field type that
673 you can use to create concrete @intfield objects.
675 You can create an integer field type
676 with bt_ctf_field_type_integer_create().
678 An integer field type has the following properties:
683 <th>Value at creation
688 <td>\b Alignment (bits) of the described integer fields
690 <td>bt_ctf_field_type_get_alignment()
691 <td>bt_ctf_field_type_set_alignment()
694 <td><strong>Byte order</strong> of the described integer fields
695 <td>#BT_CTF_BYTE_ORDER_NATIVE
696 <td>bt_ctf_field_type_get_byte_order()
697 <td>bt_ctf_field_type_set_byte_order()
700 <td><strong>Storage size</strong> (bits) of the described
702 <td>Specified at creation
703 <td>bt_ctf_field_type_integer_get_size()
704 <td>None: specified at creation (bt_ctf_field_type_integer_create())
707 <td><strong>Signedness</strong> of the described integer fields
709 <td>bt_ctf_field_type_integer_get_signed()
710 <td>bt_ctf_field_type_integer_set_signed()
713 <td><strong>Preferred display base</strong> of the described
715 <td>#BT_CTF_INTEGER_BASE_DECIMAL
716 <td>bt_ctf_field_type_integer_get_base()
717 <td>bt_ctf_field_type_integer_set_base()
720 <td>\b Encoding of the described integer fields
721 <td>#BT_CTF_STRING_ENCODING_NONE
722 <td>bt_ctf_field_type_integer_get_encoding()
723 <td>bt_ctf_field_type_integer_set_encoding()
727 \link ctfirclockclass CTF IR clock class\endlink</strong>
729 <td>bt_ctf_field_type_integer_get_mapped_clock_class()
730 <td>bt_ctf_field_type_integer_set_mapped_clock_class()
736 @sa \ref ctfirfieldtypesexamples_intfieldtype "Examples"
738 @addtogroup ctfirintfieldtype
743 @brief Preferred display base (radix) of a @intft.
745 enum bt_ctf_integer_base
{
746 /// Unknown, used for errors.
747 BT_CTF_INTEGER_BASE_UNKNOWN
= -1,
750 BT_CTF_INTEGER_BASE_BINARY
= 2,
753 BT_CTF_INTEGER_BASE_OCTAL
= 8,
756 BT_CTF_INTEGER_BASE_DECIMAL
= 10,
759 BT_CTF_INTEGER_BASE_HEXADECIMAL
= 16,
763 @brief Creates a default @intft with \p size bits as the storage size
764 of the @intfields it describes.
766 @param[in] size Storage size (bits) of the described integer fields.
767 @returns Created integer field type, or \c NULL on error.
769 @pre \p size is greater than 0 and lesser than or equal to 64.
770 @postsuccessrefcountret1
772 extern struct bt_ctf_field_type
*bt_ctf_field_type_integer_create(
776 @brief Returns the storage size, in bits, of the @intfields
777 described by the @intft \p int_field_type.
779 @param[in] int_field_type Integer field type which describes the
780 integer fields of which to get the
782 @returns Storage size (bits) of the integer
783 fields described by \p int_field_type,
784 or a negative value on error.
786 @prenotnull{int_field_type}
787 @preisintft{int_field_type}
788 @postrefcountsame{int_field_type}
790 extern int bt_ctf_field_type_integer_get_size(
791 struct bt_ctf_field_type
*int_field_type
);
794 @brief Returns whether or not the @intfields described by the @intft
795 \p int_field_type are signed.
797 @param[in] int_field_type Integer field type which describes the
798 integer fields of which to get the
800 @returns 1 if the integer fields described by
801 \p int_field_type are signed, 0 if they
802 are unsigned, or a negative value on
805 @prenotnull{int_field_type}
806 @preisintft{int_field_type}
807 @postrefcountsame{int_field_type}
809 @sa bt_ctf_field_type_integer_set_signed(): Sets the signedness of the
810 integer fields described by a given integer field type.
812 extern int bt_ctf_field_type_integer_get_signed(
813 struct bt_ctf_field_type
*int_field_type
);
816 @brief Sets whether or not the @intfields described by
817 the @intft \p int_field_type are signed.
819 @param[in] int_field_type Integer field type which describes the
820 integer fields of which to set the
822 @param[in] is_signed Signedness of the integer fields
823 described by \p int_field_type; 0 means
824 \em unsigned, 1 means \em signed.
825 @returns 0 on success, or a negative value on error.
827 @prenotnull{int_field_type}
828 @preisintft{int_field_type}
829 @prehot{int_field_type}
830 @pre \p is_signed is 0 or 1.
831 @postrefcountsame{event_class}
833 @sa bt_ctf_field_type_integer_get_signed(): Returns the signedness of
834 the integer fields described by a given integer field type.
836 extern int bt_ctf_field_type_integer_set_signed(
837 struct bt_ctf_field_type
*int_field_type
, int is_signed
);
840 @brief Returns the preferred display base (radix) of the @intfields
841 described by the @intft \p int_field_type.
843 @param[in] int_field_type Integer field type which describes the
844 integer fields of which to get the
845 preferred display base.
846 @returns Preferred display base of the integer
847 fields described by \p int_field_type,
848 or #BT_CTF_INTEGER_BASE_UNKNOWN on
851 @prenotnull{int_field_type}
852 @preisintft{int_field_type}
853 @postrefcountsame{int_field_type}
855 @sa bt_ctf_field_type_integer_set_base(): Sets the preferred display
856 base of the integer fields described by a given integer field
859 extern enum bt_ctf_integer_base
bt_ctf_field_type_integer_get_base(
860 struct bt_ctf_field_type
*int_field_type
);
863 @brief Sets the preferred display base (radix) of the @intfields
864 described by the @intft \p int_field_type to \p base.
866 @param[in] int_field_type Integer field type which describes the
867 integer fields of which to set the
868 preferred display base.
869 @param[in] base Preferred display base of the integer
870 fields described by \p int_field_type.
871 @returns 0 on success, or a negative value on error.
873 @prenotnull{int_field_type}
874 @preisintft{int_field_type}
875 @prehot{int_field_type}
876 @pre \p base is #BT_CTF_INTEGER_BASE_BINARY, #BT_CTF_INTEGER_BASE_OCTAL,
877 #BT_CTF_INTEGER_BASE_DECIMAL, or
878 #BT_CTF_INTEGER_BASE_HEXADECIMAL.
879 @postrefcountsame{int_field_type}
881 @sa bt_ctf_field_type_integer_get_base(): Returns the preferred display
882 base of the integer fields described by a given
885 extern int bt_ctf_field_type_integer_set_base(
886 struct bt_ctf_field_type
*int_field_type
,
887 enum bt_ctf_integer_base base
);
890 @brief Returns the encoding of the @intfields described by
891 the @intft \p int_field_type.
893 @param[in] int_field_type Integer field type which describes the
894 integer fields of which to get the
896 @returns Encoding of the integer
897 fields described by \p int_field_type,
898 or #BT_CTF_STRING_ENCODING_UNKNOWN on
901 @prenotnull{int_field_type}
902 @preisintft{int_field_type}
903 @postrefcountsame{int_field_type}
905 @sa bt_ctf_field_type_integer_set_encoding(): Sets the encoding
906 of the integer fields described by a given integer field type.
908 extern enum bt_ctf_string_encoding
bt_ctf_field_type_integer_get_encoding(
909 struct bt_ctf_field_type
*int_field_type
);
912 @brief Sets the encoding of the @intfields described by the @intft
913 \p int_field_type to \p encoding.
915 You can use this property, in CTF IR, to create "text" @arrayfts or
916 @seqfts. A text array field type is array field type with an unsigned,
917 8-bit integer field type having an encoding as its element field type.
919 @param[in] int_field_type Integer field type which describes the
920 integer fields of which to set the
922 @param[in] encoding Encoding of the integer
923 fields described by \p int_field_type.
924 @returns 0 on success, or a negative value on error.
926 @prenotnull{int_field_type}
927 @preisintft{int_field_type}
928 @prehot{int_field_type}
929 @pre \p encoding is #BT_CTF_STRING_ENCODING_NONE,
930 #BT_CTF_STRING_ENCODING_ASCII, or
931 #BT_CTF_STRING_ENCODING_UTF8.
932 @postrefcountsame{int_field_type}
934 @sa bt_ctf_field_type_integer_get_encoding(): Returns the encoding of
935 the integer fields described by a given integer field type.
937 extern int bt_ctf_field_type_integer_set_encoding(
938 struct bt_ctf_field_type
*int_field_type
,
939 enum bt_ctf_string_encoding encoding
);
942 @brief Returns the \link ctfirclockclass CTF IR clock class\endlink
943 mapped to the @intft \p int_field_type.
945 The mapped clock class, if any, indicates the class of the clock which
946 an @intfield described by \p int_field_type should sample or update.
947 This mapped clock class is only indicative.
949 @param[in] int_field_type Integer field type of which to get the
951 @returns Mapped clock class of \p int_field_type,
952 or \c NULL if there's no mapped clock
955 @prenotnull{int_field_type}
956 @preisintft{int_field_type}
957 @postrefcountsame{int_field_type}
958 @postsuccessrefcountretinc
960 @sa bt_ctf_field_type_integer_set_mapped_clock_class(): Sets the mapped
961 clock class of a given integer field type.
963 extern struct bt_ctf_clock_class
*bt_ctf_field_type_integer_get_mapped_clock_class(
964 struct bt_ctf_field_type
*int_field_type
);
967 @brief Sets the \link ctfirclockclass CTF IR clock class\endlink mapped
968 to the @intft \p int_field_type to \p clock_class.
970 The mapped clock class, if any, indicates the class of the clock which
971 an integer field described by \p int_field_type should sample or update.
972 This mapped clock class is only indicative.
974 @param[in] int_field_type Integer field type of which to set the
976 @param[in] clock_class Mapped clock class of \p int_field_type.
977 @returns 0 on success, or a negative value on error.
979 @prenotnull{int_field_type}
980 @prenotnull{clock_class}
981 @preisintft{int_field_type}
982 @prehot{int_field_type}
983 @postrefcountsame{int_field_type}
984 @postsuccessrefcountinc{clock_class}
986 @sa bt_ctf_field_type_integer_get_mapped_clock_class(): Returns the mapped
987 clock class of a given integer field type.
989 extern int bt_ctf_field_type_integer_set_mapped_clock_class(
990 struct bt_ctf_field_type
*int_field_type
,
991 struct bt_ctf_clock_class
*clock_class
);
996 @defgroup ctfirfloatfieldtype CTF IR floating point number field type
997 @ingroup ctfirfieldtypes
998 @brief CTF IR floating point number field type.
1001 #include <babeltrace/ctf-ir/field-types.h>
1004 A CTF IR <strong><em>floating point number field type</em></strong> is
1005 a field type that you can use to create concrete @floatfields.
1007 You can create a floating point number field type
1008 with bt_ctf_field_type_floating_point_create().
1010 A floating point number field type has the following properties:
1015 <th>Value at creation
1020 <td>\b Alignment (bits) of the described floating point
1023 <td>bt_ctf_field_type_get_alignment()
1024 <td>bt_ctf_field_type_set_alignment()
1027 <td><strong>Byte order</strong> of the described floating point
1029 <td>#BT_CTF_BYTE_ORDER_NATIVE
1030 <td>bt_ctf_field_type_get_byte_order()
1031 <td>bt_ctf_field_type_set_byte_order()
1034 <td><strong>Exponent storage size</strong> (bits) of the described
1035 floating point number fields
1037 <td>bt_ctf_field_type_floating_point_get_exponent_digits()
1038 <td>bt_ctf_field_type_floating_point_set_exponent_digits()
1041 <td><strong>Mantissa and sign storage size</strong> (bits) of the
1042 described floating point number fields
1043 <td>24 (23-bit mantissa, 1-bit sign)
1044 <td>bt_ctf_field_type_floating_point_get_mantissa_digits()
1045 <td>bt_ctf_field_type_floating_point_set_mantissa_digits()
1051 @sa \ref ctfirfieldtypesexamples_floatfieldtype "Examples"
1053 @addtogroup ctfirfloatfieldtype
1058 @brief Creates a default @floatft.
1060 @returns Created floating point number field type,
1061 or \c NULL on error.
1063 @postsuccessrefcountret1
1065 extern struct bt_ctf_field_type
*bt_ctf_field_type_floating_point_create(void);
1068 @brief Returns the exponent storage size of the @floatfields
1069 described by the @floatft \p float_field_type.
1071 @param[in] float_field_type Floating point number field type which
1072 describes the floating point number
1073 fields of which to get the exponent
1075 @returns Exponent storage size of the
1076 floating point number fields
1077 described by \p float_field_type,
1078 or a negative value on error.
1080 @prenotnull{float_field_type}
1081 @preisfloatft{float_field_type}
1082 @postrefcountsame{float_field_type}
1084 @sa bt_ctf_field_type_floating_point_set_exponent_digits(): Sets the
1085 exponent storage size of the floating point number fields
1086 described by a given floating point number field type.
1088 extern int bt_ctf_field_type_floating_point_get_exponent_digits(
1089 struct bt_ctf_field_type
*float_field_type
);
1092 @brief Sets the exponent storage size of the @floatfields described by
1093 the @floatft \p float_field_type to \p exponent_size.
1095 As of Babeltrace \btversion, \p exponent_size can only be 8 or 11.
1097 @param[in] float_field_type Floating point number field type which
1098 describes the floating point number
1099 fields of which to set the exponent
1101 @param[in] exponent_size Exponent storage size of the floating
1102 point number fields described by \p
1104 @returns 0 on success, or a negative value on error.
1106 @prenotnull{float_field_type}
1107 @preisfloatft{float_field_type}
1108 @prehot{float_field_type}
1109 @pre \p exponent_size is 8 or 11.
1110 @postrefcountsame{float_field_type}
1112 @sa bt_ctf_field_type_floating_point_get_exponent_digits(): Returns the
1113 exponent storage size of the floating point number fields
1114 described by a given floating point number field type.
1116 extern int bt_ctf_field_type_floating_point_set_exponent_digits(
1117 struct bt_ctf_field_type
*float_field_type
,
1118 unsigned int exponent_size
);
1121 @brief Returns the mantissa and sign storage size of the @floatfields
1122 described by the @floatft \p float_field_type.
1124 On success, the returned value is the sum of the mantissa \em and
1127 @param[in] float_field_type Floating point number field type which
1128 describes the floating point number
1129 fields of which to get the mantissa and
1131 @returns Mantissa and sign storage size of the
1132 floating point number fields
1133 described by \p float_field_type,
1134 or a negative value on error.
1136 @prenotnull{float_field_type}
1137 @preisfloatft{float_field_type}
1138 @postrefcountsame{float_field_type}
1140 @sa bt_ctf_field_type_floating_point_set_mantissa_digits(): Sets the
1141 mantissa and size storage size of the floating point number
1142 fields described by a given floating point number field type.
1144 extern int bt_ctf_field_type_floating_point_get_mantissa_digits(
1145 struct bt_ctf_field_type
*float_field_type
);
1148 @brief Sets the mantissa and sign storage size of the @floatfields
1149 described by the @floatft \p float_field_type to \p
1152 As of Babeltrace \btversion, \p mantissa_sign_size can only be 24 or 53.
1154 @param[in] float_field_type Floating point number field type which
1155 describes the floating point number
1156 fields of which to set the mantissa and
1158 @param[in] mantissa_sign_size Mantissa and sign storage size of the
1159 floating point number fields described
1160 by \p float_field_type.
1161 @returns 0 on success, or a negative value on error.
1163 @prenotnull{float_field_type}
1164 @preisfloatft{float_field_type}
1165 @prehot{float_field_type}
1166 @pre \p mantissa_sign_size is 24 or 53.
1167 @postrefcountsame{float_field_type}
1169 @sa bt_ctf_field_type_floating_point_get_mantissa_digits(): Returns the
1170 mantissa and sign storage size of the floating point number
1171 fields described by a given floating point number field type.
1173 extern int bt_ctf_field_type_floating_point_set_mantissa_digits(
1174 struct bt_ctf_field_type
*float_field_type
,
1175 unsigned int mantissa_sign_size
);
1179 struct bt_ctf_field_type_enumeration_mapping_iterator
*
1180 bt_ctf_field_type_enumeration_find_mappings_by_name(
1181 struct bt_ctf_field_type
*type
,
1184 struct bt_ctf_field_type_enumeration_mapping_iterator
*
1185 bt_ctf_field_type_enumeration_find_mappings_by_signed_value(
1186 struct bt_ctf_field_type
*type
,
1189 struct bt_ctf_field_type_enumeration_mapping_iterator
*
1190 bt_ctf_field_type_enumeration_find_mappings_by_unsigned_value(
1191 struct bt_ctf_field_type
*type
,
1194 int bt_ctf_field_type_enumeration_mapping_iterator_get_name(
1195 struct bt_ctf_field_type_enumeration_mapping_iterator
*iter
,
1196 const char **mapping_name
);
1198 int bt_ctf_field_type_enumeration_mapping_iterator_get_signed(
1199 struct bt_ctf_field_type_enumeration_mapping_iterator
*iter
,
1200 const char **mapping_name
, int64_t *lower
, int64_t *upper
);
1202 int bt_ctf_field_type_enumeration_mapping_iterator_get_unsigned(
1203 struct bt_ctf_field_type_enumeration_mapping_iterator
*iter
,
1204 const char **mapping_name
, uint64_t *lower
, uint64_t *upper
);
1206 int bt_ctf_field_type_enumeration_mapping_iterator_next(
1207 struct bt_ctf_field_type_enumeration_mapping_iterator
*iter
);
1210 @defgroup ctfirenumfieldtype CTF IR enumeration field type
1211 @ingroup ctfirfieldtypes
1212 @brief CTF IR enumeration field type.
1215 #include <babeltrace/ctf-ir/field-types.h>
1218 A CTF IR <strong><em>enumeration field type</em></strong> is
1219 a field type that you can use to create concrete @enumfields.
1221 You can create an enumeration field type with
1222 bt_ctf_field_type_enumeration_create(). This function needs a @intft
1223 which represents the storage field type of the created enumeration field
1224 type. In other words, an enumeration field type wraps an integer field
1225 type and adds label-value mappings to it.
1227 An enumeration mapping has:
1229 - A <strong>name</strong>.
1230 - A <strong>range of values</strong> given by a beginning and an ending
1231 value, both included in the range.
1233 You can add a mapping to an enumeration field type with
1234 bt_ctf_field_type_enumeration_add_mapping() or
1235 bt_ctf_field_type_enumeration_add_mapping_unsigned(), depending on the
1236 signedness of the wrapped @intft.
1238 Many mappings can share the same name, and the ranges of a given
1239 enumeration field type are allowed to overlap. For example,
1240 this is a valid set of mappings:
1249 The following set of mappings is also valid:
1258 Here, the range of the second \c APPLE mapping overlaps the range of
1259 the \c CHERRY mapping.
1264 @addtogroup ctfirenumfieldtype
1269 @brief Creates a default @enumft wrapping the @intft \p int_field_type.
1271 @param[in] int_field_type Integer field type wrapped by the
1272 created enumeration field type.
1273 @returns Created enumeration field type,
1274 or \c NULL on error.
1276 @prenotnull{int_field_type}
1277 @preisintft{int_field_type}
1278 @postsuccessrefcountinc{int_field_type}
1279 @postsuccessrefcountret1
1281 extern struct bt_ctf_field_type
*bt_ctf_field_type_enumeration_create(
1282 struct bt_ctf_field_type
*int_field_type
);
1285 @brief Returns the @intft wrapped by the @enumft \p enum_field_type.
1287 @param[in] enum_field_type Enumeration field type of which to get
1288 the wrapped integer field type.
1289 @returns Integer field type wrapped by
1290 \p enum_field_type, or \c NULL on
1293 @prenotnull{enum_field_type}
1294 @preisenumft{enum_field_type}
1295 @postrefcountsame{enum_field_type}
1296 @postsuccessrefcountretinc
1299 struct bt_ctf_field_type
*bt_ctf_field_type_enumeration_get_container_type(
1300 struct bt_ctf_field_type
*enum_field_type
);
1303 @brief Returns the number of mappings contained in the
1304 @enumft \p enum_field_type.
1306 @param[in] enum_field_type Enumeration field type of which to get
1307 the number of contained mappings.
1308 @returns Number of mappings contained in
1309 \p enum_field_type, or a negative
1312 @prenotnull{enum_field_type}
1313 @preisenumft{enum_field_type}
1314 @postrefcountsame{enum_field_type}
1316 extern int bt_ctf_field_type_enumeration_get_mapping_count(
1317 struct bt_ctf_field_type
*enum_field_type
);
1320 @brief Returns the signed mapping of the @enumft
1321 \p enum_field_type at index \p index.
1323 The @intft wrapped by \p enum_field_type, as returned by
1324 bt_ctf_field_type_enumeration_get_container_type(), must be \b signed
1325 to use this function.
1327 On success, \p enum_field_type remains the sole owner of \p *name.
1329 @param[in] enum_field_type Enumeration field type of which to get
1330 the mapping at index \p index.
1331 @param[in] index Index of the mapping to get from
1333 @param[out] name Returned name of the mapping at index
1335 @param[out] range_begin Returned beginning of the range
1336 (included) of the mapping at index \p
1338 @param[out] range_end Returned end of the range (included) of
1339 the mapping at index \p index.
1340 @returns 0 on success, or a negative value on error.
1342 @prenotnull{enum_field_type}
1344 @prenotnull{range_begin}
1345 @prenotnull{range_end}
1346 @preisenumft{enum_field_type}
1347 @pre The wrapped @intft of \p enum_field_type is signed.
1348 @pre \p index is lesser than the number of mappings contained in the
1349 enumeration field type \p enum_field_type (see
1350 bt_ctf_field_type_enumeration_get_mapping_count()).
1351 @postrefcountsame{enum_field_type}
1353 @sa bt_ctf_field_type_enumeration_get_mapping_signed(): Returns the
1354 signed mapping contained by a given enumeration field type
1357 extern int bt_ctf_field_type_enumeration_get_mapping_signed(
1358 struct bt_ctf_field_type
*enum_field_type
, int index
,
1359 const char **name
, int64_t *range_begin
, int64_t *range_end
);
1362 @brief Returns the unsigned mapping of the @enumft
1363 \p enum_field_type at index \p index.
1365 The @intft wrapped by \p enum_field_type, as returned by
1366 bt_ctf_field_type_enumeration_get_container_type(), must be
1367 \b unsigned to use this function.
1369 On success, \p enum_field_type remains the sole owner of \p *name.
1371 @param[in] enum_field_type Enumeration field type of which to get
1372 the mapping at index \p index.
1373 @param[in] index Index of the mapping to get from
1375 @param[out] name Returned name of the mapping at index
1377 @param[out] range_begin Returned beginning of the range
1378 (included) of the mapping at index \p
1380 @param[out] range_end Returned end of the range (included) of
1381 the mapping at index \p index.
1382 @returns 0 on success, or a negative value on error.
1384 @prenotnull{enum_field_type}
1386 @prenotnull{range_begin}
1387 @prenotnull{range_end}
1388 @preisenumft{enum_field_type}
1389 @pre The wrapped @intft of \p enum_field_type is unsigned.
1390 @pre \p index is lesser than the number of mappings contained in the
1391 enumeration field type \p enum_field_type (see
1392 bt_ctf_field_type_enumeration_get_mapping_count()).
1393 @postrefcountsame{enum_field_type}
1395 @sa bt_ctf_field_type_enumeration_get_mapping_unsigned(): Returns the
1396 unsigned mapping contained by a given enumeration field type
1399 extern int bt_ctf_field_type_enumeration_get_mapping_unsigned(
1400 struct bt_ctf_field_type
*enum_field_type
, int index
,
1401 const char **name
, uint64_t *range_begin
,
1402 uint64_t *range_end
);
1405 @brief Adds a mapping to the @enumft \p enum_field_type which maps the
1406 name \p name to the signed range \p range_begin (included) to
1407 \p range_end (included).
1409 Make \p range_begin and \p range_end the same value to add a mapping
1412 The @intft wrapped by \p enum_field_type, as returned by
1413 bt_ctf_field_type_enumeration_get_container_type(), must be
1414 \b signed to use this function.
1416 A mapping in \p enum_field_type can exist with the name \p name.
1418 @param[in] enum_field_type Enumeration field type to which to add
1420 @param[in] name Name of the mapping to add (copied
1422 @param[in] range_begin Beginning of the range of the mapping
1424 @param[in] range_end End of the range of the mapping
1426 @returns 0 on success, or a negative value on error.
1428 @prenotnull{enum_field_type}
1430 @preisenumft{enum_field_type}
1431 @pre The wrapped @intft of \p enum_field_type is signed.
1432 @pre \p range_end is greater than or equal to \p range_begin.
1433 @postrefcountsame{enum_field_type}
1435 @sa bt_ctf_field_type_enumeration_add_mapping_unsigned(): Adds an
1436 unsigned mapping to a given enumeration field type.
1438 extern int bt_ctf_field_type_enumeration_add_mapping(
1439 struct bt_ctf_field_type
*enum_field_type
, const char *name
,
1440 int64_t range_begin
, int64_t range_end
);
1443 @brief Adds a mapping to the @enumft \p enum_field_type which maps
1444 the name \p name to the unsigned
1445 range \p range_begin (included) to \p range_end (included).
1447 Make \p range_begin and \p range_end the same value to add a mapping
1450 The @intft wrapped by \p enum_field_type, as returned by
1451 bt_ctf_field_type_enumeration_get_container_type(), must be
1452 \b unsigned to use this function.
1454 A mapping in \p enum_field_type can exist with the name \p name.
1456 @param[in] enum_field_type Enumeration field type to which to add
1458 @param[in] name Name of the mapping to add (copied
1460 @param[in] range_begin Beginning of the range of the mapping
1462 @param[in] range_end End of the range of the mapping
1464 @returns 0 on success, or a negative value on error.
1466 @prenotnull{enum_field_type}
1468 @preisenumft{enum_field_type}
1469 @pre The wrapped @intft of \p enum_field_type is unsigned.
1470 @pre \p range_end is greater than or equal to \p range_begin.
1471 @postrefcountsame{enum_field_type}
1473 @sa bt_ctf_field_type_enumeration_add_mapping(): Adds a signed
1474 mapping to a given enumeration field type.
1476 extern int bt_ctf_field_type_enumeration_add_mapping_unsigned(
1477 struct bt_ctf_field_type
*enum_field_type
, const char *name
,
1478 uint64_t range_begin
, uint64_t range_end
);
1483 @defgroup ctfirstringfieldtype CTF IR string field type
1484 @ingroup ctfirfieldtypes
1485 @brief CTF IR string field type.
1488 #include <babeltrace/ctf-ir/field-types.h>
1491 A CTF IR <strong><em>string field type</em></strong> is a field type that
1492 you can use to create concrete @stringfields.
1494 You can create a string field type
1495 with bt_ctf_field_type_string_create().
1497 A string field type has only one property: the \b encoding of its
1498 described @stringfields. By default, the encoding of the string fields
1499 described by a string field type is #BT_CTF_STRING_ENCODING_UTF8. You
1500 can set the encoding of the string fields described by a string field
1501 type with bt_ctf_field_type_string_set_encoding().
1503 @sa ctfirstringfield
1506 @addtogroup ctfirstringfieldtype
1511 @brief Creates a default @stringft.
1513 @returns Created string field type, or \c NULL on error.
1515 @postsuccessrefcountret1
1517 extern struct bt_ctf_field_type
*bt_ctf_field_type_string_create(void);
1520 @brief Returns the encoding of the @stringfields described by
1521 the @stringft \p string_field_type.
1523 @param[in] string_field_type String field type which describes the
1524 string fields of which to get the
1526 @returns Encoding of the string
1527 fields described by \p string_field_type,
1528 or #BT_CTF_STRING_ENCODING_UNKNOWN on
1531 @prenotnull{string_field_type}
1532 @preisstringft{string_field_type}
1533 @postrefcountsame{string_field_type}
1535 @sa bt_ctf_field_type_string_set_encoding(): Sets the encoding
1536 of the string fields described by a given string field type.
1538 extern enum bt_ctf_string_encoding
bt_ctf_field_type_string_get_encoding(
1539 struct bt_ctf_field_type
*string_field_type
);
1542 @brief Sets the encoding of the @stringfields described by the
1543 @stringft \p string_field_type to \p encoding.
1545 @param[in] string_field_type String field type which describes the
1546 string fields of which to set the
1548 @param[in] encoding Encoding of the string fields described
1549 by \p string_field_type.
1550 @returns 0 on success, or a negative value on error.
1552 @prenotnull{string_field_type}
1553 @preisstringft{string_field_type}
1554 @prehot{string_field_type}
1555 @pre \p encoding is #BT_CTF_STRING_ENCODING_ASCII or
1556 #BT_CTF_STRING_ENCODING_UTF8.
1557 @postrefcountsame{string_field_type}
1559 @sa bt_ctf_field_type_string_get_encoding(): Returns the encoding of
1560 the string fields described by a given string field type.
1562 extern int bt_ctf_field_type_string_set_encoding(
1563 struct bt_ctf_field_type
*string_field_type
,
1564 enum bt_ctf_string_encoding encoding
);
1569 @defgroup ctfirstructfieldtype CTF IR structure field type
1570 @ingroup ctfirfieldtypes
1571 @brief CTF IR structure field type.
1574 #include <babeltrace/ctf-ir/field-types.h>
1577 A CTF IR <strong><em>structure field type</em></strong> is
1578 a field type that you can use to create concrete @structfields.
1580 You can create a structure field type
1581 with bt_ctf_field_type_structure_create(). This function creates
1582 an empty structure field type, with no fields.
1584 You can add a field to a structure field type with
1585 bt_ctf_field_type_structure_add_field(). Two fields in a structure
1586 field type cannot have the same name.
1588 You can set the \em minimum alignment of the structure fields described
1589 by a structure field type with the common
1590 bt_ctf_field_type_set_alignment() function. The \em effective alignment
1591 of the structure fields described by a structure field type, as per
1592 <a href="http://diamon.org/ctf/">CTF</a>, is the \em maximum value amongst
1593 the effective alignments of all its fields. Note that the effective
1594 alignment of @varfields is always 1.
1596 You can set the byte order of <em>all the contained fields</em>,
1597 recursively, of a structure field type with the common
1598 bt_ctf_field_type_set_byte_order() function.
1600 @sa ctfirstructfield
1603 @addtogroup ctfirstructfieldtype
1608 @brief Creates a default, empty @structft.
1610 @returns Created structure field type,
1611 or \c NULL on error.
1613 @postsuccessrefcountret1
1615 extern struct bt_ctf_field_type
*bt_ctf_field_type_structure_create(void);
1618 @brief Returns the number of fields contained in the
1619 @structft \p struct_field_type.
1621 @param[in] struct_field_type Structure field type of which to get
1622 the number of contained fields.
1623 @returns Number of fields contained in
1624 \p struct_field_type, or a negative
1627 @prenotnull{struct_field_type}
1628 @preisstructft{struct_field_type}
1629 @postrefcountsame{struct_field_type}
1631 extern int bt_ctf_field_type_structure_get_field_count(
1632 struct bt_ctf_field_type
*struct_field_type
);
1635 @brief Returns the field of the @structft \p struct_field_type
1638 On success, the field's type is placed in \p *field_type if
1639 \p field_type is not \c NULL. The field's name is placed in
1640 \p *field_name if \p field_name is not \c NULL.
1641 \p struct_field_type remains the sole owner of \p *field_name.
1643 @param[in] struct_field_type Structure field type of which to get
1644 the field at index \p index.
1645 @param[out] field_name Returned name of the field at index
1646 \p index (can be \c NULL).
1647 @param[out] field_type Returned field type of the field
1648 at index \p index (can be \c NULL).
1649 @param[in] index Index of the field to get from
1650 \p struct_field_type.
1651 @returns 0 on success, or a negative value on error.
1653 @prenotnull{struct_field_type}
1654 @preisstructft{struct_field_type}
1655 @pre \p index is lesser than the number of fields contained in the
1656 structure field type \p struct_field_type (see
1657 bt_ctf_field_type_structure_get_field_count()).
1658 @postrefcountsame{struct_field_type}
1659 @post <strong>On success</strong>, the returned field's type is placed
1660 in \p *field_type and its reference count is incremented.
1662 @sa bt_ctf_field_type_structure_get_field_type_by_name(): Finds a
1663 structure field type's field by name.
1665 extern int bt_ctf_field_type_structure_get_field(
1666 struct bt_ctf_field_type
*struct_field_type
,
1667 const char **field_name
, struct bt_ctf_field_type
**field_type
,
1671 @brief Returns the type of the field named \p field_name found in
1672 the @structft \p struct_field_type.
1674 @param[in] struct_field_type Structure field type of which to get
1676 @param[in] field_name Name of the field to find.
1677 @returns Type of the field named \p field_name in
1678 \p struct_field_type, or
1681 @prenotnull{struct_field_type}
1682 @prenotnull{field_name}
1683 @preisstructft{struct_field_type}
1684 @postrefcountsame{struct_field_type}
1685 @postsuccessrefcountretinc
1687 @sa bt_ctf_field_type_structure_get_field(): Finds a
1688 structure field type's field by index.
1691 struct bt_ctf_field_type
*bt_ctf_field_type_structure_get_field_type_by_name(
1692 struct bt_ctf_field_type
*struct_field_type
,
1693 const char *field_name
);
1696 @brief Adds a field named \p field_name with the @ft
1697 \p field_type to the @structft \p struct_field_type.
1699 On success, \p field_type becomes the child of \p struct_field_type.
1701 This function adds the new field after the current last field of
1702 \p struct_field_type (append mode).
1704 You \em cannot add a field named \p field_name if there's already a
1705 field named \p field_name in \p struct_field_type.
1707 @param[in] struct_field_type Structure field type to which to add
1709 @param[in] field_type Field type of the field to add to
1710 \p struct_field_type.
1711 @param[in] field_name Name of the field to add to
1712 \p struct_field_type
1713 (copied on success).
1714 @returns 0 on success, or a negative value on error.
1716 @prenotnull{struct_field_type}
1717 @prenotnull{field_type}
1718 @prenotnull{field_name}
1719 @preisstructft{struct_field_type}
1720 @pre \p field_type is not and does not contain \p struct_field_type,
1721 recursively, as a field's type.
1722 @prehot{struct_field_type}
1723 @postrefcountsame{struct_field_type}
1724 @postsuccessrefcountinc{field_type}
1726 extern int bt_ctf_field_type_structure_add_field(
1727 struct bt_ctf_field_type
*struct_field_type
,
1728 struct bt_ctf_field_type
*field_type
,
1729 const char *field_name
);
1734 @defgroup ctfirarrayfieldtype CTF IR array field type
1735 @ingroup ctfirfieldtypes
1736 @brief CTF IR array field type.
1739 #include <babeltrace/ctf-ir/field-types.h>
1742 A CTF IR <strong><em>array field type</em></strong> is a field type that
1743 you can use to create concrete @arrayfields.
1745 You can create an array field type
1746 with bt_ctf_field_type_array_create(). This function needs
1747 the @ft of the fields contained by the array fields described by the
1748 array field type to create.
1753 @addtogroup ctfirarrayfieldtype
1758 @brief Creates a default @arrayft with
1759 \p element_field_type as the field type of the fields contained
1760 in its described @arrayfields of length \p length.
1762 @param[in] element_field_type Field type of the fields contained in
1763 the array fields described by the
1764 created array field type.
1765 @param[in] length Length of the array fields described by
1766 the created array field type.
1767 @returns Created array field type, or
1770 @prenotnull{element_field_type}
1771 @postsuccessrefcountinc{element_field_type}
1772 @postsuccessrefcountret1
1774 extern struct bt_ctf_field_type
*bt_ctf_field_type_array_create(
1775 struct bt_ctf_field_type
*element_field_type
,
1776 unsigned int length
);
1779 @brief Returns the @ft of the @fields contained in
1780 the @arrayfields described by the @arrayft \p array_field_type.
1782 @param[in] array_field_type Array field type of which to get
1783 the type of the fields contained in its
1784 described array fields.
1785 @returns Type of the fields contained in the
1786 array fields described by
1787 \p array_field_type, or \c NULL
1790 @prenotnull{array_field_type}
1791 @preisarrayft{array_field_type}
1792 @postrefcountsame{array_field_type}
1793 @postsuccessrefcountretinc
1795 extern struct bt_ctf_field_type
*bt_ctf_field_type_array_get_element_type(
1796 struct bt_ctf_field_type
*array_field_type
);
1799 @brief Returns the number of @fields contained in the
1800 @arrayfields described by the @arrayft \p array_field_type.
1802 @param[in] array_field_type Array field type of which to get
1803 the number of fields contained in its
1804 described array fields.
1805 @returns Number of fields contained in the
1806 array fields described by
1807 \p array_field_type, or a negative value
1810 @prenotnull{array_field_type}
1811 @preisarrayft{array_field_type}
1812 @postrefcountsame{array_field_type}
1814 extern int64_t bt_ctf_field_type_array_get_length(
1815 struct bt_ctf_field_type
*array_field_type
);
1820 @defgroup ctfirseqfieldtype CTF IR sequence field type
1821 @ingroup ctfirfieldtypes
1822 @brief CTF IR sequence field type.
1825 #include <babeltrace/ctf-ir/field-types.h>
1828 A CTF IR <strong><em>sequence field type</em></strong> is
1829 a field type that you can use to create concrete @seqfields.
1831 You can create a sequence field type with
1832 bt_ctf_field_type_sequence_create(). This function needs the @ft
1833 of the fields contained by the sequence fields described by the created
1834 sequence field type. This function also needs the length name of the
1835 sequence field type to create. The length name is used to automatically
1836 resolve the length's field type. See \ref ctfirfieldtypes to learn more
1837 about the automatic resolving.
1842 @addtogroup ctfirseqfieldtype
1847 @brief Creates a default @seqft with \p element_field_type as the
1848 @ft of the @fields contained in its described @seqfields
1849 with the length name \p length_name.
1851 \p length_name can be an absolute or relative reference. See
1852 <a href="http://diamon.org/ctf/">CTF</a> for more details.
1854 @param[in] element_field_type Field type of the fields contained in
1855 the sequence fields described by the
1856 created sequence field type.
1857 @param[in] length_name Length name (copied on success).
1858 @returns Created array field type, or
1861 @prenotnull{element_field_type}
1862 @prenotnull{length_name}
1863 @postsuccessrefcountinc{element_field_type}
1864 @postsuccessrefcountret1
1866 extern struct bt_ctf_field_type
*bt_ctf_field_type_sequence_create(
1867 struct bt_ctf_field_type
*element_field_type
,
1868 const char *length_name
);
1871 @brief Returns the @ft of the @fields contained in the @seqft
1872 described by the @seqft \p sequence_field_type.
1874 @param[in] sequence_field_type Sequence field type of which to get
1875 the type of the fields contained in its
1876 described sequence fields.
1877 @returns Type of the fields contained in the
1878 sequence fields described by
1879 \p sequence_field_type, or \c NULL
1882 @prenotnull{sequence_field_type}
1883 @preisseqft{sequence_field_type}
1884 @postrefcountsame{sequence_field_type}
1885 @postsuccessrefcountretinc
1887 extern struct bt_ctf_field_type
*bt_ctf_field_type_sequence_get_element_type(
1888 struct bt_ctf_field_type
*sequence_field_type
);
1891 @brief Returns the length name of the @seqft \p sequence_field_type.
1893 On success, \p sequence_field_type remains the sole owner of
1894 the returned string.
1896 @param[in] sequence_field_type Sequence field type of which to get the
1898 @returns Length name of \p sequence_field_type,
1899 or \c NULL on error.
1901 @prenotnull{sequence_field_type}
1902 @preisseqft{sequence_field_type}
1904 @sa bt_ctf_field_type_sequence_get_length_field_path(): Returns the
1905 length's CTF IR field path of a given sequence field type.
1907 extern const char *bt_ctf_field_type_sequence_get_length_field_name(
1908 struct bt_ctf_field_type
*sequence_field_type
);
1911 @brief Returns the length's CTF IR field path of the @seqft
1912 \p sequence_field_type.
1914 The length's field path of a sequence field type is set when automatic
1915 resolving is performed (see \ref ctfirfieldtypes).
1917 @param[in] sequence_field_type Sequence field type of which to get the
1918 length's field path.
1919 @returns Length's field path of
1920 \p sequence_field_type, or
1921 \c NULL if the length's field path is
1922 not set yet is not set or on error.
1924 @prenotnull{sequence_field_type}
1925 @preisseqft{sequence_field_type}
1926 @postsuccessrefcountretinc
1928 @sa bt_ctf_field_type_sequence_get_length_field_name(): Returns the
1929 length's name of a given sequence field type.
1931 extern struct bt_ctf_field_path
*bt_ctf_field_type_sequence_get_length_field_path(
1932 struct bt_ctf_field_type
*sequence_field_type
);
1937 @defgroup ctfirvarfieldtype CTF IR variant field type
1938 @ingroup ctfirfieldtypes
1939 @brief CTF IR variant field type.
1942 #include <babeltrace/ctf-ir/field-types.h>
1945 A CTF IR <strong><em>variant field type</em></strong> is
1946 a field type that you can use to create concrete @varfields.
1948 You can create a variant field type with
1949 bt_ctf_field_type_variant_create(). This function expects you to pass
1950 both the tag's @enumft and the tag name of the variant field type to
1951 create. The tag's field type is optional, as the Babeltrace system can
1952 automatically resolve it using the tag name. You can leave the tag name
1953 to \c NULL initially, and set it later with
1954 bt_ctf_field_type_variant_set_tag_name(). The tag name must be set when
1955 the variant field type is frozen. See \ref ctfirfieldtypes to learn more
1956 about the automatic resolving and the conditions under which a field
1959 You can add a field to a variant field type with
1960 bt_ctf_field_type_variant_add_field(). All the field names of a
1961 variant field type \em must exist as mapping names in its tag's @enumft.
1963 The effective alignment of the @varfields described by a
1964 variant field type is always 1, but the individual fields of a
1965 @varfield can have custom alignments.
1967 You can set the byte order of <em>all the contained fields</em>,
1968 recursively, of a variant field type with the common
1969 bt_ctf_field_type_set_byte_order() function.
1974 @addtogroup ctfirvarfieldtype
1979 @brief Creates a default, empty @varft with the tag's @enumft
1980 \p tag_field_type and the tag name \p tag_name.
1982 \p tag_field_type can be \c NULL; the tag's field type can be
1983 automatically resolved from the variant field type's tag name (see
1984 \ref ctfirfieldtypes). If \p tag_name is \c NULL, it \em must be set
1985 with bt_ctf_field_type_variant_set_tag_name() \em before the variant
1986 field type is frozen.
1988 \p tag_name can be an absolute or relative reference. See
1989 <a href="http://diamon.org/ctf/">CTF</a> for more details.
1991 @param[in] tag_field_type Tag's enumeration field type
1993 @param[in] tag_name Tag name (copied on success,
1995 @returns Created variant field type, or
1998 @pre \p tag_field_type is an enumeration field type or \c NULL.
1999 @post <strong>On success, if \p tag_field_type is not \c NULL</strong>,
2000 its reference count is incremented.
2001 @postsuccessrefcountret1
2003 extern struct bt_ctf_field_type
*bt_ctf_field_type_variant_create(
2004 struct bt_ctf_field_type
*tag_field_type
,
2005 const char *tag_name
);
2008 @brief Returns the tag's @enumft of the @varft \p variant_field_type.
2010 @param[in] variant_field_type Variant field type of which to get
2011 the tag's enumeration field type.
2012 @returns Tag's enumeration field type of
2013 \p variant_field_type, or \c NULL if the
2014 tag's field type is not set or on
2017 @prenotnull{variant_field_type}
2018 @preisvarft{variant_field_type}
2019 @postrefcountsame{variant_field_type}
2020 @postsuccessrefcountretinc
2022 extern struct bt_ctf_field_type
*bt_ctf_field_type_variant_get_tag_type(
2023 struct bt_ctf_field_type
*variant_field_type
);
2026 @brief Returns the tag name of the @varft \p variant_field_type.
2028 On success, \p variant_field_type remains the sole owner of
2029 the returned string.
2031 @param[in] variant_field_type Variant field type of which to get the
2033 @returns Tag name of \p variant_field_type, or
2034 \c NULL if the tag name is not set or
2037 @prenotnull{variant_field_type}
2038 @preisvarft{variant_field_type}
2040 @sa bt_ctf_field_type_variant_set_tag_name(): Sets the tag name of
2041 a given variant field type.
2042 @sa bt_ctf_field_type_variant_get_tag_field_path(): Returns the tag's
2043 CTF IR field path of a given variant field type.
2045 extern const char *bt_ctf_field_type_variant_get_tag_name(
2046 struct bt_ctf_field_type
*variant_field_type
);
2049 @brief Sets the tag name of the @varft \p variant_field_type.
2051 \p tag_name can be an absolute or relative reference. See
2052 <a href="http://diamon.org/ctf/">CTF</a> for more details.
2054 @param[in] variant_field_type Variant field type of which to set
2056 @param[in] tag_name Tag name of \p variant_field_type
2057 (copied on success).
2058 @returns 0 on success, or a negative value on error.
2060 @prenotnull{variant_field_type}
2062 @prehot{variant_field_type}
2063 @postrefcountsame{variant_field_type}
2065 @sa bt_ctf_field_type_variant_get_tag_name(): Returns the tag name of
2066 a given variant field type.
2068 extern int bt_ctf_field_type_variant_set_tag_name(
2069 struct bt_ctf_field_type
*variant_field_type
,
2070 const char *tag_name
);
2073 @brief Returns the tag's CTF IR field path of the @varft
2074 \p variant_field_type.
2076 The tag's field path of a variant field type is set when automatic
2077 resolving is performed (see \ref ctfirfieldtypes).
2079 @param[in] variant_field_type Variant field type of which to get the
2081 @returns Tag's field path of
2082 \p variant_field_type, or
2083 \c NULL if the tag's field path is not
2084 set yet is not set or on error.
2086 @prenotnull{variant_field_type}
2087 @preisvarft{variant_field_type}
2088 @postsuccessrefcountretinc
2090 @sa bt_ctf_field_type_variant_get_tag_name(): Returns the tag's
2091 name of a given variant field type.
2093 extern struct bt_ctf_field_path
*bt_ctf_field_type_variant_get_tag_field_path(
2094 struct bt_ctf_field_type
*variant_field_type
);
2097 @brief Returns the number of fields (choices) contained in the @varft
2098 \p variant_field_type.
2100 @param[in] variant_field_type Variant field type of which to get
2101 the number of contained fields.
2102 @returns Number of fields contained in
2103 \p variant_field_type, or a negative
2106 @prenotnull{variant_field_type}
2107 @preisvarft{variant_field_type}
2108 @postrefcountsame{variant_field_type}
2110 extern int bt_ctf_field_type_variant_get_field_count(
2111 struct bt_ctf_field_type
*variant_field_type
);
2114 @brief Returns the field (choice) of the @varft \p variant_field_type
2117 On success, the field's type is placed in \p *field_type if
2118 \p field_type is not \c NULL. The field's name is placed in
2119 \p *field_name if \p field_name is not \c NULL.
2120 \p variant_field_type remains the sole owner of \p *field_name.
2122 @param[in] variant_field_type Variant field type of which to get
2123 the field at index \p index.
2124 @param[out] field_name Returned name of the field at index
2125 \p index (can be \c NULL).
2126 @param[out] field_type Returned field type of the field
2127 at index \p index (can be \c NULL).
2128 @param[in] index Index of the field to get from
2129 \p variant_field_type.
2130 @returns 0 on success, or a negative value on error.
2132 @prenotnull{variant_field_type}
2133 @preisvarft{variant_field_type}
2134 @pre \p index is lesser than the number of fields contained in the
2135 variant field type \p variant_field_type (see
2136 bt_ctf_field_type_variant_get_field_count()).
2137 @postrefcountsame{variant_field_type}
2138 @post <strong>On success</strong>, the returned field's type is placed
2139 in \p *field_type and its reference count is incremented.
2141 @sa bt_ctf_field_type_variant_get_field_type_by_name(): Finds a variant
2142 field type's field by name.
2143 @sa bt_ctf_field_type_variant_get_field_type_from_tag(): Finds a variant
2144 field type's field by current tag value.
2146 extern int bt_ctf_field_type_variant_get_field(
2147 struct bt_ctf_field_type
*variant_field_type
,
2148 const char **field_name
,
2149 struct bt_ctf_field_type
**field_type
, int index
);
2152 @brief Returns the type of the field (choice) named \p field_name
2153 found in the @varft \p variant_field_type.
2155 @param[in] variant_field_type Variant field type of which to get
2157 @param[in] field_name Name of the field to find.
2158 @returns Type of the field named \p field_name in
2159 \p variant_field_type, or
2162 @prenotnull{variant_field_type}
2163 @prenotnull{field_name}
2164 @preisvarft{variant_field_type}
2165 @postrefcountsame{variant_field_type}
2166 @postsuccessrefcountretinc
2168 @sa bt_ctf_field_type_variant_get_field(): Finds a variant field type's
2170 @sa bt_ctf_field_type_variant_get_field_type_from_tag(): Finds a variant
2171 field type's field by current tag value.
2174 struct bt_ctf_field_type
*bt_ctf_field_type_variant_get_field_type_by_name(
2175 struct bt_ctf_field_type
*variant_field_type
,
2176 const char *field_name
);
2179 @brief Returns the type of the field (choice) selected by the value of
2180 the @enumfield \p tag_field in the @varft \p variant_field_type.
2182 \p tag_field is the current tag value.
2184 The field type of \p tag_field, as returned by bt_ctf_field_get_type(),
2185 \em must be equivalent to the field type returned by
2186 bt_ctf_field_type_variant_get_tag_type() for \p variant_field_type.
2188 @param[in] variant_field_type Variant field type of which to get
2190 @param[in] tag_field Current tag value (variant field type's
2192 @returns Type of the field selected by
2193 \p tag_field in \p variant_field_type,
2194 or \c NULL on error.
2196 @prenotnull{variant_field_type}
2197 @prenotnull{tag_field}
2198 @preisvarft{variant_field_type}
2199 @preisenumfield{tag_field}
2200 @postrefcountsame{variant_field_type}
2201 @postrefcountsame{tag_field}
2202 @postsuccessrefcountretinc
2204 @sa bt_ctf_field_type_variant_get_field(): Finds a variant field type's
2206 @sa bt_ctf_field_type_variant_get_field_type_by_name(): Finds a variant
2207 field type's field by name.
2210 struct bt_ctf_field_type
*bt_ctf_field_type_variant_get_field_type_from_tag(
2211 struct bt_ctf_field_type
*variant_field_type
,
2212 struct bt_ctf_field
*tag_field
);
2215 @brief Adds a field (a choice) named \p field_name with the @ft
2216 \p field_type to the @varft \p variant_field_type.
2218 On success, \p field_type becomes the child of \p variant_field_type.
2220 You \em cannot add a field named \p field_name if there's already a
2221 field named \p field_name in \p variant_field_type.
2223 \p field_name \em must name an existing mapping in the tag's
2224 enumeration field type of \p variant_field_type.
2226 @param[in] variant_field_type Variant field type to which to add
2228 @param[in] field_type Field type of the field to add to
2229 \p variant_field_type.
2230 @param[in] field_name Name of the field to add to
2231 \p variant_field_type
2232 (copied on success).
2233 @returns 0 on success, or a negative value on error.
2235 @prenotnull{variant_field_type}
2236 @prenotnull{field_type}
2237 @prenotnull{field_name}
2238 @preisvarft{variant_field_type}
2239 @pre \p field_type is not and does not contain \p variant_field_type,
2240 recursively, as a field's type.
2241 @prehot{variant_field_type}
2242 @postrefcountsame{variant_field_type}
2243 @postsuccessrefcountinc{field_type}
2245 extern int bt_ctf_field_type_variant_add_field(
2246 struct bt_ctf_field_type
*variant_field_type
,
2247 struct bt_ctf_field_type
*field_type
,
2248 const char *field_name
);
2256 #endif /* BABELTRACE_CTF_IR_FIELD_TYPES_H */