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>
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_packet_set_header().
61 - Stream packet context field: bt_packet_set_context().
63 - Stream event header field: bt_event_set_header().
64 - Stream event context field: bt_event_set_stream_event_context().
65 - Event context field: bt_event_set_event_context().
66 - Event payload field: bt_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_field_create(). The enumeration and compound fields create their
87 contained fields with the following getters if such fields do not exist
90 - bt_field_enumeration_get_container()
91 - bt_field_structure_get_field_by_name()
92 - bt_field_array_get_field()
93 - bt_field_sequence_get_field()
94 - bt_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_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_field_get_type(). You can get the
102 \link #bt_field_type_id type ID\endlink of this field type directly with
103 bt_field_get_type_id().
105 You can get a deep copy of a field with bt_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_event_class
;
137 struct bt_field_type
;
138 struct bt_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_field
*bt_field_create(
164 struct bt_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_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_field_type
*bt_field_get_type(
181 struct bt_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_FIELD_TYPE_ID_UNKNOWN on error.
199 @postrefcountsame{field}
201 @sa #bt_field_type_id: CTF IR field type ID.
202 @sa bt_field_is_integer(): Returns whether or not a given field is a
204 @sa bt_field_is_floating_point(): Returns whether or not a given
205 field is a @floatfield.
206 @sa bt_field_is_enumeration(): Returns whether or not a given field
208 @sa bt_field_is_string(): Returns whether or not a given field is a
210 @sa bt_field_is_structure(): Returns whether or not a given field is
212 @sa bt_field_is_array(): Returns whether or not a given field is a
214 @sa bt_field_is_sequence(): Returns whether or not a given field is
216 @sa bt_field_is_variant(): Returns whether or not a given field is a
219 extern enum bt_field_type_id
bt_field_get_type_id(
220 struct bt_field
*field
);
223 * bt_field_signed_integer_get_value: get a signed integer field's value
225 * Get a signed integer field's value.
227 * @param integer Signed integer field instance.
228 * @param value Pointer to a signed integer where the value will be stored.
230 * Returns 0 on success, a negative value on error.
232 extern int bt_field_signed_integer_get_value(struct bt_field
*integer
,
236 @brief Returns whether or not the @field \p field is a @intfield.
238 @param[in] field Field to check (can be \c NULL).
239 @returns #BT_TRUE if \p field is an integer field, or
240 #BT_FALSE otherwise (including if \p field is
244 @postrefcountsame{field}
246 @sa bt_field_get_type_id(): Returns the type ID of a given
249 extern bt_bool
bt_field_is_integer(struct bt_field
*field
);
252 @brief Returns whether or not the @field \p field is a @floatfield.
254 @param[in] field Field to check (can be \c NULL).
255 @returns #BT_TRUE if \p field is a floating point number fiel
256 #BT_FALSE or 0 otherwise (including if \p field is
260 @postrefcountsame{field}
262 @sa bt_field_get_type_id(): Returns the type ID of a given
265 extern bt_bool
bt_field_is_floating_point(struct bt_field
*field
);
268 @brief Returns whether or not the @field \p field is a @enumfield.
270 @param[in] field Field to check (can be \c NULL).
271 @returns #BT_TRUE if \p field is an enumeration field, or
272 #BT_FALSE otherwise (including if \p field is
276 @postrefcountsame{field}
278 @sa bt_field_get_type_id(): Returns the type ID of a given
281 extern bt_bool
bt_field_is_enumeration(struct bt_field
*field
);
284 @brief Returns whether or not the @field \p field is a @stringfield.
286 @param[in] field Field to check (can be \c NULL).
287 @returns #BT_TRUE if \p field is a string field, or
288 #BT_FALSE otherwise (including if \p field is
292 @postrefcountsame{field}
294 @sa bt_field_get_type_id(): Returns the type ID of a given
297 extern bt_bool
bt_field_is_string(struct bt_field
*field
);
300 @brief Returns whether or not the @field \p field is a @structfield.
302 @param[in] field Field to check (can be \c NULL).
303 @returns #BT_TRUE if \p field is a structure field, or
304 #BT_FALSE otherwise (including if \p field is
308 @postrefcountsame{field}
310 @sa bt_field_get_type_id(): Returns the type ID of a given
313 extern bt_bool
bt_field_is_structure(struct bt_field
*field
);
316 @brief Returns whether or not the @field \p field is a @arrayfield.
318 @param[in] field Field to check (can be \c NULL).
319 @returns #BT_TRUE if \p field is an array field, or
320 #BT_FALSE otherwise (including if \p field is
324 @postrefcountsame{field}
326 @sa bt_field_get_type_id(): Returns the type ID of a given
329 extern bt_bool
bt_field_is_array(struct bt_field
*field
);
332 @brief Returns whether or not the @field \p field is a @seqfield.
334 @param[in] field Field to check (can be \c NULL).
335 @returns #BT_TRUE if \p field is a sequence field, or
336 #BT_FALSE otherwise (including if \p field is
340 @postrefcountsame{field}
342 @sa bt_field_get_type_id(): Returns the type ID of a given
345 extern bt_bool
bt_field_is_sequence(struct bt_field
*field
);
348 @brief Returns whether or not the @field \p field is a @varfield.
350 @param[in] field Field to check (can be \c NULL).
351 @returns #BT_TRUE if \p field is a variant field, or
352 #BT_FALSE otherwise (including if \p field is
356 @postrefcountsame{field}
358 @sa bt_field_get_type_id(): Returns the type ID of a given
361 extern bt_bool
bt_field_is_variant(struct bt_field
*field
);
366 @name Misc. functions
371 @brief Creates a \em deep copy of the @field \p field.
373 You can copy a frozen field: the resulting copy is <em>not frozen</em>.
375 @param[in] field Field to copy.
376 @returns Deep copy of \p field on success,
380 @postrefcountsame{field}
381 @postsuccessrefcountret1
382 @post <strong>On success</strong>, the returned field is not frozen.
384 extern struct bt_field
*bt_field_copy(struct bt_field
*field
);
391 @defgroup ctfirintfield CTF IR integer field
393 @brief CTF IR integer field.
396 #include <babeltrace/ctf-ir/fields.h>
399 A CTF IR <strong><em>integer field</em></strong> is a @field which
400 holds a signed or unsigned integral value, and which is described by
403 An integer field object is considered \em unsigned if
404 bt_field_type_integer_get_signed() on its parent field type returns
405 0. Otherwise it is considered \em signed. You \em must use
406 bt_field_unsigned_integer_get_value() and
407 bt_field_unsigned_integer_set_value() with an unsigned integer
408 field, and bt_field_signed_integer_get_value() and
409 bt_field_signed_integer_set_value() with a signed integer field.
411 After you create an integer field with bt_field_create(), you
412 \em must set an integral value with
413 bt_field_unsigned_integer_set_value() or
414 bt_field_signed_integer_set_value() before you can get the
415 field's value with bt_field_unsigned_integer_get_value() or
416 bt_field_signed_integer_get_value().
418 @sa ctfirintfieldtype
421 @addtogroup ctfirintfield
426 @brief Returns the signed integral value of the @intfield
429 @param[in] integer_field Integer field of which to get the
430 signed integral value.
431 @param[out] value Returned signed integral value of
433 @returns 0 on success, or a negative value on
434 error, including if \p integer_field
435 has no integral value yet.
437 @prenotnull{integer_field}
439 @preisintfield{integer_field}
440 @pre bt_field_type_integer_get_signed() returns 1 for the parent
441 @ft of \p integer_field.
442 @pre \p integer_field contains a signed integral value previously
443 set with bt_field_signed_integer_set_value().
444 @postrefcountsame{integer_field}
446 @sa bt_field_signed_integer_set_value(): Sets the signed integral
447 value of a given integer field.
449 extern int bt_field_signed_integer_get_value(
450 struct bt_field
*integer_field
, int64_t *value
);
453 @brief Sets the signed integral value of the @intfield
454 \p integer_field to \p value.
456 @param[in] integer_field Integer field of which to set
457 the signed integral value.
458 @param[in] value New signed integral value of
460 @returns 0 on success, or a negative value on error.
462 @prenotnull{integer_field}
463 @preisintfield{integer_field}
464 @prehot{integer_field}
465 @pre bt_field_type_integer_get_signed() returns 1 for the parent
466 @ft of \p integer_field.
467 @postrefcountsame{integer_field}
469 @sa bt_field_signed_integer_get_value(): Returns the signed integral
470 value of a given integer field.
472 extern int bt_field_signed_integer_set_value(
473 struct bt_field
*integer_field
, int64_t value
);
476 @brief Returns the unsigned integral value of the @intfield
479 @param[in] integer_field Integer field of which to get the
480 unsigned integral value.
481 @param[out] value Returned unsigned integral value of
483 @returns 0 on success, or a negative value on
484 error, including if \p integer_field
485 has no integral value yet.
487 @prenotnull{integer_field}
489 @preisintfield{integer_field}
490 @pre bt_field_type_integer_get_signed() returns 0 for the parent
491 @ft of \p integer_field.
492 @pre \p integer_field contains an unsigned integral value previously
493 set with bt_field_unsigned_integer_set_value().
494 @postrefcountsame{integer_field}
496 @sa bt_field_unsigned_integer_set_value(): Sets the unsigned
497 integral value of a given integer field.
499 extern int bt_field_unsigned_integer_get_value(
500 struct bt_field
*integer_field
, uint64_t *value
);
503 @brief Sets the unsigned integral value of the @intfield
504 \p integer_field to \p value.
506 @param[in] integer_field Integer field of which to set
507 the unsigned integral value.
508 @param[in] value New unsigned integral value of
510 @returns 0 on success, or a negative value on error.
512 @prenotnull{integer_field}
513 @preisintfield{integer_field}
514 @prehot{integer_field}
515 @pre bt_field_type_integer_get_signed() returns 0 for the parent
516 @ft of \p integer_field.
517 @postrefcountsame{integer_field}
519 @sa bt_field_unsigned_integer_get_value(): Returns the unsigned
520 integral value of a given integer field.
522 extern int bt_field_unsigned_integer_set_value(
523 struct bt_field
*integer_field
, uint64_t value
);
528 @defgroup ctfirfloatfield CTF IR floating point number field
530 @brief CTF IR floating point number field.
533 #include <babeltrace/ctf-ir/fields.h>
536 A CTF IR <strong><em>floating point number field</em></strong> is a
537 @field which holds a floating point number value, and which is
538 described by a @floatft.
540 After you create a floating point number field with bt_field_create(), you
541 \em must set a floating point number value with
542 bt_field_floating_point_set_value() before you can get the
543 field's value with bt_field_floating_point_get_value().
545 @sa ctfirfloatfieldtype
548 @addtogroup ctfirfloatfield
553 @brief Returns the floating point number value of the @floatfield
556 @param[in] float_field Floating point number field of which to get the
557 floating point number value.
558 @param[out] value Returned floating point number value of
560 @returns 0 on success, or a negative value on error,
561 including if \p float_field has no floating
562 point number value yet.
564 @prenotnull{float_field}
566 @preisfloatfield{float_field}
567 @pre \p float_field contains a floating point number value previously
568 set with bt_field_floating_point_set_value().
569 @postrefcountsame{float_field}
571 @sa bt_field_floating_point_set_value(): Sets the floating point
572 number value of a given floating point number field.
574 extern int bt_field_floating_point_get_value(
575 struct bt_field
*float_field
, double *value
);
578 @brief Sets the floating point number value of the @floatfield
579 \p float_field to \p value.
581 @param[in] float_field Floating point number field of which to set
582 the floating point number value.
583 @param[in] value New floating point number value of
585 @returns 0 on success, or a negative value on error.
587 @prenotnull{float_field}
588 @preisfloatfield{float_field}
590 @postrefcountsame{float_field}
592 @sa bt_field_floating_point_get_value(): Returns the floating point
593 number value of a given floating point number field.
595 extern int bt_field_floating_point_set_value(
596 struct bt_field
*float_field
,
602 @defgroup ctfirenumfield CTF IR enumeration field
604 @brief CTF IR enumeration field.
607 #include <babeltrace/ctf-ir/fields.h>
610 A CTF IR <strong><em>enumeration field</em></strong> is a @field which
611 holds a @intfield, and which is described by a @enumft.
613 To set the current integral value of an enumeration field, you need to
614 get its wrapped @intfield with bt_field_enumeration_get_container(),
615 and then set the integral value with either
616 bt_field_signed_integer_set_value() or
617 bt_field_unsigned_integer_set_value().
619 Once you set the integral value of an enumeration field by following the
620 previous paragraph, you can get the mappings containing this value in
621 their range with bt_field_enumeration_get_mappings(). This function
622 returns a @enumftiter.
624 @sa ctfirenumfieldtype
627 @addtogroup ctfirenumfield
632 @brief Returns the @intfield, potentially creating it, wrapped by the
633 @enumfield \p enum_field.
635 This function creates the @intfield to return if it does not currently
638 @param[in] enum_field Enumeration field of which to get the wrapped
640 @returns Integer field wrapped by \p enum_field, or
643 @prenotnull{enum_field}
644 @preisenumfield{enum_field}
645 @postrefcountsame{enum_field}
646 @postsuccessrefcountretinc
648 extern struct bt_field
*bt_field_enumeration_get_container(
649 struct bt_field
*enum_field
);
652 @brief Returns a @enumftiter on all the mappings of the field type of
653 \p enum_field which contain the current integral value of the
654 @enumfield \p enum_field in their range.
656 This function is the equivalent of using
657 bt_field_type_enumeration_find_mappings_by_unsigned_value() or
658 bt_field_type_enumeration_find_mappings_by_signed_value() with the
659 current integral value of \p enum_field.
661 @param[in] enum_field Enumeration field of which to get the mappings
662 containing the current integral value of \p
663 enum_field in their range.
664 @returns @enumftiter on the set of mappings of the field
665 type of \p enum_field which contain the current
666 integral value of \p enum_field in their range,
667 or \c NULL if no mappings were found or on
670 @prenotnull{enum_field}
671 @preisenumfield{enum_field}
672 @pre The wrapped integer field of \p enum_field contains an integral
674 @postrefcountsame{enum_field}
675 @postsuccessrefcountret1
676 @post <strong>On success</strong>, the returned @enumftiter can iterate
677 on at least one mapping.
679 extern struct bt_field_type_enumeration_mapping_iterator
*
680 bt_field_enumeration_get_mappings(struct bt_field
*enum_field
);
685 @defgroup ctfirstringfield CTF IR string field
687 @brief CTF IR string field.
690 #include <babeltrace/ctf-ir/fields.h>
693 A CTF IR <strong><em>string field</em></strong> is a @field which holds
694 a string value, and which is described by a @stringft.
696 Use bt_field_string_set_value() to set the current string value
697 of a string field object. You can also use bt_field_string_append()
698 and bt_field_string_append_len() to append a string to the current
699 value of a string field.
701 After you create a string field with bt_field_create(), you
702 \em must set a string value with
703 bt_field_string_set_value(), bt_field_string_append(), or
704 bt_field_string_append_len() before you can get the
705 field's value with bt_field_string_get_value().
707 @sa ctfirstringfieldtype
710 @addtogroup ctfirstringfield
715 @brief Returns the string value of the @stringfield \p string_field.
717 On success, \p string_field remains the sole owner of the returned
720 @param[in] string_field String field field of which to get the
722 @returns String value, or \c NULL on error.
724 @prenotnull{string_field}
726 @preisstringfield{string_field}
727 @pre \p string_field contains a string value previously
728 set with bt_field_string_set_value(),
729 bt_field_string_append(), or
730 bt_field_string_append_len().
731 @postrefcountsame{string_field}
733 @sa bt_field_string_set_value(): Sets the string value of a given
736 extern const char *bt_field_string_get_value(
737 struct bt_field
*string_field
);
740 @brief Sets the string value of the @stringfield \p string_field to
743 @param[in] string_field String field of which to set
745 @param[in] value New string value of \p string_field (copied
747 @returns 0 on success, or a negative value on error.
749 @prenotnull{string_field}
751 @preisstringfield{string_field}
752 @prehot{string_field}
753 @postrefcountsame{string_field}
755 @sa bt_field_string_get_value(): Returns the string value of a
758 extern int bt_field_string_set_value(struct bt_field
*string_field
,
762 @brief Appends the string \p value to the current string value of
763 the @stringfield \p string_field.
765 This function is the equivalent of:
768 bt_field_string_append_len(string_field, value, strlen(value));
771 @param[in] string_field String field of which to append \p value to
773 @param[in] value String to append to the current string value
774 of \p string_field (copied on success).
775 @returns 0 on success, or a negative value on error.
777 @prenotnull{string_field}
779 @preisstringfield{string_field}
780 @prehot{string_field}
781 @postrefcountsame{string_field}
783 @sa bt_field_string_set_value(): Sets the string value of a given
786 extern int bt_field_string_append(struct bt_field
*string_field
,
790 @brief Appends the first \p length characters of \p value to the
791 current string value of the @stringfield \p string_field.
793 If \p string_field has no current string value, this function first
794 sets an empty string as the string value of \p string_field and then
795 appends the first \p length characters of \p value.
797 @param[in] string_field String field of which to append the first
798 \p length characters of \p value to
800 @param[in] value String containing the characters to append to
801 the current string value of \p string_field
803 @param[in] length Number of characters of \p value to append to
804 the current string value of \p string_field.
805 @returns 0 on success, or a negative value on error.
807 @prenotnull{string_field}
809 @preisstringfield{string_field}
810 @prehot{string_field}
811 @postrefcountsame{string_field}
813 @sa bt_field_string_set_value(): Sets the string value of a given
816 extern int bt_field_string_append_len(
817 struct bt_field
*string_field
, const char *value
,
818 unsigned int length
);
823 @defgroup ctfirstructfield CTF IR structure field
825 @brief CTF IR structure field.
828 #include <babeltrace/ctf-ir/fields.h>
831 A CTF IR <strong><em>structure field</em></strong> is a @field which
832 contains an ordered list of zero or more named @fields which can be
833 different @fts, and which is described by a @structft.
835 To set the value of a specific field of a structure field, you need to
836 first get the field with bt_field_structure_get_field_by_name() or
837 bt_field_structure_get_field_by_index(). If you already have a
838 field object, you can assign it to a specific name within a structure
839 field with bt_field_structure_set_field_by_name().
841 @sa ctfirstructfieldtype
844 @addtogroup ctfirstructfield
849 @brief Returns the @field named \p name, potentially creating it,
850 in the @structfield \p struct_field.
852 This function creates the @field to return if it does not currently
855 @param[in] struct_field Structure field of which to get the field
857 @param[in] name Name of the field to get from \p struct_field.
858 @returns Field named \p name in \p struct_field, or
861 @prenotnull{struct_field}
863 @preisstructfield{struct_field}
864 @postrefcountsame{struct_field}
865 @postsuccessrefcountretinc
867 @sa bt_field_structure_get_field_by_index(): Returns the field of a
868 given structure field by index.
869 @sa bt_field_structure_set_field_by_name(): Sets the field of a
870 given structure field by name.
872 extern struct bt_field
*bt_field_structure_get_field_by_name(
873 struct bt_field
*struct_field
, const char *name
);
876 @brief Returns the @field at index \p index in the @structfield
879 @param[in] struct_field Structure field of which to get the field
881 @param[in] index Index of the field to get in \p struct_field.
882 @returns Field at index \p index in \p struct_field, or
885 @prenotnull{struct_field}
886 @preisstructfield{struct_field}
887 @pre \p index is lesser than the number of fields contained in the
888 parent field type of \p struct_field (see
889 bt_field_type_structure_get_field_count()).
890 @postrefcountsame{struct_field}
891 @postsuccessrefcountretinc
893 @sa bt_field_structure_get_field_by_name(): Returns the field of a
894 given structure field by name.
895 @sa bt_field_structure_set_field_by_name(): Sets the field of a
896 given structure field by name.
898 extern struct bt_field
*bt_field_structure_get_field_by_index(
899 struct bt_field
*struct_field
, uint64_t index
);
902 @brief Sets the field of the @structfield \p struct_field named \p name
903 to the @field \p field.
905 If \p struct_field already contains a field named \p name, then it may
906 either be replaced by \p field and its reference count is decremented,
907 or \p field's value is assigned to it.
909 The field type of \p field, as returned by bt_field_get_type(),
910 \em must be equivalent to the field type returned by
911 bt_field_type_structure_get_field_type_by_name() with the field
912 type of \p struct_field and the same name, \p name.
914 bt_trace_get_packet_header_type() for the parent trace class of
917 @param[in] struct_field Structure field of which to set the field
919 @param[in] name Name of the field to set in \p struct_field.
920 @param[in] field Field named \p name to set in \p struct_field.
921 @returns 0 on success, or -1 on error.
923 @prenotnull{struct_field}
926 @prehot{struct_field}
927 @preisstructfield{struct_field}
928 @pre \p field has a field type equivalent to the field type returned by
929 bt_field_type_structure_get_field_type_by_name() for the
930 field type of \p struct_field with the name \p name.
931 @postrefcountsame{struct_field}
932 @post <strong>On success, the field in \p struct_field named \p name</strong>
933 may either be replaced by \p field or have the same value as \p field.
934 @postsuccessrefcountinc{field}
936 @sa bt_field_structure_get_field_by_index(): Returns the field of a
937 given structure field by index.
938 @sa bt_field_structure_get_field_by_name(): Returns the field of a
939 given structure field by name.
941 extern int bt_field_structure_set_field_by_name(
942 struct bt_field
*struct_field
,
943 const char *name
, struct bt_field
*field
);
948 @defgroup ctfirarrayfield CTF IR array field
950 @brief CTF IR array field.
953 #include <babeltrace/ctf-ir/fields.h>
956 A CTF IR <strong><em>array field</em></strong> is a @field which
957 contains an ordered list of zero or more @fields sharing the same @ft,
958 and which is described by a @arrayft.
960 To set the value of a specific field of an array field, you need to
961 first get the field with bt_field_array_get_field().
963 @sa ctfirarrayfieldtype
966 @addtogroup ctfirarrayfield
971 @brief Returns the @field at index \p index, potentially creating it,
972 in the @arrayfield \p array_field.
974 This function creates the @field to return if it does not currently
977 @param[in] array_field Array field of which to get the field
979 @param[in] index Index of the field to get in \p array_field.
980 @returns Field at index \p index in \p array_field, or
983 @prenotnull{array_field}
984 @preisarrayfield{array_field}
985 @pre \p index is lesser than bt_field_type_array_get_length() called
986 on the field type of \p array_field.
987 @postrefcountsame{array_field}
988 @postsuccessrefcountretinc
990 extern struct bt_field
*bt_field_array_get_field(
991 struct bt_field
*array_field
, uint64_t index
);
996 @defgroup ctfirseqfield CTF IR sequence field
998 @brief CTF IR sequence field.
1001 #include <babeltrace/ctf-ir/fields.h>
1004 A CTF IR <strong><em>sequence field</em></strong> is a @field which
1005 contains an ordered list of zero or more @fields sharing the same @ft,
1006 and which is described by a @seqft.
1008 Before you can get a specific field of a sequence field with
1009 bt_field_sequence_get_field(), you need to set its current length
1010 @intfield with bt_field_sequence_set_length(). The integral value of
1011 the length field of a sequence field indicates the number of fields
1014 @sa ctfirseqfieldtype
1017 @addtogroup ctfirseqfield
1022 @brief Returns the @field at index \p index, potentially creating it,
1023 in the @seqfield \p sequence_field.
1025 This function creates the @field to return if it does not currently
1028 @param[in] sequence_field Sequence field of which to get the field
1030 @param[in] index Index of the field to get in
1032 @returns Field at index \p index in
1033 \p sequence_field, or \c NULL on error.
1035 @prenotnull{sequence_field}
1036 @preisseqfield{sequence_field}
1037 @pre \p sequence_field has a length field previously set with
1038 bt_field_sequence_set_length().
1039 @pre \p index is lesser than the current integral value of the current
1040 length field of \p sequence_field (see
1041 bt_field_sequence_get_length()).
1042 @postrefcountsame{sequence_field}
1043 @postsuccessrefcountretinc
1045 extern struct bt_field
*bt_field_sequence_get_field(
1046 struct bt_field
*sequence_field
, uint64_t index
);
1049 @brief Returns the length @intfield of the @seqfield \p sequence_field.
1051 The current integral value of the returned length field indicates the
1052 number of fields contained in \p sequence_field.
1054 @param[in] sequence_field Sequence field of which to get the
1056 @returns Length field of \p sequence_field, or
1059 @prenotnull{sequence_field}
1060 @preisseqfield{sequence_field}
1061 @pre \p sequence_field has a length field previously set with
1062 bt_field_sequence_set_length().
1063 @postrefcountsame{sequence_field}
1064 @postsuccessrefcountretinc
1065 @post <strong>On success</strong>, the returned field is a @intfield.
1067 @sa bt_field_sequence_set_length(): Sets the length field of a given
1070 extern struct bt_field
*bt_field_sequence_get_length(
1071 struct bt_field
*sequence_field
);
1074 @brief Sets the length @intfield of the @seqfield \p sequence_field
1077 The current integral value of \p length_field indicates the number of
1078 fields contained in \p sequence_field.
1080 @param[in] sequence_field Sequence field of which to set the
1082 @param[in] length_field Length field of \p sequence_field.
1083 @returns 0 on success, or a negative value on error.
1085 @prenotnull{sequence_field}
1086 @prenotnull{length_field}
1087 @preisseqfield{sequence_field}
1088 @preisintfield{length_field}
1089 @prehot{sequence_field}
1090 @postrefcountsame{sequence_field}
1091 @postsuccessrefcountinc{length_field}
1093 @sa bt_field_sequence_get_length(): Returns the length field of a
1094 given sequence field.
1096 extern int bt_field_sequence_set_length(struct bt_field
*sequence_field
,
1097 struct bt_field
*length_field
);
1102 @defgroup ctfirvarfield CTF IR variant field
1103 @ingroup ctfirfields
1104 @brief CTF IR variant field.
1107 #include <babeltrace/ctf-ir/fields.h>
1110 A CTF IR <strong><em>variant field</em></strong> is a @field which
1111 contains a current @field amongst one or more choices, and which is
1112 described by a @varft.
1114 Use bt_field_variant_get_field() to get the @field selected by
1115 a specific tag @enumfield. Once you call this function, you can call
1116 bt_field_variant_get_current_field() afterwards to get this last
1119 @sa ctfirvarfieldtype
1122 @addtogroup ctfirvarfield
1127 @brief Returns the @field, potentially creating it, selected by the
1128 tag @intfield \p tag_field in the @varfield \p variant_field.
1130 This function creates the @field to return if it does not currently
1133 Once you call this function, you can call
1134 bt_field_variant_get_current_field() to get the same field again,
1135 and you can call bt_field_variant_get_tag() to get \p tag_field.
1137 @param[in] variant_field Variant field of which to get the field
1138 selected by \p tag_field.
1139 @param[in] tag_field Tag field.
1140 @returns Field selected by \p tag_field in
1141 \p variant_field, or \c NULL on error.
1143 @prenotnull{variant_field}
1144 @prenotnull{tag_field}
1145 @preisvarfield{variant_field}
1146 @preisenumfield{tag_field}
1147 @postrefcountsame{variant_field}
1148 @postsuccessrefcountinc{tag_field}
1149 @postsuccessrefcountretinc
1151 extern struct bt_field
*bt_field_variant_get_field(
1152 struct bt_field
*variant_field
,
1153 struct bt_field
*tag_field
);
1156 @brief Returns the currently selected @field of the @varfield
1159 @param[in] variant_field Variant field of which to get the
1160 currently selected field.
1161 @returns Currently selected field of
1162 \p variant_field, or \c NULL if there's
1163 no selected field or on error.
1165 @prenotnull{variant_field}
1166 @preisvarfield{variant_field}
1167 @pre \p variant_field contains has a current selected field previously
1168 set with bt_field_variant_get_field().
1169 @postrefcountsame{variant_field}
1170 @postsuccessrefcountretinc
1172 extern struct bt_field
*bt_field_variant_get_current_field(
1173 struct bt_field
*variant_field
);
1176 @brief Returns the tag @enumfield of the @varfield \p variant_field.
1178 @param[in] variant_field Variant field of which to get the
1180 @returns Tag field of \p variant_field, or
1183 @prenotnull{variant_field}
1184 @preisvarfield{variant_field}
1185 @pre \p variant_field contains has a current selected field previously
1186 set with bt_field_variant_get_field().
1187 @postrefcountsame{variant_field}
1188 @postsuccessrefcountretinc
1189 @post <strong>On success</strong>, the returned field is a @enumfield.
1191 extern struct bt_field
*bt_field_variant_get_tag(
1192 struct bt_field
*variant_field
);
1196 /* Pre-2.0 CTF writer compatibility */
1197 #define bt_ctf_field bt_field
1198 #define bt_ctf_field_create bt_field_create
1199 #define bt_ctf_field_structure_get_field bt_field_structure_get_field_by_name
1200 #define bt_ctf_field_variant_get_field bt_field_variant_get_field
1201 #define bt_ctf_field_array_get_field bt_field_array_get_field
1202 #define bt_ctf_field_sequence_set_length bt_field_sequence_set_length
1203 #define bt_ctf_field_sequence_get_field bt_field_sequence_get_field
1204 #define bt_ctf_field_enumeration_get_container bt_field_enumeration_get_container
1205 #define bt_ctf_field_signed_integer_set_value bt_field_signed_integer_set_value
1206 #define bt_ctf_field_unsigned_integer_set_value bt_field_unsigned_integer_set_value
1207 #define bt_ctf_field_floating_point_set_value bt_field_floating_point_set_value
1208 #define bt_ctf_field_string_set_value bt_field_string_set_value
1214 #endif /* BABELTRACE_CTF_IR_FIELDS_H */