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
;
201 struct bt_ctf_field_type_enumeration_mapping_iterator
;
203 /** @cond DOCUMENT */
206 * Babeltrace 1.x enumerations that were also used in CTF writer's API.
207 * They are left here for backward compatibility reasons, but
208 * enum bt_ctf_type_id and enum bt_ctf_string_encoding should be used
209 * in new code. Both new enumerations are compatible with their legacy
213 CTF_TYPE_UNKNOWN
= 0,
219 CTF_TYPE_UNTAGGED_VARIANT
,
229 enum ctf_string_encoding
{
242 /// Unknown, used for errors.
243 BT_CTF_SCOPE_UNKNOWN
= -1,
245 /// Trace packet header.
246 BT_CTF_SCOPE_TRACE_PACKET_HEADER
= 1,
248 /// Stream packet context.
249 BT_CTF_SCOPE_STREAM_PACKET_CONTEXT
= 2,
251 /// Stream event header.
252 BT_CTF_SCOPE_STREAM_EVENT_HEADER
= 3,
254 /// Stream event context.
255 BT_CTF_SCOPE_STREAM_EVENT_CONTEXT
= 4,
258 BT_CTF_SCOPE_EVENT_CONTEXT
= 5,
261 BT_CTF_SCOPE_EVENT_PAYLOAD
= 6,
264 BT_CTF_SCOPE_ENV
= 0,
265 BT_CTF_SCOPE_EVENT_FIELDS
= 6,
270 @name Type information
275 @brief Type ID of a @ft.
277 enum bt_ctf_type_id
{
278 /// Unknown, used for errors.
279 BT_CTF_TYPE_ID_UNKNOWN
= CTF_TYPE_UNKNOWN
,
281 /// \ref ctfirintfieldtype
282 BT_CTF_TYPE_ID_INTEGER
= CTF_TYPE_INTEGER
,
284 /// \ref ctfirfloatfieldtype
285 BT_CTF_TYPE_ID_FLOAT
= CTF_TYPE_FLOAT
,
287 /// \ref ctfirenumfieldtype
288 BT_CTF_TYPE_ID_ENUM
= CTF_TYPE_ENUM
,
290 /// \ref ctfirstringfieldtype
291 BT_CTF_TYPE_ID_STRING
= CTF_TYPE_STRING
,
293 /// \ref ctfirstructfieldtype
294 BT_CTF_TYPE_ID_STRUCT
= CTF_TYPE_STRUCT
,
297 BT_CTF_TYPE_ID_UNTAGGED_VARIANT
= CTF_TYPE_UNTAGGED_VARIANT
,
300 /// \ref ctfirarrayfieldtype
301 BT_CTF_TYPE_ID_ARRAY
= CTF_TYPE_ARRAY
,
303 /// \ref ctfirseqfieldtype
304 BT_CTF_TYPE_ID_SEQUENCE
= CTF_TYPE_SEQUENCE
,
306 /// \ref ctfirvarfieldtype
307 BT_CTF_TYPE_ID_VARIANT
= CTF_TYPE_VARIANT
,
309 /// Number of enumeration entries.
310 BT_CTF_NR_TYPE_IDS
= NR_CTF_TYPES
,
314 @brief Returns the type ID of the @ft \p field_type.
316 @param[in] field_type Field type of which to get the type ID.
317 @returns Type ID of \p field_type,
318 or #BT_CTF_TYPE_ID_UNKNOWN on error.
320 @prenotnull{field_type}
321 @postrefcountsame{field_type}
323 @sa #bt_ctf_type_id: CTF IR field type ID.
324 @sa bt_ctf_field_type_is_integer(): Returns whether or not a given
325 field type is a @intft.
326 @sa bt_ctf_field_type_is_floating_point(): Returns whether or not a
327 given field type is a @floatft.
328 @sa bt_ctf_field_type_is_enumeration(): Returns whether or not a given
329 field type is a @enumft.
330 @sa bt_ctf_field_type_is_string(): Returns whether or not a given
331 field type is a @stringft.
332 @sa bt_ctf_field_type_is_structure(): Returns whether or not a given
333 field type is a @structft.
334 @sa bt_ctf_field_type_is_array(): Returns whether or not a given
335 field type is a @arrayft.
336 @sa bt_ctf_field_type_is_sequence(): Returns whether or not a given
337 field type is a @seqft.
338 @sa bt_ctf_field_type_is_variant(): Returns whether or not a given
339 field type is a @varft.
341 extern enum bt_ctf_type_id
bt_ctf_field_type_get_type_id(
342 struct bt_ctf_field_type
*field_type
);
345 @brief Returns whether or not the @ft \p field_type is a @intft.
347 @param[in] field_type Field type to check (can be \c NULL).
348 @returns 1 if \p field_type is an integer field type,
349 or 0 otherwise (including if \p field_type is
352 @prenotnull{field_type}
353 @postrefcountsame{field_type}
355 @sa bt_ctf_field_type_get_type_id(): Returns the type ID of a given
358 extern int bt_ctf_field_type_is_integer(struct bt_ctf_field_type
*field_type
);
361 @brief Returns whether or not the @ft \p field_type is a @floatft.
363 @param[in] field_type Field type to check (can be \c NULL).
364 @returns 1 if \p field_type is a floating point
366 or 0 otherwise (including if \p field_type is
369 @postrefcountsame{field_type}
371 @sa bt_ctf_field_type_get_type_id(): Returns the type ID of a given
374 extern int bt_ctf_field_type_is_floating_point(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 1 if \p field_type is an enumeration field type,
381 or 0 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 int bt_ctf_field_type_is_enumeration(struct bt_ctf_field_type
*field_type
);
392 @brief Returns whether or not the @ft \p field_type is a @stringft.
394 @param[in] field_type Field type to check (can be \c NULL).
395 @returns 1 if \p field_type is a string field type,
396 or 0 otherwise (including if \p field_type is
399 @postrefcountsame{field_type}
401 @sa bt_ctf_field_type_get_type_id(): Returns the type ID of a given
404 extern int bt_ctf_field_type_is_string(struct bt_ctf_field_type
*field_type
);
407 @brief Returns whether or not the @ft \p field_type is a @structft.
409 @param[in] field_type Field type to check (can be \c NULL).
410 @returns 1 if \p field_type is a structure field type,
411 or 0 otherwise (including if \p field_type is
414 @postrefcountsame{field_type}
416 @sa bt_ctf_field_type_get_type_id(): Returns the type ID of a given
419 extern int bt_ctf_field_type_is_structure(struct bt_ctf_field_type
*field_type
);
422 @brief Returns whether or not the @ft \p field_type is a @arrayft.
424 @param[in] field_type Field type to check (can be \c NULL).
425 @returns 1 if \p field_type is an array field type,
426 or 0 otherwise (including if \p field_type is
429 @postrefcountsame{field_type}
431 @sa bt_ctf_field_type_get_type_id(): Returns the type ID of a given
434 extern int bt_ctf_field_type_is_array(struct bt_ctf_field_type
*field_type
);
437 @brief Returns whether or not the @ft \p field_type is a @seqft.
439 @param[in] field_type Field type to check (can be \c NULL).
440 @returns 1 if \p field_type is a sequence field type,
441 or 0 otherwise (including if \p field_type is
444 @postrefcountsame{field_type}
446 @sa bt_ctf_field_type_get_type_id(): Returns the type ID of a given
449 extern int bt_ctf_field_type_is_sequence(struct bt_ctf_field_type
*field_type
);
452 @brief Returns whether or not the @ft \p field_type is a @varft.
454 @param[in] field_type Field type to check (can be \c NULL).
455 @returns 1 if \p field_type is a variant field type,
456 or 0 otherwise (including if \p field_type is
459 @postrefcountsame{field_type}
461 @sa bt_ctf_field_type_get_type_id(): Returns the type ID of a given
464 extern int bt_ctf_field_type_is_variant(struct bt_ctf_field_type
*field_type
);
469 @name Common properties types and functions
474 @brief <a href="https://en.wikipedia.org/wiki/Endianness">Byte order</a>
477 enum bt_ctf_byte_order
{
478 /// Unknown, used for errors.
479 BT_CTF_BYTE_ORDER_UNKNOWN
= -1,
482 * Note that native, in the context of the CTF specification, is defined
483 * as "the byte order described in the trace" and does not mean that the
484 * host's endianness will be used.
486 /// Native (default) byte order.
487 BT_CTF_BYTE_ORDER_NATIVE
= 0,
490 BT_CTF_BYTE_ORDER_LITTLE_ENDIAN
,
493 BT_CTF_BYTE_ORDER_BIG_ENDIAN
,
495 /// Network byte order (big-endian).
496 BT_CTF_BYTE_ORDER_NETWORK
,
500 @brief String encoding of a @ft.
502 enum bt_ctf_string_encoding
{
503 /// Unknown, used for errors.
504 BT_CTF_STRING_ENCODING_UNKNOWN
= CTF_STRING_UNKNOWN
,
507 BT_CTF_STRING_ENCODING_NONE
= CTF_STRING_NONE
,
509 /// <a href="https://en.wikipedia.org/wiki/UTF-8">UTF-8</a>.
510 BT_CTF_STRING_ENCODING_UTF8
= CTF_STRING_UTF8
,
512 /// <a href="https://en.wikipedia.org/wiki/ASCII">ASCII</a>.
513 BT_CTF_STRING_ENCODING_ASCII
= CTF_STRING_ASCII
,
517 @brief Returns the alignment of the @fields described by
518 the @ft \p field_type.
520 @param[in] field_type Field type which describes the
521 fields of which to get the alignment.
522 @returns Alignment of the fields described by
523 \p field_type, or a negative value on error.
525 @prenotnull{field_type}
526 @postrefcountsame{field_type}
528 @sa bt_ctf_field_type_set_alignment(): Sets the alignment
529 of the fields described by a given field type.
531 extern int bt_ctf_field_type_get_alignment(
532 struct bt_ctf_field_type
*field_type
);
535 @brief Sets the alignment of the @fields described by the
536 @ft \p field_type to \p alignment.
538 \p alignment \em must be greater than 0 and a power of two.
540 @param[in] field_type Field type which describes the fields of
541 which to set the alignment.
542 @param[in] alignment Alignment of the fields described by
544 @returns 0 on success, or a negative value on error.
546 @prenotnull{field_type}
548 @pre \p alignment is greater than 0 and a power of two.
549 @postrefcountsame{field_type}
551 @sa bt_ctf_field_type_get_alignment(): Returns the alignment of the
552 fields described by a given field type.
554 extern int bt_ctf_field_type_set_alignment(struct bt_ctf_field_type
*field_type
,
555 unsigned int alignment
);
558 @brief Returns the byte order of the @fields described by
559 the @ft \p field_type.
561 You can only call this function if \p field_type is a @intft, a
562 @floatft, or a @enumft.
564 @param[in] field_type Field type which describes the
565 fields of which to get the byte order.
566 @returns Byte order of the fields described by
567 \p field_type, or #BT_CTF_BYTE_ORDER_UNKNOWN on
570 @prenotnull{field_type}
571 @pre \p field_type is a @intft, a @floatft, or a @enumft.
572 @postrefcountsame{field_type}
574 @sa bt_ctf_field_type_set_byte_order(): Sets the byte order
575 of the fields described by a given field type.
577 extern enum bt_ctf_byte_order
bt_ctf_field_type_get_byte_order(
578 struct bt_ctf_field_type
*field_type
);
581 @brief Sets the byte order of the @fields described by the
582 @ft \p field_type to \p byte_order.
584 If \p field_type is a compound field type, this function also
585 recursively sets the byte order of its children to \p byte_order.
587 @param[in] field_type Field type which describes the fields of
588 which to set the byte order.
589 @param[in] byte_order Alignment of the fields described by
591 @returns 0 on success, or a negative value on error.
593 @prenotnull{field_type}
595 @pre \p byte_order is #BT_CTF_BYTE_ORDER_NATIVE,
596 #BT_CTF_BYTE_ORDER_LITTLE_ENDIAN, #BT_CTF_BYTE_ORDER_BIG_ENDIAN,
597 or #BT_CTF_BYTE_ORDER_NETWORK.
598 @postrefcountsame{field_type}
600 @sa bt_ctf_field_type_get_byte_order(): Returns the byte order of the
601 fields described by a given field type.
603 extern int bt_ctf_field_type_set_byte_order(
604 struct bt_ctf_field_type
*field_type
,
605 enum bt_ctf_byte_order byte_order
);
610 @name Utility functions
615 @brief Returns whether or not the @ft \p field_type_a
616 is equivalent to the field type \p field_type_b.
618 You \em must use this function to compare two field types: it is not
619 safe to compare two pointer values directly, because, for internal
620 reasons, some parts of the Babeltrace system can copy user field types
621 and discard the original ones.
623 @param[in] field_type_a Field type to compare to \p field_type_b.
624 @param[in] field_type_b Field type to compare to \p field_type_a.
625 @returns 0 if \p field_type_a is equivalent to
626 \p field_type_b, 1 if they are not equivalent,
627 or a negative value on error.
629 @prenotnull{field_type_a}
630 @prenotnull{field_type_b}
631 @postrefcountsame{field_type_a}
632 @postrefcountsame{field_type_b}
634 extern int bt_ctf_field_type_compare(struct bt_ctf_field_type
*field_type_a
,
635 struct bt_ctf_field_type
*field_type_b
);
638 @brief Creates a \em deep copy of the @ft \p field_type.
640 You can copy a frozen field type: the resulting copy is
643 This function resets the tag field type of a copied @varft. The
644 automatic field resolving which some functions of the API perform
645 can set it again when the returned field type is used (learn more
646 in the detailed description of this module).
648 @param[in] field_type Field type to copy.
649 @returns Deep copy of \p field_type on success,
652 @prenotnull{field_type}
653 @postrefcountsame{field_type}
654 @postsuccessrefcountret1
655 @post <strong>On success</strong>, the returned field type is not frozen.
657 extern struct bt_ctf_field_type
*bt_ctf_field_type_copy(
658 struct bt_ctf_field_type
*field_type
);
665 @defgroup ctfirintfieldtype CTF IR integer field type
666 @ingroup ctfirfieldtypes
667 @brief CTF IR integer field type.
670 #include <babeltrace/ctf-ir/field-types.h>
673 A CTF IR <strong><em>integer field type</em></strong> is a field type that
674 you can use to create concrete @intfield objects.
676 You can create an integer field type
677 with bt_ctf_field_type_integer_create().
679 An integer field type has the following properties:
684 <th>Value at creation
689 <td>\b Alignment (bits) of the described integer fields
691 <td>bt_ctf_field_type_get_alignment()
692 <td>bt_ctf_field_type_set_alignment()
695 <td><strong>Byte order</strong> of the described integer fields
696 <td>#BT_CTF_BYTE_ORDER_NATIVE
697 <td>bt_ctf_field_type_get_byte_order()
698 <td>bt_ctf_field_type_set_byte_order()
701 <td><strong>Storage size</strong> (bits) of the described
703 <td>Specified at creation
704 <td>bt_ctf_field_type_integer_get_size()
705 <td>None: specified at creation (bt_ctf_field_type_integer_create())
708 <td><strong>Signedness</strong> of the described integer fields
710 <td>bt_ctf_field_type_integer_get_signed()
711 <td>bt_ctf_field_type_integer_set_signed()
714 <td><strong>Preferred display base</strong> of the described
716 <td>#BT_CTF_INTEGER_BASE_DECIMAL
717 <td>bt_ctf_field_type_integer_get_base()
718 <td>bt_ctf_field_type_integer_set_base()
721 <td>\b Encoding of the described integer fields
722 <td>#BT_CTF_STRING_ENCODING_NONE
723 <td>bt_ctf_field_type_integer_get_encoding()
724 <td>bt_ctf_field_type_integer_set_encoding()
728 \link ctfirclockclass CTF IR clock class\endlink</strong>
730 <td>bt_ctf_field_type_integer_get_mapped_clock_class()
731 <td>bt_ctf_field_type_integer_set_mapped_clock_class()
737 @sa \ref ctfirfieldtypesexamples_intfieldtype "Examples"
739 @addtogroup ctfirintfieldtype
744 @brief Preferred display base (radix) of a @intft.
746 enum bt_ctf_integer_base
{
747 /// Unknown, used for errors.
748 BT_CTF_INTEGER_BASE_UNKNOWN
= -1,
751 BT_CTF_INTEGER_BASE_BINARY
= 2,
754 BT_CTF_INTEGER_BASE_OCTAL
= 8,
757 BT_CTF_INTEGER_BASE_DECIMAL
= 10,
760 BT_CTF_INTEGER_BASE_HEXADECIMAL
= 16,
764 @brief Creates a default @intft with \p size bits as the storage size
765 of the @intfields it describes.
767 @param[in] size Storage size (bits) of the described integer fields.
768 @returns Created integer field type, or \c NULL on error.
770 @pre \p size is greater than 0 and lesser than or equal to 64.
771 @postsuccessrefcountret1
773 extern struct bt_ctf_field_type
*bt_ctf_field_type_integer_create(
777 @brief Returns the storage size, in bits, of the @intfields
778 described by the @intft \p int_field_type.
780 @param[in] int_field_type Integer field type which describes the
781 integer fields of which to get the
783 @returns Storage size (bits) of the integer
784 fields described by \p int_field_type,
785 or a negative value on error.
787 @prenotnull{int_field_type}
788 @preisintft{int_field_type}
789 @postrefcountsame{int_field_type}
791 extern int bt_ctf_field_type_integer_get_size(
792 struct bt_ctf_field_type
*int_field_type
);
795 @brief Returns whether or not the @intfields described by the @intft
796 \p int_field_type are signed.
798 @param[in] int_field_type Integer field type which describes the
799 integer fields of which to get the
801 @returns 1 if the integer fields described by
802 \p int_field_type are signed, 0 if they
803 are unsigned, or a negative value on
806 @prenotnull{int_field_type}
807 @preisintft{int_field_type}
808 @postrefcountsame{int_field_type}
810 @sa bt_ctf_field_type_integer_set_signed(): Sets the signedness of the
811 integer fields described by a given integer field type.
813 extern int bt_ctf_field_type_integer_get_signed(
814 struct bt_ctf_field_type
*int_field_type
);
817 @brief Sets whether or not the @intfields described by
818 the @intft \p int_field_type are signed.
820 @param[in] int_field_type Integer field type which describes the
821 integer fields of which to set the
823 @param[in] is_signed Signedness of the integer fields
824 described by \p int_field_type; 0 means
825 \em unsigned, 1 means \em signed.
826 @returns 0 on success, or a negative value on error.
828 @prenotnull{int_field_type}
829 @preisintft{int_field_type}
830 @prehot{int_field_type}
831 @pre \p is_signed is 0 or 1.
832 @postrefcountsame{event_class}
834 @sa bt_ctf_field_type_integer_get_signed(): Returns the signedness of
835 the integer fields described by a given integer field type.
837 extern int bt_ctf_field_type_integer_set_signed(
838 struct bt_ctf_field_type
*int_field_type
, int is_signed
);
841 @brief Returns the preferred display base (radix) of the @intfields
842 described by the @intft \p int_field_type.
844 @param[in] int_field_type Integer field type which describes the
845 integer fields of which to get the
846 preferred display base.
847 @returns Preferred display base of the integer
848 fields described by \p int_field_type,
849 or #BT_CTF_INTEGER_BASE_UNKNOWN on
852 @prenotnull{int_field_type}
853 @preisintft{int_field_type}
854 @postrefcountsame{int_field_type}
856 @sa bt_ctf_field_type_integer_set_base(): Sets the preferred display
857 base of the integer fields described by a given integer field
860 extern enum bt_ctf_integer_base
bt_ctf_field_type_integer_get_base(
861 struct bt_ctf_field_type
*int_field_type
);
864 @brief Sets the preferred display base (radix) of the @intfields
865 described by the @intft \p int_field_type to \p base.
867 @param[in] int_field_type Integer field type which describes the
868 integer fields of which to set the
869 preferred display base.
870 @param[in] base Preferred display base of the integer
871 fields described by \p int_field_type.
872 @returns 0 on success, or a negative value on error.
874 @prenotnull{int_field_type}
875 @preisintft{int_field_type}
876 @prehot{int_field_type}
877 @pre \p base is #BT_CTF_INTEGER_BASE_BINARY, #BT_CTF_INTEGER_BASE_OCTAL,
878 #BT_CTF_INTEGER_BASE_DECIMAL, or
879 #BT_CTF_INTEGER_BASE_HEXADECIMAL.
880 @postrefcountsame{int_field_type}
882 @sa bt_ctf_field_type_integer_get_base(): Returns the preferred display
883 base of the integer fields described by a given
886 extern int bt_ctf_field_type_integer_set_base(
887 struct bt_ctf_field_type
*int_field_type
,
888 enum bt_ctf_integer_base base
);
891 @brief Returns the encoding of the @intfields described by
892 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
897 @returns Encoding of the integer
898 fields described by \p int_field_type,
899 or #BT_CTF_STRING_ENCODING_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_encoding(): Sets the encoding
907 of the integer fields described by a given integer field type.
909 extern enum bt_ctf_string_encoding
bt_ctf_field_type_integer_get_encoding(
910 struct bt_ctf_field_type
*int_field_type
);
913 @brief Sets the encoding of the @intfields described by the @intft
914 \p int_field_type to \p encoding.
916 You can use this property, in CTF IR, to create "text" @arrayfts or
917 @seqfts. A text array field type is array field type with an unsigned,
918 8-bit integer field type having an encoding as its element field type.
920 @param[in] int_field_type Integer field type which describes the
921 integer fields of which to set the
923 @param[in] encoding Encoding of the integer
924 fields described by \p int_field_type.
925 @returns 0 on success, or a negative value on error.
927 @prenotnull{int_field_type}
928 @preisintft{int_field_type}
929 @prehot{int_field_type}
930 @pre \p encoding is #BT_CTF_STRING_ENCODING_NONE,
931 #BT_CTF_STRING_ENCODING_ASCII, or
932 #BT_CTF_STRING_ENCODING_UTF8.
933 @postrefcountsame{int_field_type}
935 @sa bt_ctf_field_type_integer_get_encoding(): Returns the encoding of
936 the integer fields described by a given integer field type.
938 extern int bt_ctf_field_type_integer_set_encoding(
939 struct bt_ctf_field_type
*int_field_type
,
940 enum bt_ctf_string_encoding encoding
);
943 @brief Returns the \link ctfirclockclass CTF IR clock class\endlink
944 mapped to the @intft \p int_field_type.
946 The mapped clock class, if any, indicates the class of the clock which
947 an @intfield described by \p int_field_type should sample or update.
948 This mapped clock class is only indicative.
950 @param[in] int_field_type Integer field type of which to get the
952 @returns Mapped clock class of \p int_field_type,
953 or \c NULL if there's no mapped clock
956 @prenotnull{int_field_type}
957 @preisintft{int_field_type}
958 @postrefcountsame{int_field_type}
959 @postsuccessrefcountretinc
961 @sa bt_ctf_field_type_integer_set_mapped_clock_class(): Sets the mapped
962 clock class of a given integer field type.
964 extern struct bt_ctf_clock_class
*bt_ctf_field_type_integer_get_mapped_clock_class(
965 struct bt_ctf_field_type
*int_field_type
);
968 @brief Sets the \link ctfirclockclass CTF IR clock class\endlink mapped
969 to the @intft \p int_field_type to \p clock_class.
971 The mapped clock class, if any, indicates the class of the clock which
972 an integer field described by \p int_field_type should sample or update.
973 This mapped clock class is only indicative.
975 @param[in] int_field_type Integer field type of which to set the
977 @param[in] clock_class Mapped clock class of \p int_field_type.
978 @returns 0 on success, or a negative value on error.
980 @prenotnull{int_field_type}
981 @prenotnull{clock_class}
982 @preisintft{int_field_type}
983 @prehot{int_field_type}
984 @postrefcountsame{int_field_type}
985 @postsuccessrefcountinc{clock_class}
987 @sa bt_ctf_field_type_integer_get_mapped_clock_class(): Returns the mapped
988 clock class of a given integer field type.
990 extern int bt_ctf_field_type_integer_set_mapped_clock_class(
991 struct bt_ctf_field_type
*int_field_type
,
992 struct bt_ctf_clock_class
*clock_class
);
997 @defgroup ctfirfloatfieldtype CTF IR floating point number field type
998 @ingroup ctfirfieldtypes
999 @brief CTF IR floating point number field type.
1002 #include <babeltrace/ctf-ir/field-types.h>
1005 A CTF IR <strong><em>floating point number field type</em></strong> is
1006 a field type that you can use to create concrete @floatfields.
1008 You can create a floating point number field type
1009 with bt_ctf_field_type_floating_point_create().
1011 A floating point number field type has the following properties:
1016 <th>Value at creation
1021 <td>\b Alignment (bits) of the described floating point
1024 <td>bt_ctf_field_type_get_alignment()
1025 <td>bt_ctf_field_type_set_alignment()
1028 <td><strong>Byte order</strong> of the described floating point
1030 <td>#BT_CTF_BYTE_ORDER_NATIVE
1031 <td>bt_ctf_field_type_get_byte_order()
1032 <td>bt_ctf_field_type_set_byte_order()
1035 <td><strong>Exponent storage size</strong> (bits) of the described
1036 floating point number fields
1038 <td>bt_ctf_field_type_floating_point_get_exponent_digits()
1039 <td>bt_ctf_field_type_floating_point_set_exponent_digits()
1042 <td><strong>Mantissa and sign storage size</strong> (bits) of the
1043 described floating point number fields
1044 <td>24 (23-bit mantissa, 1-bit sign)
1045 <td>bt_ctf_field_type_floating_point_get_mantissa_digits()
1046 <td>bt_ctf_field_type_floating_point_set_mantissa_digits()
1052 @sa \ref ctfirfieldtypesexamples_floatfieldtype "Examples"
1054 @addtogroup ctfirfloatfieldtype
1059 @brief Creates a default @floatft.
1061 @returns Created floating point number field type,
1062 or \c NULL on error.
1064 @postsuccessrefcountret1
1066 extern struct bt_ctf_field_type
*bt_ctf_field_type_floating_point_create(void);
1069 @brief Returns the exponent storage size of the @floatfields
1070 described by the @floatft \p float_field_type.
1072 @param[in] float_field_type Floating point number field type which
1073 describes the floating point number
1074 fields of which to get the exponent
1076 @returns Exponent storage size of the
1077 floating point number fields
1078 described by \p float_field_type,
1079 or a negative value on error.
1081 @prenotnull{float_field_type}
1082 @preisfloatft{float_field_type}
1083 @postrefcountsame{float_field_type}
1085 @sa bt_ctf_field_type_floating_point_set_exponent_digits(): Sets the
1086 exponent storage size of the floating point number fields
1087 described by a given floating point number field type.
1089 extern int bt_ctf_field_type_floating_point_get_exponent_digits(
1090 struct bt_ctf_field_type
*float_field_type
);
1093 @brief Sets the exponent storage size of the @floatfields described by
1094 the @floatft \p float_field_type to \p exponent_size.
1096 As of Babeltrace \btversion, \p exponent_size can only be 8 or 11.
1098 @param[in] float_field_type Floating point number field type which
1099 describes the floating point number
1100 fields of which to set the exponent
1102 @param[in] exponent_size Exponent storage size of the floating
1103 point number fields described by \p
1105 @returns 0 on success, or a negative value on error.
1107 @prenotnull{float_field_type}
1108 @preisfloatft{float_field_type}
1109 @prehot{float_field_type}
1110 @pre \p exponent_size is 8 or 11.
1111 @postrefcountsame{float_field_type}
1113 @sa bt_ctf_field_type_floating_point_get_exponent_digits(): Returns the
1114 exponent storage size of the floating point number fields
1115 described by a given floating point number field type.
1117 extern int bt_ctf_field_type_floating_point_set_exponent_digits(
1118 struct bt_ctf_field_type
*float_field_type
,
1119 unsigned int exponent_size
);
1122 @brief Returns the mantissa and sign storage size of the @floatfields
1123 described by the @floatft \p float_field_type.
1125 On success, the returned value is the sum of the mantissa \em and
1128 @param[in] float_field_type Floating point number field type which
1129 describes the floating point number
1130 fields of which to get the mantissa and
1132 @returns Mantissa and sign storage size of the
1133 floating point number fields
1134 described by \p float_field_type,
1135 or a negative value on error.
1137 @prenotnull{float_field_type}
1138 @preisfloatft{float_field_type}
1139 @postrefcountsame{float_field_type}
1141 @sa bt_ctf_field_type_floating_point_set_mantissa_digits(): Sets the
1142 mantissa and size storage size of the floating point number
1143 fields described by a given floating point number field type.
1145 extern int bt_ctf_field_type_floating_point_get_mantissa_digits(
1146 struct bt_ctf_field_type
*float_field_type
);
1149 @brief Sets the mantissa and sign storage size of the @floatfields
1150 described by the @floatft \p float_field_type to \p
1153 As of Babeltrace \btversion, \p mantissa_sign_size can only be 24 or 53.
1155 @param[in] float_field_type Floating point number field type which
1156 describes the floating point number
1157 fields of which to set the mantissa and
1159 @param[in] mantissa_sign_size Mantissa and sign storage size of the
1160 floating point number fields described
1161 by \p float_field_type.
1162 @returns 0 on success, or a negative value on error.
1164 @prenotnull{float_field_type}
1165 @preisfloatft{float_field_type}
1166 @prehot{float_field_type}
1167 @pre \p mantissa_sign_size is 24 or 53.
1168 @postrefcountsame{float_field_type}
1170 @sa bt_ctf_field_type_floating_point_get_mantissa_digits(): Returns the
1171 mantissa and sign storage size of the floating point number
1172 fields described by a given floating point number field type.
1174 extern int bt_ctf_field_type_floating_point_set_mantissa_digits(
1175 struct bt_ctf_field_type
*float_field_type
,
1176 unsigned int mantissa_sign_size
);
1180 struct bt_ctf_field_type_enumeration_mapping_iterator
*
1181 bt_ctf_field_type_enumeration_find_mappings_by_name(
1182 struct bt_ctf_field_type
*type
,
1185 struct bt_ctf_field_type_enumeration_mapping_iterator
*
1186 bt_ctf_field_type_enumeration_find_mappings_by_signed_value(
1187 struct bt_ctf_field_type
*type
,
1190 struct bt_ctf_field_type_enumeration_mapping_iterator
*
1191 bt_ctf_field_type_enumeration_find_mappings_by_unsigned_value(
1192 struct bt_ctf_field_type
*type
,
1195 int bt_ctf_field_type_enumeration_mapping_iterator_get_name(
1196 struct bt_ctf_field_type_enumeration_mapping_iterator
*iter
,
1197 const char **mapping_name
);
1199 int bt_ctf_field_type_enumeration_mapping_iterator_get_signed(
1200 struct bt_ctf_field_type_enumeration_mapping_iterator
*iter
,
1201 const char **mapping_name
, int64_t *lower
, int64_t *upper
);
1203 int bt_ctf_field_type_enumeration_mapping_iterator_get_unsigned(
1204 struct bt_ctf_field_type_enumeration_mapping_iterator
*iter
,
1205 const char **mapping_name
, uint64_t *lower
, uint64_t *upper
);
1207 int bt_ctf_field_type_enumeration_mapping_iterator_next(
1208 struct bt_ctf_field_type_enumeration_mapping_iterator
*iter
);
1211 @defgroup ctfirenumfieldtype CTF IR enumeration field type
1212 @ingroup ctfirfieldtypes
1213 @brief CTF IR enumeration field type.
1216 #include <babeltrace/ctf-ir/field-types.h>
1219 A CTF IR <strong><em>enumeration field type</em></strong> is
1220 a field type that you can use to create concrete @enumfields.
1222 You can create an enumeration field type with
1223 bt_ctf_field_type_enumeration_create(). This function needs a @intft
1224 which represents the storage field type of the created enumeration field
1225 type. In other words, an enumeration field type wraps an integer field
1226 type and adds label-value mappings to it.
1228 An enumeration mapping has:
1230 - A <strong>name</strong>.
1231 - A <strong>range of values</strong> given by a beginning and an ending
1232 value, both included in the range.
1234 You can add a mapping to an enumeration field type with
1235 bt_ctf_field_type_enumeration_add_mapping() or
1236 bt_ctf_field_type_enumeration_add_mapping_unsigned(), depending on the
1237 signedness of the wrapped @intft.
1239 Many mappings can share the same name, and the ranges of a given
1240 enumeration field type are allowed to overlap. For example,
1241 this is a valid set of mappings:
1250 The following set of mappings is also valid:
1259 Here, the range of the second \c APPLE mapping overlaps the range of
1260 the \c CHERRY mapping.
1265 @addtogroup ctfirenumfieldtype
1270 @brief Creates a default @enumft wrapping the @intft \p int_field_type.
1272 @param[in] int_field_type Integer field type wrapped by the
1273 created enumeration field type.
1274 @returns Created enumeration field type,
1275 or \c NULL on error.
1277 @prenotnull{int_field_type}
1278 @preisintft{int_field_type}
1279 @postsuccessrefcountinc{int_field_type}
1280 @postsuccessrefcountret1
1282 extern struct bt_ctf_field_type
*bt_ctf_field_type_enumeration_create(
1283 struct bt_ctf_field_type
*int_field_type
);
1286 @brief Returns the @intft wrapped by the @enumft \p enum_field_type.
1288 @param[in] enum_field_type Enumeration field type of which to get
1289 the wrapped integer field type.
1290 @returns Integer field type wrapped by
1291 \p enum_field_type, or \c NULL on
1294 @prenotnull{enum_field_type}
1295 @preisenumft{enum_field_type}
1296 @postrefcountsame{enum_field_type}
1297 @postsuccessrefcountretinc
1300 struct bt_ctf_field_type
*bt_ctf_field_type_enumeration_get_container_type(
1301 struct bt_ctf_field_type
*enum_field_type
);
1304 @brief Returns the number of mappings contained in the
1305 @enumft \p enum_field_type.
1307 @param[in] enum_field_type Enumeration field type of which to get
1308 the number of contained mappings.
1309 @returns Number of mappings contained in
1310 \p enum_field_type, or a negative
1313 @prenotnull{enum_field_type}
1314 @preisenumft{enum_field_type}
1315 @postrefcountsame{enum_field_type}
1317 extern int bt_ctf_field_type_enumeration_get_mapping_count(
1318 struct bt_ctf_field_type
*enum_field_type
);
1321 @brief Returns the signed mapping of the @enumft
1322 \p enum_field_type at index \p index.
1324 The @intft wrapped by \p enum_field_type, as returned by
1325 bt_ctf_field_type_enumeration_get_container_type(), must be \b signed
1326 to use this function.
1328 On success, \p enum_field_type remains the sole owner of \p *name.
1330 @param[in] enum_field_type Enumeration field type of which to get
1331 the mapping at index \p index.
1332 @param[in] index Index of the mapping to get from
1334 @param[out] name Returned name of the mapping at index
1336 @param[out] range_begin Returned beginning of the range
1337 (included) of the mapping at index \p
1339 @param[out] range_end Returned end of the range (included) of
1340 the mapping at index \p index.
1341 @returns 0 on success, or a negative value on error.
1343 @prenotnull{enum_field_type}
1345 @prenotnull{range_begin}
1346 @prenotnull{range_end}
1347 @preisenumft{enum_field_type}
1348 @pre The wrapped @intft of \p enum_field_type is signed.
1349 @pre \p index is lesser than the number of mappings contained in the
1350 enumeration field type \p enum_field_type (see
1351 bt_ctf_field_type_enumeration_get_mapping_count()).
1352 @postrefcountsame{enum_field_type}
1354 @sa bt_ctf_field_type_enumeration_get_mapping_signed(): Returns the
1355 signed mapping contained by a given enumeration field type
1358 extern int bt_ctf_field_type_enumeration_get_mapping_signed(
1359 struct bt_ctf_field_type
*enum_field_type
, int index
,
1360 const char **name
, int64_t *range_begin
, int64_t *range_end
);
1363 @brief Returns the unsigned mapping of the @enumft
1364 \p enum_field_type at index \p index.
1366 The @intft wrapped by \p enum_field_type, as returned by
1367 bt_ctf_field_type_enumeration_get_container_type(), must be
1368 \b unsigned to use this function.
1370 On success, \p enum_field_type remains the sole owner of \p *name.
1372 @param[in] enum_field_type Enumeration field type of which to get
1373 the mapping at index \p index.
1374 @param[in] index Index of the mapping to get from
1376 @param[out] name Returned name of the mapping at index
1378 @param[out] range_begin Returned beginning of the range
1379 (included) of the mapping at index \p
1381 @param[out] range_end Returned end of the range (included) of
1382 the mapping at index \p index.
1383 @returns 0 on success, or a negative value on error.
1385 @prenotnull{enum_field_type}
1387 @prenotnull{range_begin}
1388 @prenotnull{range_end}
1389 @preisenumft{enum_field_type}
1390 @pre The wrapped @intft of \p enum_field_type is unsigned.
1391 @pre \p index is lesser than the number of mappings contained in the
1392 enumeration field type \p enum_field_type (see
1393 bt_ctf_field_type_enumeration_get_mapping_count()).
1394 @postrefcountsame{enum_field_type}
1396 @sa bt_ctf_field_type_enumeration_get_mapping_unsigned(): Returns the
1397 unsigned mapping contained by a given enumeration field type
1400 extern int bt_ctf_field_type_enumeration_get_mapping_unsigned(
1401 struct bt_ctf_field_type
*enum_field_type
, int index
,
1402 const char **name
, uint64_t *range_begin
,
1403 uint64_t *range_end
);
1406 @brief Adds a mapping to the @enumft \p enum_field_type which maps the
1407 name \p name to the signed range \p range_begin (included) to
1408 \p range_end (included).
1410 Make \p range_begin and \p range_end the same value to add a mapping
1413 The @intft wrapped by \p enum_field_type, as returned by
1414 bt_ctf_field_type_enumeration_get_container_type(), must be
1415 \b signed to use this function.
1417 A mapping in \p enum_field_type can exist with the name \p name.
1419 @param[in] enum_field_type Enumeration field type to which to add
1421 @param[in] name Name of the mapping to add (copied
1423 @param[in] range_begin Beginning of the range of the mapping
1425 @param[in] range_end End of the range of the mapping
1427 @returns 0 on success, or a negative value on error.
1429 @prenotnull{enum_field_type}
1431 @preisenumft{enum_field_type}
1432 @pre The wrapped @intft of \p enum_field_type is signed.
1433 @pre \p range_end is greater than or equal to \p range_begin.
1434 @postrefcountsame{enum_field_type}
1436 @sa bt_ctf_field_type_enumeration_add_mapping_unsigned(): Adds an
1437 unsigned mapping to a given enumeration field type.
1439 extern int bt_ctf_field_type_enumeration_add_mapping(
1440 struct bt_ctf_field_type
*enum_field_type
, const char *name
,
1441 int64_t range_begin
, int64_t range_end
);
1444 @brief Adds a mapping to the @enumft \p enum_field_type which maps
1445 the name \p name to the unsigned
1446 range \p range_begin (included) to \p range_end (included).
1448 Make \p range_begin and \p range_end the same value to add a mapping
1451 The @intft wrapped by \p enum_field_type, as returned by
1452 bt_ctf_field_type_enumeration_get_container_type(), must be
1453 \b unsigned to use this function.
1455 A mapping in \p enum_field_type can exist with the name \p name.
1457 @param[in] enum_field_type Enumeration field type to which to add
1459 @param[in] name Name of the mapping to add (copied
1461 @param[in] range_begin Beginning of the range of the mapping
1463 @param[in] range_end End of the range of the mapping
1465 @returns 0 on success, or a negative value on error.
1467 @prenotnull{enum_field_type}
1469 @preisenumft{enum_field_type}
1470 @pre The wrapped @intft of \p enum_field_type is unsigned.
1471 @pre \p range_end is greater than or equal to \p range_begin.
1472 @postrefcountsame{enum_field_type}
1474 @sa bt_ctf_field_type_enumeration_add_mapping(): Adds a signed
1475 mapping to a given enumeration field type.
1477 extern int bt_ctf_field_type_enumeration_add_mapping_unsigned(
1478 struct bt_ctf_field_type
*enum_field_type
, const char *name
,
1479 uint64_t range_begin
, uint64_t range_end
);
1484 @defgroup ctfirstringfieldtype CTF IR string field type
1485 @ingroup ctfirfieldtypes
1486 @brief CTF IR string field type.
1489 #include <babeltrace/ctf-ir/field-types.h>
1492 A CTF IR <strong><em>string field type</em></strong> is a field type that
1493 you can use to create concrete @stringfields.
1495 You can create a string field type
1496 with bt_ctf_field_type_string_create().
1498 A string field type has only one property: the \b encoding of its
1499 described @stringfields. By default, the encoding of the string fields
1500 described by a string field type is #BT_CTF_STRING_ENCODING_UTF8. You
1501 can set the encoding of the string fields described by a string field
1502 type with bt_ctf_field_type_string_set_encoding().
1504 @sa ctfirstringfield
1507 @addtogroup ctfirstringfieldtype
1512 @brief Creates a default @stringft.
1514 @returns Created string field type, or \c NULL on error.
1516 @postsuccessrefcountret1
1518 extern struct bt_ctf_field_type
*bt_ctf_field_type_string_create(void);
1521 @brief Returns the encoding of the @stringfields described by
1522 the @stringft \p string_field_type.
1524 @param[in] string_field_type String field type which describes the
1525 string fields of which to get the
1527 @returns Encoding of the string
1528 fields described by \p string_field_type,
1529 or #BT_CTF_STRING_ENCODING_UNKNOWN on
1532 @prenotnull{string_field_type}
1533 @preisstringft{string_field_type}
1534 @postrefcountsame{string_field_type}
1536 @sa bt_ctf_field_type_string_set_encoding(): Sets the encoding
1537 of the string fields described by a given string field type.
1539 extern enum bt_ctf_string_encoding
bt_ctf_field_type_string_get_encoding(
1540 struct bt_ctf_field_type
*string_field_type
);
1543 @brief Sets the encoding of the @stringfields described by the
1544 @stringft \p string_field_type to \p encoding.
1546 @param[in] string_field_type String field type which describes the
1547 string fields of which to set the
1549 @param[in] encoding Encoding of the string fields described
1550 by \p string_field_type.
1551 @returns 0 on success, or a negative value on error.
1553 @prenotnull{string_field_type}
1554 @preisstringft{string_field_type}
1555 @prehot{string_field_type}
1556 @pre \p encoding is #BT_CTF_STRING_ENCODING_ASCII or
1557 #BT_CTF_STRING_ENCODING_UTF8.
1558 @postrefcountsame{string_field_type}
1560 @sa bt_ctf_field_type_string_get_encoding(): Returns the encoding of
1561 the string fields described by a given string field type.
1563 extern int bt_ctf_field_type_string_set_encoding(
1564 struct bt_ctf_field_type
*string_field_type
,
1565 enum bt_ctf_string_encoding encoding
);
1570 @defgroup ctfirstructfieldtype CTF IR structure field type
1571 @ingroup ctfirfieldtypes
1572 @brief CTF IR structure field type.
1575 #include <babeltrace/ctf-ir/field-types.h>
1578 A CTF IR <strong><em>structure field type</em></strong> is
1579 a field type that you can use to create concrete @structfields.
1581 You can create a structure field type
1582 with bt_ctf_field_type_structure_create(). This function creates
1583 an empty structure field type, with no fields.
1585 You can add a field to a structure field type with
1586 bt_ctf_field_type_structure_add_field(). Two fields in a structure
1587 field type cannot have the same name.
1589 You can set the \em minimum alignment of the structure fields described
1590 by a structure field type with the common
1591 bt_ctf_field_type_set_alignment() function. The \em effective alignment
1592 of the structure fields described by a structure field type, as per
1593 <a href="http://diamon.org/ctf/">CTF</a>, is the \em maximum value amongst
1594 the effective alignments of all its fields. Note that the effective
1595 alignment of @varfields is always 1.
1597 You can set the byte order of <em>all the contained fields</em>,
1598 recursively, of a structure field type with the common
1599 bt_ctf_field_type_set_byte_order() function.
1601 @sa ctfirstructfield
1604 @addtogroup ctfirstructfieldtype
1609 @brief Creates a default, empty @structft.
1611 @returns Created structure field type,
1612 or \c NULL on error.
1614 @postsuccessrefcountret1
1616 extern struct bt_ctf_field_type
*bt_ctf_field_type_structure_create(void);
1619 @brief Returns the number of fields contained in the
1620 @structft \p struct_field_type.
1622 @param[in] struct_field_type Structure field type of which to get
1623 the number of contained fields.
1624 @returns Number of fields contained in
1625 \p struct_field_type, or a negative
1628 @prenotnull{struct_field_type}
1629 @preisstructft{struct_field_type}
1630 @postrefcountsame{struct_field_type}
1632 extern int bt_ctf_field_type_structure_get_field_count(
1633 struct bt_ctf_field_type
*struct_field_type
);
1636 @brief Returns the field of the @structft \p struct_field_type
1639 On success, the field's type is placed in \p *field_type if
1640 \p field_type is not \c NULL. The field's name is placed in
1641 \p *field_name if \p field_name is not \c NULL.
1642 \p struct_field_type remains the sole owner of \p *field_name.
1644 @param[in] struct_field_type Structure field type of which to get
1645 the field at index \p index.
1646 @param[out] field_name Returned name of the field at index
1647 \p index (can be \c NULL).
1648 @param[out] field_type Returned field type of the field
1649 at index \p index (can be \c NULL).
1650 @param[in] index Index of the field to get from
1651 \p struct_field_type.
1652 @returns 0 on success, or a negative value on error.
1654 @prenotnull{struct_field_type}
1655 @preisstructft{struct_field_type}
1656 @pre \p index is lesser than the number of fields contained in the
1657 structure field type \p struct_field_type (see
1658 bt_ctf_field_type_structure_get_field_count()).
1659 @postrefcountsame{struct_field_type}
1660 @post <strong>On success</strong>, the returned field's type is placed
1661 in \p *field_type and its reference count is incremented.
1663 @sa bt_ctf_field_type_structure_get_field_type_by_name(): Finds a
1664 structure field type's field by name.
1666 extern int bt_ctf_field_type_structure_get_field(
1667 struct bt_ctf_field_type
*struct_field_type
,
1668 const char **field_name
, struct bt_ctf_field_type
**field_type
,
1672 @brief Returns the type of the field named \p field_name found in
1673 the @structft \p struct_field_type.
1675 @param[in] struct_field_type Structure field type of which to get
1677 @param[in] field_name Name of the field to find.
1678 @returns Type of the field named \p field_name in
1679 \p struct_field_type, or
1682 @prenotnull{struct_field_type}
1683 @prenotnull{field_name}
1684 @preisstructft{struct_field_type}
1685 @postrefcountsame{struct_field_type}
1686 @postsuccessrefcountretinc
1688 @sa bt_ctf_field_type_structure_get_field(): Finds a
1689 structure field type's field by index.
1692 struct bt_ctf_field_type
*bt_ctf_field_type_structure_get_field_type_by_name(
1693 struct bt_ctf_field_type
*struct_field_type
,
1694 const char *field_name
);
1697 @brief Adds a field named \p field_name with the @ft
1698 \p field_type to the @structft \p struct_field_type.
1700 On success, \p field_type becomes the child of \p struct_field_type.
1702 This function adds the new field after the current last field of
1703 \p struct_field_type (append mode).
1705 You \em cannot add a field named \p field_name if there's already a
1706 field named \p field_name in \p struct_field_type.
1708 @param[in] struct_field_type Structure field type to which to add
1710 @param[in] field_type Field type of the field to add to
1711 \p struct_field_type.
1712 @param[in] field_name Name of the field to add to
1713 \p struct_field_type
1714 (copied on success).
1715 @returns 0 on success, or a negative value on error.
1717 @prenotnull{struct_field_type}
1718 @prenotnull{field_type}
1719 @prenotnull{field_name}
1720 @preisstructft{struct_field_type}
1721 @pre \p field_type is not and does not contain \p struct_field_type,
1722 recursively, as a field's type.
1723 @prehot{struct_field_type}
1724 @postrefcountsame{struct_field_type}
1725 @postsuccessrefcountinc{field_type}
1727 extern int bt_ctf_field_type_structure_add_field(
1728 struct bt_ctf_field_type
*struct_field_type
,
1729 struct bt_ctf_field_type
*field_type
,
1730 const char *field_name
);
1735 @defgroup ctfirarrayfieldtype CTF IR array field type
1736 @ingroup ctfirfieldtypes
1737 @brief CTF IR array field type.
1740 #include <babeltrace/ctf-ir/field-types.h>
1743 A CTF IR <strong><em>array field type</em></strong> is a field type that
1744 you can use to create concrete @arrayfields.
1746 You can create an array field type
1747 with bt_ctf_field_type_array_create(). This function needs
1748 the @ft of the fields contained by the array fields described by the
1749 array field type to create.
1754 @addtogroup ctfirarrayfieldtype
1759 @brief Creates a default @arrayft with
1760 \p element_field_type as the field type of the fields contained
1761 in its described @arrayfields of length \p length.
1763 @param[in] element_field_type Field type of the fields contained in
1764 the array fields described by the
1765 created array field type.
1766 @param[in] length Length of the array fields described by
1767 the created array field type.
1768 @returns Created array field type, or
1771 @prenotnull{element_field_type}
1772 @postsuccessrefcountinc{element_field_type}
1773 @postsuccessrefcountret1
1775 extern struct bt_ctf_field_type
*bt_ctf_field_type_array_create(
1776 struct bt_ctf_field_type
*element_field_type
,
1777 unsigned int length
);
1780 @brief Returns the @ft of the @fields contained in
1781 the @arrayfields described by the @arrayft \p array_field_type.
1783 @param[in] array_field_type Array field type of which to get
1784 the type of the fields contained in its
1785 described array fields.
1786 @returns Type of the fields contained in the
1787 array fields described by
1788 \p array_field_type, or \c NULL
1791 @prenotnull{array_field_type}
1792 @preisarrayft{array_field_type}
1793 @postrefcountsame{array_field_type}
1794 @postsuccessrefcountretinc
1796 extern struct bt_ctf_field_type
*bt_ctf_field_type_array_get_element_type(
1797 struct bt_ctf_field_type
*array_field_type
);
1800 @brief Returns the number of @fields contained in the
1801 @arrayfields described by the @arrayft \p array_field_type.
1803 @param[in] array_field_type Array field type of which to get
1804 the number of fields contained in its
1805 described array fields.
1806 @returns Number of fields contained in the
1807 array fields described by
1808 \p array_field_type, or a negative value
1811 @prenotnull{array_field_type}
1812 @preisarrayft{array_field_type}
1813 @postrefcountsame{array_field_type}
1815 extern int64_t bt_ctf_field_type_array_get_length(
1816 struct bt_ctf_field_type
*array_field_type
);
1821 @defgroup ctfirseqfieldtype CTF IR sequence field type
1822 @ingroup ctfirfieldtypes
1823 @brief CTF IR sequence field type.
1826 #include <babeltrace/ctf-ir/field-types.h>
1829 A CTF IR <strong><em>sequence field type</em></strong> is
1830 a field type that you can use to create concrete @seqfields.
1832 You can create a sequence field type with
1833 bt_ctf_field_type_sequence_create(). This function needs the @ft
1834 of the fields contained by the sequence fields described by the created
1835 sequence field type. This function also needs the length name of the
1836 sequence field type to create. The length name is used to automatically
1837 resolve the length's field type. See \ref ctfirfieldtypes to learn more
1838 about the automatic resolving.
1843 @addtogroup ctfirseqfieldtype
1848 @brief Creates a default @seqft with \p element_field_type as the
1849 @ft of the @fields contained in its described @seqfields
1850 with the length name \p length_name.
1852 \p length_name can be an absolute or relative reference. See
1853 <a href="http://diamon.org/ctf/">CTF</a> for more details.
1855 @param[in] element_field_type Field type of the fields contained in
1856 the sequence fields described by the
1857 created sequence field type.
1858 @param[in] length_name Length name (copied on success).
1859 @returns Created array field type, or
1862 @prenotnull{element_field_type}
1863 @prenotnull{length_name}
1864 @postsuccessrefcountinc{element_field_type}
1865 @postsuccessrefcountret1
1867 extern struct bt_ctf_field_type
*bt_ctf_field_type_sequence_create(
1868 struct bt_ctf_field_type
*element_field_type
,
1869 const char *length_name
);
1872 @brief Returns the @ft of the @fields contained in the @seqft
1873 described by the @seqft \p sequence_field_type.
1875 @param[in] sequence_field_type Sequence field type of which to get
1876 the type of the fields contained in its
1877 described sequence fields.
1878 @returns Type of the fields contained in the
1879 sequence fields described by
1880 \p sequence_field_type, or \c NULL
1883 @prenotnull{sequence_field_type}
1884 @preisseqft{sequence_field_type}
1885 @postrefcountsame{sequence_field_type}
1886 @postsuccessrefcountretinc
1888 extern struct bt_ctf_field_type
*bt_ctf_field_type_sequence_get_element_type(
1889 struct bt_ctf_field_type
*sequence_field_type
);
1892 @brief Returns the length name of the @seqft \p sequence_field_type.
1894 On success, \p sequence_field_type remains the sole owner of
1895 the returned string.
1897 @param[in] sequence_field_type Sequence field type of which to get the
1899 @returns Length name of \p sequence_field_type,
1900 or \c NULL on error.
1902 @prenotnull{sequence_field_type}
1903 @preisseqft{sequence_field_type}
1905 @sa bt_ctf_field_type_sequence_get_length_field_path(): Returns the
1906 length's CTF IR field path of a given sequence field type.
1908 extern const char *bt_ctf_field_type_sequence_get_length_field_name(
1909 struct bt_ctf_field_type
*sequence_field_type
);
1912 @brief Returns the length's CTF IR field path of the @seqft
1913 \p sequence_field_type.
1915 The length's field path of a sequence field type is set when automatic
1916 resolving is performed (see \ref ctfirfieldtypes).
1918 @param[in] sequence_field_type Sequence field type of which to get the
1919 length's field path.
1920 @returns Length's field path of
1921 \p sequence_field_type, or
1922 \c NULL if the length's field path is
1923 not set yet is not set or on error.
1925 @prenotnull{sequence_field_type}
1926 @preisseqft{sequence_field_type}
1927 @postsuccessrefcountretinc
1929 @sa bt_ctf_field_type_sequence_get_length_field_name(): Returns the
1930 length's name of a given sequence field type.
1932 extern struct bt_ctf_field_path
*bt_ctf_field_type_sequence_get_length_field_path(
1933 struct bt_ctf_field_type
*sequence_field_type
);
1938 @defgroup ctfirvarfieldtype CTF IR variant field type
1939 @ingroup ctfirfieldtypes
1940 @brief CTF IR variant field type.
1943 #include <babeltrace/ctf-ir/field-types.h>
1946 A CTF IR <strong><em>variant field type</em></strong> is
1947 a field type that you can use to create concrete @varfields.
1949 You can create a variant field type with
1950 bt_ctf_field_type_variant_create(). This function expects you to pass
1951 both the tag's @enumft and the tag name of the variant field type to
1952 create. The tag's field type is optional, as the Babeltrace system can
1953 automatically resolve it using the tag name. You can leave the tag name
1954 to \c NULL initially, and set it later with
1955 bt_ctf_field_type_variant_set_tag_name(). The tag name must be set when
1956 the variant field type is frozen. See \ref ctfirfieldtypes to learn more
1957 about the automatic resolving and the conditions under which a field
1960 You can add a field to a variant field type with
1961 bt_ctf_field_type_variant_add_field(). All the field names of a
1962 variant field type \em must exist as mapping names in its tag's @enumft.
1964 The effective alignment of the @varfields described by a
1965 variant field type is always 1, but the individual fields of a
1966 @varfield can have custom alignments.
1968 You can set the byte order of <em>all the contained fields</em>,
1969 recursively, of a variant field type with the common
1970 bt_ctf_field_type_set_byte_order() function.
1975 @addtogroup ctfirvarfieldtype
1980 @brief Creates a default, empty @varft with the tag's @enumft
1981 \p tag_field_type and the tag name \p tag_name.
1983 \p tag_field_type can be \c NULL; the tag's field type can be
1984 automatically resolved from the variant field type's tag name (see
1985 \ref ctfirfieldtypes). If \p tag_name is \c NULL, it \em must be set
1986 with bt_ctf_field_type_variant_set_tag_name() \em before the variant
1987 field type is frozen.
1989 \p tag_name can be an absolute or relative reference. See
1990 <a href="http://diamon.org/ctf/">CTF</a> for more details.
1992 @param[in] tag_field_type Tag's enumeration field type
1994 @param[in] tag_name Tag name (copied on success,
1996 @returns Created variant field type, or
1999 @pre \p tag_field_type is an enumeration field type or \c NULL.
2000 @post <strong>On success, if \p tag_field_type is not \c NULL</strong>,
2001 its reference count is incremented.
2002 @postsuccessrefcountret1
2004 extern struct bt_ctf_field_type
*bt_ctf_field_type_variant_create(
2005 struct bt_ctf_field_type
*tag_field_type
,
2006 const char *tag_name
);
2009 @brief Returns the tag's @enumft of the @varft \p variant_field_type.
2011 @param[in] variant_field_type Variant field type of which to get
2012 the tag's enumeration field type.
2013 @returns Tag's enumeration field type of
2014 \p variant_field_type, or \c NULL if the
2015 tag's field type is not set or on
2018 @prenotnull{variant_field_type}
2019 @preisvarft{variant_field_type}
2020 @postrefcountsame{variant_field_type}
2021 @postsuccessrefcountretinc
2023 extern struct bt_ctf_field_type
*bt_ctf_field_type_variant_get_tag_type(
2024 struct bt_ctf_field_type
*variant_field_type
);
2027 @brief Returns the tag name of the @varft \p variant_field_type.
2029 On success, \p variant_field_type remains the sole owner of
2030 the returned string.
2032 @param[in] variant_field_type Variant field type of which to get the
2034 @returns Tag name of \p variant_field_type, or
2035 \c NULL if the tag name is not set or
2038 @prenotnull{variant_field_type}
2039 @preisvarft{variant_field_type}
2041 @sa bt_ctf_field_type_variant_set_tag_name(): Sets the tag name of
2042 a given variant field type.
2043 @sa bt_ctf_field_type_variant_get_tag_field_path(): Returns the tag's
2044 CTF IR field path of a given variant field type.
2046 extern const char *bt_ctf_field_type_variant_get_tag_name(
2047 struct bt_ctf_field_type
*variant_field_type
);
2050 @brief Sets the tag name of the @varft \p variant_field_type.
2052 \p tag_name can be an absolute or relative reference. See
2053 <a href="http://diamon.org/ctf/">CTF</a> for more details.
2055 @param[in] variant_field_type Variant field type of which to set
2057 @param[in] tag_name Tag name of \p variant_field_type
2058 (copied on success).
2059 @returns 0 on success, or a negative value on error.
2061 @prenotnull{variant_field_type}
2063 @prehot{variant_field_type}
2064 @postrefcountsame{variant_field_type}
2066 @sa bt_ctf_field_type_variant_get_tag_name(): Returns the tag name of
2067 a given variant field type.
2069 extern int bt_ctf_field_type_variant_set_tag_name(
2070 struct bt_ctf_field_type
*variant_field_type
,
2071 const char *tag_name
);
2074 @brief Returns the tag's CTF IR field path of the @varft
2075 \p variant_field_type.
2077 The tag's field path of a variant field type is set when automatic
2078 resolving is performed (see \ref ctfirfieldtypes).
2080 @param[in] variant_field_type Variant field type of which to get the
2082 @returns Tag's field path of
2083 \p variant_field_type, or
2084 \c NULL if the tag's field path is not
2085 set yet is not set or on error.
2087 @prenotnull{variant_field_type}
2088 @preisvarft{variant_field_type}
2089 @postsuccessrefcountretinc
2091 @sa bt_ctf_field_type_variant_get_tag_name(): Returns the tag's
2092 name of a given variant field type.
2094 extern struct bt_ctf_field_path
*bt_ctf_field_type_variant_get_tag_field_path(
2095 struct bt_ctf_field_type
*variant_field_type
);
2098 @brief Returns the number of fields (choices) contained in the @varft
2099 \p variant_field_type.
2101 @param[in] variant_field_type Variant field type of which to get
2102 the number of contained fields.
2103 @returns Number of fields contained in
2104 \p variant_field_type, or a negative
2107 @prenotnull{variant_field_type}
2108 @preisvarft{variant_field_type}
2109 @postrefcountsame{variant_field_type}
2111 extern int bt_ctf_field_type_variant_get_field_count(
2112 struct bt_ctf_field_type
*variant_field_type
);
2115 @brief Returns the field (choice) of the @varft \p variant_field_type
2118 On success, the field's type is placed in \p *field_type if
2119 \p field_type is not \c NULL. The field's name is placed in
2120 \p *field_name if \p field_name is not \c NULL.
2121 \p variant_field_type remains the sole owner of \p *field_name.
2123 @param[in] variant_field_type Variant field type of which to get
2124 the field at index \p index.
2125 @param[out] field_name Returned name of the field at index
2126 \p index (can be \c NULL).
2127 @param[out] field_type Returned field type of the field
2128 at index \p index (can be \c NULL).
2129 @param[in] index Index of the field to get from
2130 \p variant_field_type.
2131 @returns 0 on success, or a negative value on error.
2133 @prenotnull{variant_field_type}
2134 @preisvarft{variant_field_type}
2135 @pre \p index is lesser than the number of fields contained in the
2136 variant field type \p variant_field_type (see
2137 bt_ctf_field_type_variant_get_field_count()).
2138 @postrefcountsame{variant_field_type}
2139 @post <strong>On success</strong>, the returned field's type is placed
2140 in \p *field_type and its reference count is incremented.
2142 @sa bt_ctf_field_type_variant_get_field_type_by_name(): Finds a variant
2143 field type's field by name.
2144 @sa bt_ctf_field_type_variant_get_field_type_from_tag(): Finds a variant
2145 field type's field by current tag value.
2147 extern int bt_ctf_field_type_variant_get_field(
2148 struct bt_ctf_field_type
*variant_field_type
,
2149 const char **field_name
,
2150 struct bt_ctf_field_type
**field_type
, int index
);
2153 @brief Returns the type of the field (choice) named \p field_name
2154 found in the @varft \p variant_field_type.
2156 @param[in] variant_field_type Variant field type of which to get
2158 @param[in] field_name Name of the field to find.
2159 @returns Type of the field named \p field_name in
2160 \p variant_field_type, or
2163 @prenotnull{variant_field_type}
2164 @prenotnull{field_name}
2165 @preisvarft{variant_field_type}
2166 @postrefcountsame{variant_field_type}
2167 @postsuccessrefcountretinc
2169 @sa bt_ctf_field_type_variant_get_field(): Finds a variant field type's
2171 @sa bt_ctf_field_type_variant_get_field_type_from_tag(): Finds a variant
2172 field type's field by current tag value.
2175 struct bt_ctf_field_type
*bt_ctf_field_type_variant_get_field_type_by_name(
2176 struct bt_ctf_field_type
*variant_field_type
,
2177 const char *field_name
);
2180 @brief Returns the type of the field (choice) selected by the value of
2181 the @enumfield \p tag_field in the @varft \p variant_field_type.
2183 \p tag_field is the current tag value.
2185 The field type of \p tag_field, as returned by bt_ctf_field_get_type(),
2186 \em must be equivalent to the field type returned by
2187 bt_ctf_field_type_variant_get_tag_type() for \p variant_field_type.
2189 @param[in] variant_field_type Variant field type of which to get
2191 @param[in] tag_field Current tag value (variant field type's
2193 @returns Type of the field selected by
2194 \p tag_field in \p variant_field_type,
2195 or \c NULL on error.
2197 @prenotnull{variant_field_type}
2198 @prenotnull{tag_field}
2199 @preisvarft{variant_field_type}
2200 @preisenumfield{tag_field}
2201 @postrefcountsame{variant_field_type}
2202 @postrefcountsame{tag_field}
2203 @postsuccessrefcountretinc
2205 @sa bt_ctf_field_type_variant_get_field(): Finds a variant field type's
2207 @sa bt_ctf_field_type_variant_get_field_type_by_name(): Finds a variant
2208 field type's field by name.
2211 struct bt_ctf_field_type
*bt_ctf_field_type_variant_get_field_type_from_tag(
2212 struct bt_ctf_field_type
*variant_field_type
,
2213 struct bt_ctf_field
*tag_field
);
2216 @brief Adds a field (a choice) named \p field_name with the @ft
2217 \p field_type to the @varft \p variant_field_type.
2219 On success, \p field_type becomes the child of \p variant_field_type.
2221 You \em cannot add a field named \p field_name if there's already a
2222 field named \p field_name in \p variant_field_type.
2224 \p field_name \em must name an existing mapping in the tag's
2225 enumeration field type of \p variant_field_type.
2227 @param[in] variant_field_type Variant field type to which to add
2229 @param[in] field_type Field type of the field to add to
2230 \p variant_field_type.
2231 @param[in] field_name Name of the field to add to
2232 \p variant_field_type
2233 (copied on success).
2234 @returns 0 on success, or a negative value on error.
2236 @prenotnull{variant_field_type}
2237 @prenotnull{field_type}
2238 @prenotnull{field_name}
2239 @preisvarft{variant_field_type}
2240 @pre \p field_type is not and does not contain \p variant_field_type,
2241 recursively, as a field's type.
2242 @prehot{variant_field_type}
2243 @postrefcountsame{variant_field_type}
2244 @postsuccessrefcountinc{field_type}
2246 extern int bt_ctf_field_type_variant_add_field(
2247 struct bt_ctf_field_type
*variant_field_type
,
2248 struct bt_ctf_field_type
*field_type
,
2249 const char *field_name
);
2257 #endif /* BABELTRACE_CTF_IR_FIELD_TYPES_H */