1 #ifndef BABELTRACE_CTF_IR_FIELDS_H
2 #define BABELTRACE_CTF_IR_FIELDS_H
5 * Babeltrace - CTF IR: Event Fields
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
37 #include <babeltrace/types.h>
43 struct bt_ctf_field_type
;
46 @defgroup ctfirfields CTF IR fields
51 #include <babeltrace/ctf-ir/fields.h>
54 A CTF IR <strong><em>field</em></strong> is an object which holds a
55 concrete value, and which is described by a @ft.
57 In the CTF IR hierarchy, you can set the root fields of two objects:
60 - Trace packet header field: bt_ctf_packet_set_header().
61 - Stream packet context field: bt_ctf_packet_set_context().
63 - Stream event header field: bt_ctf_event_set_header().
64 - Stream event context field: bt_ctf_event_set_stream_event_context().
65 - Event context field: bt_ctf_event_set_event_context().
66 - Event payload field: bt_ctf_event_set_payload_field().
68 There are two categories of fields:
70 - <strong>Basic fields</strong>:
71 - @intfield: contains an integral value.
72 - @floatfield: contains a floating point number value.
73 - @enumfield: contains an integer field which contains an integral
75 - @stringfield: contains a string value.
76 - <strong>Compound fields</strong>:
77 - @structfield: contains an ordered list of named fields
78 (possibly with different @fts).
79 - @arrayfield: contains an ordered list of fields which share
81 - @seqfield: contains an ordered list of fields which share
83 - @varfield: contains a single, current field.
85 You can create a field object from a @ft object with
86 bt_ctf_field_create(). The enumeration and compound fields create their
87 contained fields with the following getters if such fields do not exist
90 - bt_ctf_field_enumeration_get_container()
91 - bt_ctf_field_structure_get_field_by_name()
92 - bt_ctf_field_array_get_field()
93 - bt_ctf_field_sequence_get_field()
94 - bt_ctf_field_variant_get_field()
96 If you already have a field object, you can also assign it to a specific
97 name within a @structfield with
98 bt_ctf_field_structure_set_field_by_name().
100 You can get a reference to the @ft which was used to create a field with
101 bt_ctf_field_get_type(). You can get the
102 \link #bt_ctf_field_type_id type ID\endlink of this field type directly with
103 bt_ctf_field_get_type_id().
105 You can get a deep copy of a field with bt_ctf_field_copy(). The field
106 copy, and its contained field copies if it's the case, have the same
107 field type as the originals.
109 As with any Babeltrace object, CTF IR field objects have
110 <a href="https://en.wikipedia.org/wiki/Reference_counting">reference
111 counts</a>. See \ref refs to learn more about the reference counting
112 management of Babeltrace objects.
114 The functions which freeze CTF IR \link ctfirpacket packet\endlink and
115 \link ctfirevent event\endlink objects also freeze their root field
116 objects. You cannot modify a frozen field object: it is considered
117 immutable, except for \link refs reference counting\endlink.
122 @brief CTF IR fields type and functions.
125 @addtogroup ctfirfields
131 @brief A CTF IR field.
135 struct bt_ctf_event_class
;
137 struct bt_ctf_field_type
;
138 struct bt_ctf_field_type_enumeration_mapping_iterator
;
141 @name Creation and parent field type access functions
146 @brief Creates an uninitialized @field described by the @ft
149 On success, \p field_type becomes the parent of the created field
152 On success, this function creates an \em uninitialized field: it has
153 no value. You need to set the value of the created field with one of the
154 its specific setters.
156 @param[in] field_type Field type which describes the field to create.
157 @returns Created field object, or \c NULL on error.
159 @prenotnull{field_type}
160 @postsuccessrefcountret1
161 @postsuccessfrozen{field_type}
163 extern struct bt_ctf_field
*bt_ctf_field_create(
164 struct bt_ctf_field_type
*field_type
);
167 @brief Returns the parent @ft of the @field \p field.
169 This function returns a reference to the field type which was used to
170 create the field object in the first place with bt_ctf_field_create().
172 @param[in] field Field of which to get the parent field type.
173 @returns Parent field type of \p event,
177 @postrefcountsame{field}
178 @postsuccessrefcountretinc
180 extern struct bt_ctf_field_type
*bt_ctf_field_get_type(
181 struct bt_ctf_field
*field
);
186 @name Type information
191 @brief Returns the type ID of the @ft of the @field \p field.
193 @param[in] field Field of which to get the type ID of its
195 @returns Type ID of the parent field type of \p field,
196 or #BT_CTF_FIELD_TYPE_ID_UNKNOWN on error.
199 @postrefcountsame{field}
201 @sa #bt_ctf_field_type_id: CTF IR field type ID.
202 @sa bt_ctf_field_is_integer(): Returns whether or not a given field is a
204 @sa bt_ctf_field_is_floating_point(): Returns whether or not a given
205 field is a @floatfield.
206 @sa bt_ctf_field_is_enumeration(): Returns whether or not a given field
208 @sa bt_ctf_field_is_string(): Returns whether or not a given field is a
210 @sa bt_ctf_field_is_structure(): Returns whether or not a given field is
212 @sa bt_ctf_field_is_array(): Returns whether or not a given field is a
214 @sa bt_ctf_field_is_sequence(): Returns whether or not a given field is
216 @sa bt_ctf_field_is_variant(): Returns whether or not a given field is a
219 extern enum bt_ctf_field_type_id
bt_ctf_field_get_type_id(
220 struct bt_ctf_field
*field
);
223 extern bt_bool
bt_ctf_field_is_set(struct bt_ctf_field
*field
);
225 extern int bt_ctf_field_reset(struct bt_ctf_field
*field
);
228 * bt_ctf_field_signed_integer_get_value: get a signed integer field's value
230 * Get a signed integer field's value.
232 * @param integer Signed integer field instance.
233 * @param value Pointer to a signed integer where the value will be stored.
235 * Returns 0 on success, a negative value on error.
237 extern int bt_ctf_field_signed_integer_get_value(struct bt_ctf_field
*integer
,
241 @brief Returns whether or not the @field \p field is a @intfield.
243 @param[in] field Field to check (can be \c NULL).
244 @returns #BT_TRUE if \p field is an integer field, or
245 #BT_FALSE otherwise (including if \p field is
249 @postrefcountsame{field}
251 @sa bt_ctf_field_get_type_id(): Returns the type ID of a given
254 extern bt_bool
bt_ctf_field_is_integer(struct bt_ctf_field
*field
);
257 @brief Returns whether or not the @field \p field is a @floatfield.
259 @param[in] field Field to check (can be \c NULL).
260 @returns #BT_TRUE if \p field is a floating point number fiel
261 #BT_FALSE or 0 otherwise (including if \p field is
265 @postrefcountsame{field}
267 @sa bt_ctf_field_get_type_id(): Returns the type ID of a given
270 extern bt_bool
bt_ctf_field_is_floating_point(struct bt_ctf_field
*field
);
273 @brief Returns whether or not the @field \p field is a @enumfield.
275 @param[in] field Field to check (can be \c NULL).
276 @returns #BT_TRUE if \p field is an enumeration field, or
277 #BT_FALSE otherwise (including if \p field is
281 @postrefcountsame{field}
283 @sa bt_ctf_field_get_type_id(): Returns the type ID of a given
286 extern bt_bool
bt_ctf_field_is_enumeration(struct bt_ctf_field
*field
);
289 @brief Returns whether or not the @field \p field is a @stringfield.
291 @param[in] field Field to check (can be \c NULL).
292 @returns #BT_TRUE if \p field is a string field, or
293 #BT_FALSE otherwise (including if \p field is
297 @postrefcountsame{field}
299 @sa bt_ctf_field_get_type_id(): Returns the type ID of a given
302 extern bt_bool
bt_ctf_field_is_string(struct bt_ctf_field
*field
);
305 @brief Returns whether or not the @field \p field is a @structfield.
307 @param[in] field Field to check (can be \c NULL).
308 @returns #BT_TRUE if \p field is a structure field, or
309 #BT_FALSE otherwise (including if \p field is
313 @postrefcountsame{field}
315 @sa bt_ctf_field_get_type_id(): Returns the type ID of a given
318 extern bt_bool
bt_ctf_field_is_structure(struct bt_ctf_field
*field
);
321 @brief Returns whether or not the @field \p field is a @arrayfield.
323 @param[in] field Field to check (can be \c NULL).
324 @returns #BT_TRUE if \p field is an array field, or
325 #BT_FALSE otherwise (including if \p field is
329 @postrefcountsame{field}
331 @sa bt_ctf_field_get_type_id(): Returns the type ID of a given
334 extern bt_bool
bt_ctf_field_is_array(struct bt_ctf_field
*field
);
337 @brief Returns whether or not the @field \p field is a @seqfield.
339 @param[in] field Field to check (can be \c NULL).
340 @returns #BT_TRUE if \p field is a sequence field, or
341 #BT_FALSE otherwise (including if \p field is
345 @postrefcountsame{field}
347 @sa bt_ctf_field_get_type_id(): Returns the type ID of a given
350 extern bt_bool
bt_ctf_field_is_sequence(struct bt_ctf_field
*field
);
353 @brief Returns whether or not the @field \p field is a @varfield.
355 @param[in] field Field to check (can be \c NULL).
356 @returns #BT_TRUE if \p field is a variant field, or
357 #BT_FALSE otherwise (including if \p field is
361 @postrefcountsame{field}
363 @sa bt_ctf_field_get_type_id(): Returns the type ID of a given
366 extern bt_bool
bt_ctf_field_is_variant(struct bt_ctf_field
*field
);
371 @name Misc. functions
376 @brief Creates a \em deep copy of the @field \p field.
378 You can copy a frozen field: the resulting copy is <em>not frozen</em>.
380 @param[in] field Field to copy.
381 @returns Deep copy of \p field on success,
385 @postrefcountsame{field}
386 @postsuccessrefcountret1
387 @post <strong>On success</strong>, the returned field is not frozen.
389 extern struct bt_ctf_field
*bt_ctf_field_copy(struct bt_ctf_field
*field
);
396 @defgroup ctfirintfield CTF IR integer field
398 @brief CTF IR integer field.
401 #include <babeltrace/ctf-ir/fields.h>
404 A CTF IR <strong><em>integer field</em></strong> is a @field which
405 holds a signed or unsigned integral value, and which is described by
408 An integer field object is considered \em unsigned if
409 bt_ctf_field_type_integer_get_signed() on its parent field type returns
410 0. Otherwise it is considered \em signed. You \em must use
411 bt_ctf_field_unsigned_integer_get_value() and
412 bt_ctf_field_unsigned_integer_set_value() with an unsigned integer
413 field, and bt_ctf_field_signed_integer_get_value() and
414 bt_ctf_field_signed_integer_set_value() with a signed integer field.
416 After you create an integer field with bt_ctf_field_create(), you
417 \em must set an integral value with
418 bt_ctf_field_unsigned_integer_set_value() or
419 bt_ctf_field_signed_integer_set_value() before you can get the
420 field's value with bt_ctf_field_unsigned_integer_get_value() or
421 bt_ctf_field_signed_integer_get_value().
423 @sa ctfirintfieldtype
426 @addtogroup ctfirintfield
431 @brief Returns the signed integral value of the @intfield
434 @param[in] integer_field Integer field of which to get the
435 signed integral value.
436 @param[out] value Returned signed integral value of
438 @returns 0 on success, or a negative value on
439 error, including if \p integer_field
440 has no integral value yet.
442 @prenotnull{integer_field}
444 @preisintfield{integer_field}
445 @pre bt_ctf_field_type_integer_get_signed() returns 1 for the parent
446 @ft of \p integer_field.
447 @pre \p integer_field contains a signed integral value previously
448 set with bt_ctf_field_signed_integer_set_value().
449 @postrefcountsame{integer_field}
451 @sa bt_ctf_field_signed_integer_set_value(): Sets the signed integral
452 value of a given integer field.
454 extern int bt_ctf_field_signed_integer_get_value(
455 struct bt_ctf_field
*integer_field
, int64_t *value
);
458 @brief Sets the signed integral value of the @intfield
459 \p integer_field to \p value.
461 @param[in] integer_field Integer field of which to set
462 the signed integral value.
463 @param[in] value New signed integral value of
465 @returns 0 on success, or a negative value on error.
467 @prenotnull{integer_field}
468 @preisintfield{integer_field}
469 @prehot{integer_field}
470 @pre bt_ctf_field_type_integer_get_signed() returns 1 for the parent
471 @ft of \p integer_field.
472 @postrefcountsame{integer_field}
474 @sa bt_ctf_field_signed_integer_get_value(): Returns the signed integral
475 value of a given integer field.
477 extern int bt_ctf_field_signed_integer_set_value(
478 struct bt_ctf_field
*integer_field
, int64_t value
);
481 @brief Returns the unsigned integral value of the @intfield
484 @param[in] integer_field Integer field of which to get the
485 unsigned integral value.
486 @param[out] value Returned unsigned integral value of
488 @returns 0 on success, or a negative value on
489 error, including if \p integer_field
490 has no integral value yet.
492 @prenotnull{integer_field}
494 @preisintfield{integer_field}
495 @pre bt_ctf_field_type_integer_get_signed() returns 0 for the parent
496 @ft of \p integer_field.
497 @pre \p integer_field contains an unsigned integral value previously
498 set with bt_ctf_field_unsigned_integer_set_value().
499 @postrefcountsame{integer_field}
501 @sa bt_ctf_field_unsigned_integer_set_value(): Sets the unsigned
502 integral value of a given integer field.
504 extern int bt_ctf_field_unsigned_integer_get_value(
505 struct bt_ctf_field
*integer_field
, uint64_t *value
);
508 @brief Sets the unsigned integral value of the @intfield
509 \p integer_field to \p value.
511 @param[in] integer_field Integer field of which to set
512 the unsigned integral value.
513 @param[in] value New unsigned integral value of
515 @returns 0 on success, or a negative value on error.
517 @prenotnull{integer_field}
518 @preisintfield{integer_field}
519 @prehot{integer_field}
520 @pre bt_ctf_field_type_integer_get_signed() returns 0 for the parent
521 @ft of \p integer_field.
522 @postrefcountsame{integer_field}
524 @sa bt_ctf_field_unsigned_integer_get_value(): Returns the unsigned
525 integral value of a given integer field.
527 extern int bt_ctf_field_unsigned_integer_set_value(
528 struct bt_ctf_field
*integer_field
, uint64_t value
);
533 @defgroup ctfirfloatfield CTF IR floating point number field
535 @brief CTF IR floating point number field.
538 #include <babeltrace/ctf-ir/fields.h>
541 A CTF IR <strong><em>floating point number field</em></strong> is a
542 @field which holds a floating point number value, and which is
543 described by a @floatft.
545 After you create a floating point number field with bt_ctf_field_create(), you
546 \em must set a floating point number value with
547 bt_ctf_field_floating_point_set_value() before you can get the
548 field's value with bt_ctf_field_floating_point_get_value().
550 @sa ctfirfloatfieldtype
553 @addtogroup ctfirfloatfield
558 @brief Returns the floating point number value of the @floatfield
561 @param[in] float_field Floating point number field of which to get the
562 floating point number value.
563 @param[out] value Returned floating point number value of
565 @returns 0 on success, or a negative value on error,
566 including if \p float_field has no floating
567 point number value yet.
569 @prenotnull{float_field}
571 @preisfloatfield{float_field}
572 @pre \p float_field contains a floating point number value previously
573 set with bt_ctf_field_floating_point_set_value().
574 @postrefcountsame{float_field}
576 @sa bt_ctf_field_floating_point_set_value(): Sets the floating point
577 number value of a given floating point number field.
579 extern int bt_ctf_field_floating_point_get_value(
580 struct bt_ctf_field
*float_field
, double *value
);
583 @brief Sets the floating point number value of the @floatfield
584 \p float_field to \p value.
586 @param[in] float_field Floating point number field of which to set
587 the floating point number value.
588 @param[in] value New floating point number value of
590 @returns 0 on success, or a negative value on error.
592 @prenotnull{float_field}
593 @preisfloatfield{float_field}
595 @postrefcountsame{float_field}
597 @sa bt_ctf_field_floating_point_get_value(): Returns the floating point
598 number value of a given floating point number field.
600 extern int bt_ctf_field_floating_point_set_value(
601 struct bt_ctf_field
*float_field
,
607 @defgroup ctfirenumfield CTF IR enumeration field
609 @brief CTF IR enumeration field.
612 #include <babeltrace/ctf-ir/fields.h>
615 A CTF IR <strong><em>enumeration field</em></strong> is a @field which
616 holds a @intfield, and which is described by a @enumft.
618 To set the current integral value of an enumeration field, you need to
619 get its wrapped @intfield with bt_ctf_field_enumeration_get_container(),
620 and then set the integral value with either
621 bt_ctf_field_signed_integer_set_value() or
622 bt_ctf_field_unsigned_integer_set_value().
624 Once you set the integral value of an enumeration field by following the
625 previous paragraph, you can get the mappings containing this value in
626 their range with bt_ctf_field_enumeration_get_mappings(). This function
627 returns a @enumftiter.
629 @sa ctfirenumfieldtype
632 @addtogroup ctfirenumfield
637 @brief Returns the @intfield, potentially creating it, wrapped by the
638 @enumfield \p enum_field.
640 This function creates the @intfield to return if it does not currently
643 @param[in] enum_field Enumeration field of which to get the wrapped
645 @returns Integer field wrapped by \p enum_field, or
648 @prenotnull{enum_field}
649 @preisenumfield{enum_field}
650 @postrefcountsame{enum_field}
651 @postsuccessrefcountretinc
653 extern struct bt_ctf_field
*bt_ctf_field_enumeration_get_container(
654 struct bt_ctf_field
*enum_field
);
657 @brief Returns a @enumftiter on all the mappings of the field type of
658 \p enum_field which contain the current integral value of the
659 @enumfield \p enum_field in their range.
661 This function is the equivalent of using
662 bt_ctf_field_type_enumeration_find_mappings_by_unsigned_value() or
663 bt_ctf_field_type_enumeration_find_mappings_by_signed_value() with the
664 current integral value of \p enum_field.
666 @param[in] enum_field Enumeration field of which to get the mappings
667 containing the current integral value of \p
668 enum_field in their range.
669 @returns @enumftiter on the set of mappings of the field
670 type of \p enum_field which contain the current
671 integral value of \p enum_field in their range,
672 or \c NULL if no mappings were found or on
675 @prenotnull{enum_field}
676 @preisenumfield{enum_field}
677 @pre The wrapped integer field of \p enum_field contains an integral
679 @postrefcountsame{enum_field}
680 @postsuccessrefcountret1
681 @post <strong>On success</strong>, the returned @enumftiter can iterate
682 on at least one mapping.
684 extern struct bt_ctf_field_type_enumeration_mapping_iterator
*
685 bt_ctf_field_enumeration_get_mappings(struct bt_ctf_field
*enum_field
);
690 @defgroup ctfirstringfield CTF IR string field
692 @brief CTF IR string field.
695 #include <babeltrace/ctf-ir/fields.h>
698 A CTF IR <strong><em>string field</em></strong> is a @field which holds
699 a string value, and which is described by a @stringft.
701 Use bt_ctf_field_string_set_value() to set the current string value
702 of a string field object. You can also use bt_ctf_field_string_append()
703 and bt_ctf_field_string_append_len() to append a string to the current
704 value of a string field.
706 After you create a string field with bt_ctf_field_create(), you
707 \em must set a string value with
708 bt_ctf_field_string_set_value(), bt_ctf_field_string_append(), or
709 bt_ctf_field_string_append_len() before you can get the
710 field's value with bt_ctf_field_string_get_value().
712 @sa ctfirstringfieldtype
715 @addtogroup ctfirstringfield
720 @brief Returns the string value of the @stringfield \p string_field.
722 On success, \p string_field remains the sole owner of the returned
725 @param[in] string_field String field field of which to get the
727 @returns String value, or \c NULL on error.
729 @prenotnull{string_field}
731 @preisstringfield{string_field}
732 @pre \p string_field contains a string value previously
733 set with bt_ctf_field_string_set_value(),
734 bt_ctf_field_string_append(), or
735 bt_ctf_field_string_append_len().
736 @postrefcountsame{string_field}
738 @sa bt_ctf_field_string_set_value(): Sets the string value of a given
741 extern const char *bt_ctf_field_string_get_value(
742 struct bt_ctf_field
*string_field
);
745 @brief Sets the string value of the @stringfield \p string_field to
748 @param[in] string_field String field of which to set
750 @param[in] value New string value of \p string_field (copied
752 @returns 0 on success, or a negative value on error.
754 @prenotnull{string_field}
756 @preisstringfield{string_field}
757 @prehot{string_field}
758 @postrefcountsame{string_field}
760 @sa bt_ctf_field_string_get_value(): Returns the string value of a
763 extern int bt_ctf_field_string_set_value(struct bt_ctf_field
*string_field
,
767 @brief Appends the string \p value to the current string value of
768 the @stringfield \p string_field.
770 This function is the equivalent of:
773 bt_ctf_field_string_append_len(string_field, value, strlen(value));
776 @param[in] string_field String field of which to append \p value to
778 @param[in] value String to append to the current string value
779 of \p string_field (copied on success).
780 @returns 0 on success, or a negative value on error.
782 @prenotnull{string_field}
784 @preisstringfield{string_field}
785 @prehot{string_field}
786 @postrefcountsame{string_field}
788 @sa bt_ctf_field_string_set_value(): Sets the string value of a given
791 extern int bt_ctf_field_string_append(struct bt_ctf_field
*string_field
,
795 @brief Appends the first \p length characters of \p value to the
796 current string value of the @stringfield \p string_field.
798 If \p string_field has no current string value, this function first
799 sets an empty string as the string value of \p string_field and then
800 appends the first \p length characters of \p value.
802 @param[in] string_field String field of which to append the first
803 \p length characters of \p value to
805 @param[in] value String containing the characters to append to
806 the current string value of \p string_field
808 @param[in] length Number of characters of \p value to append to
809 the current string value of \p string_field.
810 @returns 0 on success, or a negative value on error.
812 @prenotnull{string_field}
814 @preisstringfield{string_field}
815 @prehot{string_field}
816 @postrefcountsame{string_field}
818 @sa bt_ctf_field_string_set_value(): Sets the string value of a given
821 extern int bt_ctf_field_string_append_len(
822 struct bt_ctf_field
*string_field
, const char *value
,
823 unsigned int length
);
828 @defgroup ctfirstructfield CTF IR structure field
830 @brief CTF IR structure field.
833 #include <babeltrace/ctf-ir/fields.h>
836 A CTF IR <strong><em>structure field</em></strong> is a @field which
837 contains an ordered list of zero or more named @fields which can be
838 different @fts, and which is described by a @structft.
840 To set the value of a specific field of a structure field, you need to
841 first get the field with bt_ctf_field_structure_get_field_by_name() or
842 bt_ctf_field_structure_get_field_by_index(). If you already have a
843 field object, you can assign it to a specific name within a structure
844 field with bt_ctf_field_structure_set_field_by_name().
846 @sa ctfirstructfieldtype
849 @addtogroup ctfirstructfield
854 @brief Returns the @field named \p name, potentially creating it,
855 in the @structfield \p struct_field.
857 This function creates the @field to return if it does not currently
860 @param[in] struct_field Structure field of which to get the field
862 @param[in] name Name of the field to get from \p struct_field.
863 @returns Field named \p name in \p struct_field, or
866 @prenotnull{struct_field}
868 @preisstructfield{struct_field}
869 @postrefcountsame{struct_field}
870 @postsuccessrefcountretinc
872 @sa bt_ctf_field_structure_get_field_by_index(): Returns the field of a
873 given structure field by index.
874 @sa bt_ctf_field_structure_set_field_by_name(): Sets the field of a
875 given structure field by name.
877 extern struct bt_ctf_field
*bt_ctf_field_structure_get_field_by_name(
878 struct bt_ctf_field
*struct_field
, const char *name
);
880 /* Pre-2.0 CTF writer compatibility */
881 #define bt_ctf_field_structure_get_field bt_ctf_field_structure_get_field_by_name
884 @brief Returns the @field at index \p index in the @structfield
887 @param[in] struct_field Structure field of which to get the field
889 @param[in] index Index of the field to get in \p struct_field.
890 @returns Field at index \p index in \p struct_field, or
893 @prenotnull{struct_field}
894 @preisstructfield{struct_field}
895 @pre \p index is lesser than the number of fields contained in the
896 parent field type of \p struct_field (see
897 bt_ctf_field_type_structure_get_field_count()).
898 @postrefcountsame{struct_field}
899 @postsuccessrefcountretinc
901 @sa bt_ctf_field_structure_get_field_by_name(): Returns the field of a
902 given structure field by name.
903 @sa bt_ctf_field_structure_set_field_by_name(): Sets the field of a
904 given structure field by name.
906 extern struct bt_ctf_field
*bt_ctf_field_structure_get_field_by_index(
907 struct bt_ctf_field
*struct_field
, uint64_t index
);
910 @brief Sets the field of the @structfield \p struct_field named \p name
911 to the @field \p field.
913 If \p struct_field already contains a field named \p name, then it may
914 either be replaced by \p field and its reference count is decremented,
915 or \p field's value is assigned to it.
917 The field type of \p field, as returned by bt_ctf_field_get_type(),
918 \em must be equivalent to the field type returned by
919 bt_ctf_field_type_structure_get_field_type_by_name() with the field
920 type of \p struct_field and the same name, \p name.
922 bt_ctf_trace_get_packet_header_type() for the parent trace class of
925 @param[in] struct_field Structure field of which to set the field
927 @param[in] name Name of the field to set in \p struct_field.
928 @param[in] field Field named \p name to set in \p struct_field.
929 @returns 0 on success, or -1 on error.
931 @prenotnull{struct_field}
934 @prehot{struct_field}
935 @preisstructfield{struct_field}
936 @pre \p field has a field type equivalent to the field type returned by
937 bt_ctf_field_type_structure_get_field_type_by_name() for the
938 field type of \p struct_field with the name \p name.
939 @postrefcountsame{struct_field}
940 @post <strong>On success, the field in \p struct_field named \p name</strong>
941 may either be replaced by \p field or have the same value as \p field.
942 @postsuccessrefcountinc{field}
944 @sa bt_ctf_field_structure_get_field_by_index(): Returns the field of a
945 given structure field by index.
946 @sa bt_ctf_field_structure_get_field_by_name(): Returns the field of a
947 given structure field by name.
949 extern int bt_ctf_field_structure_set_field_by_name(
950 struct bt_ctf_field
*struct_field
,
951 const char *name
, struct bt_ctf_field
*field
);
956 @defgroup ctfirarrayfield CTF IR array field
958 @brief CTF IR array field.
961 #include <babeltrace/ctf-ir/fields.h>
964 A CTF IR <strong><em>array field</em></strong> is a @field which
965 contains an ordered list of zero or more @fields sharing the same @ft,
966 and which is described by a @arrayft.
968 To set the value of a specific field of an array field, you need to
969 first get the field with bt_ctf_field_array_get_field().
971 @sa ctfirarrayfieldtype
974 @addtogroup ctfirarrayfield
979 @brief Returns the @field at index \p index, potentially creating it,
980 in the @arrayfield \p array_field.
982 This function creates the @field to return if it does not currently
985 @param[in] array_field Array field of which to get the field
987 @param[in] index Index of the field to get in \p array_field.
988 @returns Field at index \p index in \p array_field, or
991 @prenotnull{array_field}
992 @preisarrayfield{array_field}
993 @pre \p index is lesser than bt_ctf_field_type_array_get_length() called
994 on the field type of \p array_field.
995 @postrefcountsame{array_field}
996 @postsuccessrefcountretinc
998 extern struct bt_ctf_field
*bt_ctf_field_array_get_field(
999 struct bt_ctf_field
*array_field
, uint64_t index
);
1004 @defgroup ctfirseqfield CTF IR sequence field
1005 @ingroup ctfirfields
1006 @brief CTF IR sequence field.
1009 #include <babeltrace/ctf-ir/fields.h>
1012 A CTF IR <strong><em>sequence field</em></strong> is a @field which
1013 contains an ordered list of zero or more @fields sharing the same @ft,
1014 and which is described by a @seqft.
1016 Before you can get a specific field of a sequence field with
1017 bt_ctf_field_sequence_get_field(), you need to set its current length
1018 @intfield with bt_ctf_field_sequence_set_length(). The integral value of
1019 the length field of a sequence field indicates the number of fields
1022 @sa ctfirseqfieldtype
1025 @addtogroup ctfirseqfield
1030 @brief Returns the @field at index \p index, potentially creating it,
1031 in the @seqfield \p sequence_field.
1033 This function creates the @field to return if it does not currently
1036 @param[in] sequence_field Sequence field of which to get the field
1038 @param[in] index Index of the field to get in
1040 @returns Field at index \p index in
1041 \p sequence_field, or \c NULL on error.
1043 @prenotnull{sequence_field}
1044 @preisseqfield{sequence_field}
1045 @pre \p sequence_field has a length field previously set with
1046 bt_ctf_field_sequence_set_length().
1047 @pre \p index is lesser than the current integral value of the current
1048 length field of \p sequence_field (see
1049 bt_ctf_field_sequence_get_length()).
1050 @postrefcountsame{sequence_field}
1051 @postsuccessrefcountretinc
1053 extern struct bt_ctf_field
*bt_ctf_field_sequence_get_field(
1054 struct bt_ctf_field
*sequence_field
, uint64_t index
);
1057 @brief Returns the length @intfield of the @seqfield \p sequence_field.
1059 The current integral value of the returned length field indicates the
1060 number of fields contained in \p sequence_field.
1062 @param[in] sequence_field Sequence field of which to get the
1064 @returns Length field of \p sequence_field, or
1067 @prenotnull{sequence_field}
1068 @preisseqfield{sequence_field}
1069 @pre \p sequence_field has a length field previously set with
1070 bt_ctf_field_sequence_set_length().
1071 @postrefcountsame{sequence_field}
1072 @postsuccessrefcountretinc
1073 @post <strong>On success</strong>, the returned field is a @intfield.
1075 @sa bt_ctf_field_sequence_set_length(): Sets the length field of a given
1078 extern struct bt_ctf_field
*bt_ctf_field_sequence_get_length(
1079 struct bt_ctf_field
*sequence_field
);
1082 @brief Sets the length @intfield of the @seqfield \p sequence_field
1085 The current integral value of \p length_field indicates the number of
1086 fields contained in \p sequence_field.
1088 @param[in] sequence_field Sequence field of which to set the
1090 @param[in] length_field Length field of \p sequence_field.
1091 @returns 0 on success, or a negative value on error.
1093 @prenotnull{sequence_field}
1094 @prenotnull{length_field}
1095 @preisseqfield{sequence_field}
1096 @preisintfield{length_field}
1097 @prehot{sequence_field}
1098 @postrefcountsame{sequence_field}
1099 @postsuccessrefcountinc{length_field}
1101 @sa bt_ctf_field_sequence_get_length(): Returns the length field of a
1102 given sequence field.
1104 extern int bt_ctf_field_sequence_set_length(struct bt_ctf_field
*sequence_field
,
1105 struct bt_ctf_field
*length_field
);
1110 @defgroup ctfirvarfield CTF IR variant field
1111 @ingroup ctfirfields
1112 @brief CTF IR variant field.
1115 #include <babeltrace/ctf-ir/fields.h>
1118 A CTF IR <strong><em>variant field</em></strong> is a @field which
1119 contains a current @field amongst one or more choices, and which is
1120 described by a @varft.
1122 Use bt_ctf_field_variant_get_field() to get the @field selected by
1123 a specific tag @enumfield. Once you call this function, you can call
1124 bt_ctf_field_variant_get_current_field() afterwards to get this last
1127 @sa ctfirvarfieldtype
1130 @addtogroup ctfirvarfield
1135 @brief Returns the @field, potentially creating it, selected by the
1136 tag @intfield \p tag_field in the @varfield \p variant_field.
1138 This function creates the @field to return if it does not currently
1141 Once you call this function, you can call
1142 bt_ctf_field_variant_get_current_field() to get the same field again,
1143 and you can call bt_ctf_field_variant_get_tag() to get \p tag_field.
1145 @param[in] variant_field Variant field of which to get the field
1146 selected by \p tag_field.
1147 @param[in] tag_field Tag field.
1148 @returns Field selected by \p tag_field in
1149 \p variant_field, or \c NULL on error.
1151 @prenotnull{variant_field}
1152 @prenotnull{tag_field}
1153 @preisvarfield{variant_field}
1154 @preisenumfield{tag_field}
1155 @postrefcountsame{variant_field}
1156 @postsuccessrefcountinc{tag_field}
1157 @postsuccessrefcountretinc
1159 extern struct bt_ctf_field
*bt_ctf_field_variant_get_field(
1160 struct bt_ctf_field
*variant_field
,
1161 struct bt_ctf_field
*tag_field
);
1164 @brief Returns the currently selected @field of the @varfield
1167 @param[in] variant_field Variant field of which to get the
1168 currently selected field.
1169 @returns Currently selected field of
1170 \p variant_field, or \c NULL if there's
1171 no selected field or on error.
1173 @prenotnull{variant_field}
1174 @preisvarfield{variant_field}
1175 @pre \p variant_field contains has a current selected field previously
1176 set with bt_ctf_field_variant_get_field().
1177 @postrefcountsame{variant_field}
1178 @postsuccessrefcountretinc
1180 extern struct bt_ctf_field
*bt_ctf_field_variant_get_current_field(
1181 struct bt_ctf_field
*variant_field
);
1184 @brief Returns the tag @enumfield of the @varfield \p variant_field.
1186 @param[in] variant_field Variant field of which to get the
1188 @returns Tag field of \p variant_field, or
1191 @prenotnull{variant_field}
1192 @preisvarfield{variant_field}
1193 @pre \p variant_field contains has a current selected field previously
1194 set with bt_ctf_field_variant_get_field().
1195 @postrefcountsame{variant_field}
1196 @postsuccessrefcountretinc
1197 @post <strong>On success</strong>, the returned field is a @enumfield.
1199 extern struct bt_ctf_field
*bt_ctf_field_variant_get_tag(
1200 struct bt_ctf_field
*variant_field
);
1208 #endif /* BABELTRACE_CTF_IR_FIELDS_H */