1f907b7ff9f22640d068709eb04f6598953064f1
[babeltrace.git] / include / babeltrace2 / trace-ir / field-class.h
1 #ifndef BABELTRACE2_TRACE_IR_FIELD_CLASS_H
2 #define BABELTRACE2_TRACE_IR_FIELD_CLASS_H
3
4 /*
5 * Copyright (c) 2010-2019 EfficiOS Inc. and Linux Foundation
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 * SOFTWARE.
24 */
25
26 #ifndef __BT_IN_BABELTRACE_H
27 # error "Please include <babeltrace2/babeltrace.h> instead."
28 #endif
29
30 #include <stdint.h>
31 #include <stddef.h>
32
33 #include <babeltrace2/types.h>
34
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38
39 /*!
40 @defgroup api-tir-fc Field classes
41 @ingroup api-tir
42
43 @brief
44 Classes of \bt_p_field.
45
46 <strong><em>Field classes</em></strong> are the classes of \bt_p_field:
47
48 @image html field-class-zoom.png
49
50 Field classes are \ref api-tir "trace IR" metadata objects.
51
52 There are many types of field classes. They can be divided into two main
53 categories:
54
55 <dl>
56 <dt>Scalar</dt>
57 <dd>
58 Classes of fields which contain a simple value.
59
60 The scalar field classes are:
61
62 - \ref api-tir-fc-bool "Boolean"
63 - \ref api-tir-fc-ba "Bit array"
64 - \ref api-tir-fc-int "Integer" (unsigned and signed)
65 - \ref api-tir-fc-enum "Enumeration" (unsigned and signed)
66 - \ref api-tir-fc-real "Real" (single-precision and double-precision)
67 - \ref api-tir-fc-string "String"
68 </dd>
69
70 <dt>Container</dt>
71 <dd>
72 Classes of fields which contain other fields.
73
74 The container field classes are:
75
76 - \ref api-tir-fc-array "Array" (static and dynamic)
77 - \ref api-tir-fc-struct "Structure"
78 - \ref api-tir-fc-opt "Option"
79 - \ref api-tir-fc-var "Variant"
80 </dd>
81 </dl>
82
83 @image html fc-to-field.png "Fields (green) are instances of field classes (orange)."
84
85 Some field classes conceptually inherit other field classes, eventually
86 making an inheritance hierarchy. For example, a \bt_sarray_fc
87 \em is an array field class. Therefore, a static array field class has
88 any property that an array field class has.
89
90 The complete field class inheritance hierarchy is:
91
92 @image html all-field-classes.png
93
94 In the illustration above:
95
96 - You can create any field class with a dark background with
97 a dedicated <code>bt_field_class_*_create()</code> function.
98
99 - A field class with a pale background is an \em abstract field class:
100 you cannot create it, but it has properties, therefore there are
101 functions which apply to it.
102
103 For example, bt_field_class_integer_set_preferred_display_base()
104 applies to any \bt_int_fc.
105
106 Field classes are \ref api-fund-shared-object "shared objects": get a
107 new reference with bt_field_class_get_ref() and put an existing
108 reference with bt_field_class_put_ref().
109
110 Some library functions \ref api-fund-freezing "freeze" field classes on
111 success. The documentation of those functions indicate this
112 postcondition.
113
114 All the field class types share the same C type, #bt_field_class.
115
116 Get the type enumerator of a field class with bt_field_class_get_type().
117 Get whether or not a field class type conceptually \em is a given type
118 with the inline bt_field_class_type_is() function.
119
120 The following table shows the available type enumerators and creation
121 functions for each type of \em concrete (non-abstract) field class:
122
123 <table>
124 <tr>
125 <th>Name
126 <th>Type enumerator
127 <th>Creation function
128 <tr>
129 <td><em>\ref api-tir-fc-bool "Boolean"</em>
130 <td>#BT_FIELD_CLASS_TYPE_BOOL
131 <td>bt_field_class_bool_create()
132 <tr>
133 <td><em>\ref api-tir-fc-ba "Bit array"</em>
134 <td>#BT_FIELD_CLASS_TYPE_BIT_ARRAY
135 <td>bt_field_class_bit_array_create()
136 <tr>
137 <td><em>Unsigned \ref api-tir-fc-int "integer"</em>
138 <td>#BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER
139 <td>bt_field_class_integer_unsigned_create()
140 <tr>
141 <td><em>Signed \ref api-tir-fc-int "integer"</em>
142 <td>#BT_FIELD_CLASS_TYPE_SIGNED_INTEGER
143 <td>bt_field_class_integer_signed_create()
144 <tr>
145 <td><em>Unsigned \ref api-tir-fc-enum "enumeration"</em>
146 <td>#BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION
147 <td>bt_field_class_enumeration_unsigned_create()
148 <tr>
149 <td><em>Signed \ref api-tir-fc-enum "enumeration"</em>
150 <td>#BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION
151 <td>bt_field_class_enumeration_signed_create()
152 <tr>
153 <td><em>Single-precision \ref api-tir-fc-real "real"</em>
154 <td>#BT_FIELD_CLASS_TYPE_SINGLE_PRECISION_REAL
155 <td>bt_field_class_real_single_precision_create()
156 <tr>
157 <td><em>Double-precision \ref api-tir-fc-real "real"</em>
158 <td>#BT_FIELD_CLASS_TYPE_DOUBLE_PRECISION_REAL
159 <td>bt_field_class_real_double_precision_create()
160 <tr>
161 <td><em>\ref api-tir-fc-string "String"</em>
162 <td>#BT_FIELD_CLASS_TYPE_STRING
163 <td>bt_field_class_string_create()
164 <tr>
165 <td><em>Static \ref api-tir-fc-array "array"</em>
166 <td>#BT_FIELD_CLASS_TYPE_STATIC_ARRAY
167 <td>bt_field_class_array_static_create()
168 <tr>
169 <td><em>Dynamic \ref api-tir-fc-array "array" (no length field)</em>
170 <td>#BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD
171 <td>bt_field_class_array_dynamic_create()
172 <tr>
173 <td><em>Dynamic \ref api-tir-fc-array "array" (with length field)</em>
174 <td>#BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD
175 <td>bt_field_class_array_dynamic_create()
176 <tr>
177 <td><em>\ref api-tir-fc-struct "Structure"</em>
178 <td>#BT_FIELD_CLASS_TYPE_STRUCTURE
179 <td>bt_field_class_structure_create()
180 <tr>
181 <td><em>\ref api-tir-fc-opt "Option" (no selector field)</em>
182 <td>#BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR_FIELD
183 <td>bt_field_class_option_without_selector_create()
184 <tr>
185 <td><em>\ref api-tir-fc-opt "Option" (boolean selector field)</em>
186 <td>#BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD
187 <td>bt_field_class_option_with_selector_field_bool_create()
188 <tr>
189 <td><em>\ref api-tir-fc-opt "Option" (unsigned integer selector field)</em>
190 <td>#BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD
191 <td>bt_field_class_option_with_selector_field_integer_unsigned_create()
192 <tr>
193 <td><em>\ref api-tir-fc-opt "Option" (signed integer selector field)</em>
194 <td>#BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD
195 <td>bt_field_class_option_with_selector_field_integer_signed_create()
196 <tr>
197 <td><em>\ref api-tir-fc-var "Variant" (no selector field)</em>
198 <td>#BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR_FIELD
199 <td>bt_field_class_variant_create()
200 <tr>
201 <td><em>\ref api-tir-fc-var "Variant" (unsigned integer selector field)</em>
202 <td>#BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD
203 <td>bt_field_class_variant_create()
204 <tr>
205 <td><em>\ref api-tir-fc-var "Variant" (signed integer selector field)</em>
206 <td>#BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD
207 <td>bt_field_class_variant_create()
208 </table>
209
210 You need a \bt_trace_cls to create a field class: create one from a
211 \bt_self_comp with bt_trace_class_create().
212
213 Outside the field class API, you can use field classes at four
214 locations, called <em>scopes</em>, within the trace IR API:
215
216 - To set the packet context field class of a \bt_stream_cls with
217 bt_stream_class_set_packet_context_field_class().
218
219 - To set the event common context field class of a stream class with
220 bt_stream_class_set_event_common_context_field_class().
221
222 - To set the specific context field class of an \bt_ev_cls with
223 bt_event_class_set_specific_context_field_class().
224
225 - To set the payload field class of an event class with
226 bt_event_class_set_payload_field_class().
227
228 When you call one of the four functions above:
229
230 - The passed field class must be a \bt_struct_fc.
231
232 - You must \em not have already called any of the four functions above
233 with the passed field class or with any of its contained field
234 classes.
235
236 - If any of the field classes recursively contained in the passed
237 field class has a \ref api-tir-fc-link "link to another field class",
238 it must honor the field class link rules.
239
240 Once you have called one of the four functions above, the passed field
241 class becomes \ref api-fund-freezing "frozen".
242
243 <h1>Common field class property</h1>
244
245 A field class has the following common property:
246
247 <dl>
248 <dt>
249 \anchor api-tir-fc-prop-user-attrs
250 \bt_dt_opt User attributes
251 </dt>
252 <dd>
253 User attributes of the field class.
254
255 User attributes are custom attributes attached to a field class.
256
257 Use bt_field_class_set_user_attributes(),
258 bt_field_class_borrow_user_attributes(), and
259 bt_field_class_borrow_user_attributes_const().
260 </dd>
261 </dl>
262
263 <h1>\anchor api-tir-fc-bool Boolean field class</h1>
264
265 @image html fc-bool.png
266
267 A <strong><em>boolean field class</em></strong> is the class
268 of \bt_p_bool_field.
269
270 A boolean field contains a boolean value (#BT_TRUE or #BT_FALSE).
271
272 Create a boolean field class with bt_field_class_bool_create().
273
274 A boolean field class has no specific properties.
275
276 <h1>\anchor api-tir-fc-ba Bit array field class</h1>
277
278 @image html fc-ba.png
279
280 A <strong><em>bit array field class</em></strong> is the class
281 of \bt_p_ba_field.
282
283 A bit array field contains a fixed-length array of bits.
284
285 Create a bit array field class with bt_field_class_bit_array_create().
286
287 A bit array field class has the following property:
288
289 <dl>
290 <dt>
291 \anchor api-tir-fc-ba-prop-len
292 Length
293 </dt>
294 <dd>
295 Number of bits contained in the instances (bit array fields) of
296 the bit array field class.
297
298 As of \bt_name_version_min_maj, the maximum length of a bit array
299 field is 64.
300
301 You cannot change the length once the bit array field class is
302 created.
303
304 Get a bit array field class's length with
305 bt_field_class_bit_array_get_length().
306 </dd>
307 </dl>
308
309 <h1>\anchor api-tir-fc-int Integer field classes</h1>
310
311 @image html fc-int.png
312
313 <strong><em>Integer field classes</em></strong> are classes
314 of \bt_p_int_field.
315
316 Integer fields contain integral values.
317
318 An integer field class is an \em abstract field class: you cannot create
319 one. The concrete integer field classes are:
320
321 <dl>
322 <dt>Unsigned integer field class</dt>
323 <dd>
324 Its instances (unsigned integer fields) contain an unsigned integral
325 value (\c uint64_t).
326
327 Create with bt_field_class_integer_unsigned_create().
328 </dd>
329
330 <dt>Signed integer field class</dt>
331 <dd>
332 Its instances (signed integer fields) contain a signed integral
333 value (\c int64_t).
334
335 Create with bt_field_class_integer_signed_create().
336 </dd>
337 </dl>
338
339 Integer field classes have the following common properties:
340
341 <dl>
342 <dt>
343 \anchor api-tir-fc-int-prop-size
344 Field value range
345 </dt>
346 <dd>
347 Expected range of values that the instances (integer fields)
348 of the integer field class can contain.
349
350 For example, if the field value range of an unsigned integer
351 field class is [0,&nbsp;16383], then its unsigned integer fields
352 can only contain the values from 0 to 16383.
353
354 \bt_cp_sink_comp can benefit from this property to make some space
355 optimizations when writing trace data.
356
357 Use bt_field_class_integer_set_field_value_range() and
358 bt_field_class_integer_get_field_value_range().
359 </dd>
360
361 <dt>
362 \anchor api-tir-fc-int-prop-base
363 Preferred display base
364 </dt>
365 <dd>
366 Preferred base (2, 8, 10, or 16) to use when displaying the
367 instances (integer fields) of the integer field class.
368
369 Use bt_field_class_integer_set_preferred_display_base() and
370 bt_field_class_integer_get_preferred_display_base().
371 </dd>
372 </dl>
373
374 <h2>\anchor api-tir-fc-enum Enumeration field classes</h2>
375
376 @image html fc-enum.png
377
378 <strong><em>Enumeration field classes</em></strong> are classes
379 of \bt_p_enum_field.
380
381 Enumeration field classes \em are \bt_p_int_fc: they have the integer
382 field classes properties.
383
384 Enumeration fields \em are integer fields: they contain integral values.
385
386 Enumeration field classes associate labels (strings) to specific
387 ranges of integral values. This association is called an enumeration
388 field class <em>mapping</em>.
389
390 For example, if an enumeration field class maps the label \c SUGAR to
391 the integer ranges [1,&nbsp;19] and [25,&nbsp;31], then an instance
392 (enumeration field) of this field class with the value 15 or 28 has the
393 label <code>SUGAR</code>.
394
395 An enumeration field class is an \em abstract field class: you cannot
396 create one. The concrete enumeration field classes are:
397
398 <dl>
399 <dt>Unsigned enumeration field class</dt>
400 <dd>
401 Its instances (unsigned enumeration fields) contain an unsigned
402 value (\c uint64_t).
403
404 Create with bt_field_class_enumeration_unsigned_create().
405 </dd>
406
407 <dt>Signed enumeration field class</dt>
408 <dd>
409 Its instances (signed enumeration fields) contain a signed value
410 (\c int64_t).
411
412 Create with bt_field_class_enumeration_signed_create().
413 </dd>
414 </dl>
415
416 Enumeration field classes have the following common property:
417
418 <dl>
419 <dt>
420 \anchor api-tir-fc-enum-prop-mappings
421 Mappings
422 </dt>
423 <dd>
424 Set of mappings of the enumeration field class.
425
426 An enumeration field class mapping is a label (string) and an
427 \bt_int_rs.
428
429 The integer ranges of a given mapping or of multiple mappings of
430 the same enumeration field class can overlap. For example,
431 an enumeration field class can have those two mappings:
432
433 - <code>CALORIES</code>: [1,&nbsp;11], [15,&nbsp;37]
434 - <code>SODIUM</code>: [7,&nbsp;13]
435
436 In that case, the values 2 and 30 correpond to the label
437 <code>CALORIES</code>, the value 12 to the label
438 <code>SODIUM</code>, and the value 10 to the labels
439 \c CALORIES \em and <code>SODIUM</code>.
440
441 Two mappings of the same enumeration field class cannot have the
442 same label.
443
444 Add a mapping to an enumeration field class with
445 bt_field_class_enumeration_unsigned_add_mapping() or
446 bt_field_class_enumeration_signed_add_mapping().
447
448 Get the number of mappings in an enumeration field class with
449 bt_field_class_enumeration_get_mapping_count().
450
451 Borrow a mapping from an enumeration field class with
452 bt_field_class_enumeration_unsigned_borrow_mapping_by_index_const(),
453 bt_field_class_enumeration_signed_borrow_mapping_by_index_const(),
454 bt_field_class_enumeration_unsigned_borrow_mapping_by_label_const(),
455 and
456 bt_field_class_enumeration_signed_borrow_mapping_by_label_const().
457
458 An enumeration field class mapping is a
459 \ref api-fund-unique-object "unique object": it
460 belongs to the enumeration field class which contains it.
461
462 There are two enumeration field class mapping types, depending on
463 the field class's type:
464 #bt_field_class_enumeration_unsigned_mapping and
465 #bt_field_class_enumeration_signed_mapping.
466
467 There is also the #bt_field_class_enumeration_mapping type for
468 common properties and operations (for example,
469 bt_field_class_enumeration_mapping_get_label()).
470 \ref api-fund-c-typing "Upcast" a specific enumeration field class
471 mapping to the #bt_field_class_enumeration_mapping type with
472 bt_field_class_enumeration_unsigned_mapping_as_mapping_const() or
473 bt_field_class_enumeration_signed_mapping_as_mapping_const().
474
475 Get all the enumeration field class labels mapped to a given integer
476 value with
477 bt_field_class_enumeration_unsigned_get_mapping_labels_for_value()
478 and
479 bt_field_class_enumeration_signed_get_mapping_labels_for_value().
480 </dd>
481 </dl>
482
483 <h1>\anchor api-tir-fc-real Real field classes</h1>
484
485 @image html fc-real.png
486
487 <strong><em>Real field classes</em></strong> are classes
488 of \bt_p_real_field.
489
490 Real fields contain
491 <a href="https://en.wikipedia.org/wiki/Real_number">real</a>
492 values (\c float or \c double types).
493
494 A real field class is an \em abstract field class: you cannot create
495 one. The concrete real field classes are:
496
497 <dl>
498 <dt>Single-precision real field class</dt>
499 <dd>
500 Its instances (single-precision real fields) contain a \c float
501 value.
502
503 Create with bt_field_class_real_single_precision_create().
504 </dd>
505
506 <dt>Double-precision real field class</dt>
507 <dd>
508 Its instances (double-precision real fields) contain a \c double
509 value.
510
511 Create with bt_field_class_real_double_precision_create().
512 </dd>
513 </dl>
514
515 Real field classes have no specific properties.
516
517 <h1>\anchor api-tir-fc-string String field class</h1>
518
519 @image html fc-string.png
520
521 A <strong><em>string field class</em></strong> is the class
522 of \bt_p_string_field.
523
524 A string field contains an UTF-8 string value.
525
526 Create a string field class with bt_field_class_string_create().
527
528 A string field class has no specific properties.
529
530 <h1>\anchor api-tir-fc-array Array field classes</h1>
531
532 @image html fc-array.png
533
534 <strong><em>Array field classes</em></strong> are classes
535 of \bt_p_array_field.
536
537 Array fields contain zero or more fields which have the same class.
538
539 An array field class is an \em abstract field class: you cannot create
540 one. The concrete array field classes are:
541
542 <dl>
543 <dt>Static array field class</dt>
544 <dd>
545 Its instances (static array fields) contain a fixed number of
546 fields.
547
548 Create with bt_field_class_array_static_create().
549
550 A static array field class has the following specific property:
551
552 <dl>
553 <dt>
554 \anchor api-tir-fc-sarray-prop-len
555 Length
556 </dt>
557 <dd>
558 Number of fields contained in the instances (static array
559 fields) of the static array field class.
560
561 You cannot change the length once the static array field class
562 is created.
563
564 Get a static array field class's length with
565 bt_field_class_array_static_get_length().
566 </dd>
567 </dl>
568 </dd>
569
570 <dt>Dynamic array field class</dt>
571 <dd>
572 Its instances (dynamic array fields) contain a variable number array
573 of fields.
574
575 There are two types of dynamic array field classes: without or
576 with a length field. See
577 \ref api-tir-fc-link "Field classes with links to other field classes"
578 to learn more.
579
580 @image html darray-link.png "Dynamic array field class with a length field."
581
582 Create with bt_field_class_array_dynamic_create().
583
584 A dynamic array field class with a length field has the
585 specific property:
586
587 <dl>
588 <dt>
589 \anchor api-tir-fc-darray-prop-len-fp
590 Length field path
591 </dt>
592 <dd>
593 Field path of the linked length field class.
594
595 Get a dynamic array field class's length field path with
596 bt_field_class_array_dynamic_with_length_field_borrow_length_field_path_const().
597 </dd>
598 </dl>
599 </dd>
600 </dl>
601
602 Array field classes have the following common property:
603
604 <dl>
605 <dt>
606 \anchor api-tir-fc-array-prop-elem-fc
607 Element field class
608 </dt>
609 <dd>
610 Class of the fields contained in the instances (array fields) of the
611 array field class.
612
613 You cannot change the element field class once the array field class
614 is created.
615
616 Borrow an array field class's element field class with
617 Use bt_field_class_array_borrow_element_field_class() and
618 bt_field_class_array_borrow_element_field_class_const().
619 </dd>
620 </dl>
621
622 <h1>\anchor api-tir-fc-struct Structure field class</h1>
623
624 @image html fc-struct.png
625
626 A <strong><em>structure field class</em></strong> is the class
627 of a \bt_struct_field.
628
629 A structure field contains an ordered list of zero or more members. Each
630 structure field member is the instance of a structure field class
631 member. A structure field class member has a name, a field class,
632 and user attributes.
633
634 Create a structure field class with bt_field_class_structure_create().
635
636 A structure field class has the following specific property:
637
638 <dl>
639 <dt>
640 \anchor api-tir-fc-struct-prop-members
641 Members
642 </dt>
643 <dd>
644 Ordered list of members (zero or more) of the structure field class.
645
646 Each member has:
647
648 - A name, unique amongst all the member names of the same
649 structure field class.
650 - A field class.
651 - User attributes.
652
653 The instances (structure fields) of a structure field class have
654 members which are instances of the corresponding structure field
655 class members.
656
657 Append a member to a structure field class with
658 bt_field_class_structure_append_member().
659
660 Borrow a member from a structure field class with
661 bt_field_class_structure_borrow_member_by_index(),
662 bt_field_class_structure_borrow_member_by_name(),
663 bt_field_class_structure_borrow_member_by_index_const(), and
664 bt_field_class_structure_borrow_member_by_name_const().
665
666 A structure field class member is a
667 \ref api-fund-unique-object "unique object": it
668 belongs to the structure field class which contains it.
669
670 The type of a structure field class member is
671 #bt_field_class_structure_member.
672
673 Get a structure field class member's name with
674 bt_field_class_structure_member_get_name().
675
676 Borrow a structure field class member's field class with
677 bt_field_class_structure_member_borrow_field_class() and
678 bt_field_class_structure_member_borrow_field_class_const().
679
680 Set a structure field class member's user attributes with
681 bt_field_class_structure_member_set_user_attributes().
682
683 Borrow a structure field class member's user attributes with
684 bt_field_class_structure_member_borrow_user_attributes() and
685 bt_field_class_structure_member_borrow_user_attributes_const().
686 </dd>
687 </dl>
688
689 <h1>\anchor api-tir-fc-opt Option field classes</h1>
690
691 @image html fc-opt.png
692
693 <strong><em>Option field classes</em></strong> are classes
694 of \bt_p_opt_field.
695
696 An option field either does or doesn't contain a field, called its
697 optional field.
698
699 An option field class is an \em abstract field class: you cannot create
700 one. An option field class either has a selector field (it's linked to a
701 selector field class; see
702 \ref api-tir-fc-link "Field classes with links to other field classes")
703 or none. Therefore, the concrete option field classes are:
704
705 <dl>
706 <dt>Option field class without a selector field</dt>
707 <dd>
708 Create with bt_field_class_option_without_selector_create().
709
710 An option field class without a selector field has no specific
711 properties.
712 </dd>
713
714 <dt>Option field class with a boolean selector field</dt>
715 <dd>
716 The linked selector field of an option field class's instance
717 (an option field) is a \bt_bool_field.
718
719 Consequently, the option field class's selector field class is
720 a \bt_bool_fc.
721
722 @image html opt-link.png "Option field class with a boolean selector field."
723
724 Create with bt_field_class_option_with_selector_field_bool_create().
725
726 An option field class with a boolean selector field has the
727 following specific property:
728
729 <dl>
730 <dt>
731 \anchor api-tir-fc-opt-prop-sel-rev
732 Selector is reversed?
733 </dt>
734 <dd>
735 Whether or not the linked boolean selector field makes the
736 option field class's instance (an option field) contain a field
737 when it's #BT_TRUE or when it's #BT_FALSE.
738
739 If this property is #BT_TRUE, then if the linked selector field
740 has the value #BT_FALSE, the option field contains a field.
741
742 Use
743 bt_field_class_option_with_selector_field_bool_set_selector_is_reversed()
744 and
745 bt_field_class_option_with_selector_field_bool_selector_is_reversed().
746 </dd>
747 </dl>
748 </dd>
749
750 <dt>Option field class with an unsigned selector field</dt>
751 <dd>
752 The linked selector field of an option field class's instance
753 (an option field) is an \bt_uint_field.
754
755 Consequently, the option field class's selector field class is
756 an \bt_uint_fc.
757
758 Create with
759 bt_field_class_option_with_selector_field_integer_unsigned_create().
760
761 Pass an \bt_uint_rs on creation to set which values of the selector
762 field can make the option field contain a field.
763
764 An option field class with an unsigned integer selector field has
765 the following specific property:
766
767 <dl>
768 <dt>
769 \anchor api-tir-fc-opt-prop-uint-rs
770 Selector's unsigned integer ranges
771 </dt>
772 <dd>
773 If the linked unsigned integer selector field of an option
774 field class's instance (an option field) has a value which
775 intersects with the selector's unsigned integer ranges, then
776 the option field contains a field.
777
778 You cannot change the selector's unsigned integer ranges once
779 the option field class is created.
780
781 Borrow the selector's unsigned integer ranges from an
782 option field class with an unsigned integer selector field with
783 bt_field_class_option_with_selector_field_integer_unsigned_borrow_selector_ranges_const().
784 </dd>
785 </dl>
786 </dd>
787
788 <dt>Option field class with a signed selector field</dt>
789 <dd>
790 The linked selector field of an option field class's instance
791 (an option field) is a \bt_sint_field.
792
793 Consequently, the option field class's selector field class is
794 a \bt_sint_fc.
795
796 Create with
797 bt_field_class_option_with_selector_field_integer_signed_create().
798
799 Pass a \bt_sint_rs on creation to set which values of the selector
800 field can make the option field contain a field.
801
802 An option field class with a signed integer selector field has
803 the following specific property:
804
805 <dl>
806 <dt>
807 \anchor api-tir-fc-opt-prop-sint-rs
808 Selector's signed integer ranges
809 </dt>
810 <dd>
811 If the linked signed integer selector field of an option
812 field class's instance (an option field) has a value which
813 intersects with the selector's signed integer ranges, then
814 the option field contains a field.
815
816 You cannot change the selector's signed integer ranges once
817 the option field class is created.
818
819 Borrow the selector's signed integer ranges from an
820 option field class with a signed integer selector field with
821 bt_field_class_option_with_selector_field_integer_signed_borrow_selector_ranges_const().
822 </dd>
823 </dl>
824 </dd>
825 </dl>
826
827 Option field classes with a selector have the following common
828 property:
829
830 <dl>
831 <dt>
832 \anchor api-tir-fc-opt-prop-sel-fp
833 Selector field path
834 </dt>
835 <dd>
836 Field path of the linked selector field class.
837
838 Borrow such an option field class's selector field path with
839 bt_field_class_option_with_selector_field_borrow_selector_field_path_const().
840 </dd>
841 </dl>
842
843 Option field classes have the following common property:
844
845 <dl>
846 <dt>
847 \anchor api-tir-fc-opt-prop-fc
848 Optional field class
849 </dt>
850 <dd>
851 Class of the optional field of an instance (option field) of the
852 option field class.
853
854 You cannot change the optional field class once the option field
855 class is created.
856
857 Borrow an option field class's optional field class with
858 Use bt_field_class_option_borrow_field_class() and
859 bt_field_class_option_borrow_field_class_const().
860 </dd>
861 </dl>
862
863 <h1>\anchor api-tir-fc-var Variant field classes</h1>
864
865 @image html fc-var.png
866
867 <strong><em>Variant field classes</em></strong> are classes
868 of \bt_p_var_field.
869
870 A variant field contains a field amongst one or more possible fields.
871
872 Variant field classes contain one or more options. Each variant field
873 class option has a name, a field class, user attributes, and integer
874 ranges, depending on the exact type.
875
876 A variant field class is an \em abstract field class: you cannot create
877 one. A variant field class either has a selector field (it's linked to a
878 selector field class; see
879 \ref api-tir-fc-link "Field classes with links to other field classes")
880 or none. Therefore, the concrete variant field classes are:
881
882 <dl>
883 <dt>Variant field class without a selector field</dt>
884 <dd>
885 Create with bt_field_class_variant_create(), passing \c NULL as
886 the selector field class.
887
888 Append an option to such a variant field class with
889 bt_field_class_variant_without_selector_append_option().
890
891 A variant field class without a selector field has no specific
892 properties.
893 </dd>
894
895 <dt>Variant field class with an unsigned selector field</dt>
896 <dd>
897 The linked selector field of a variant field class's instance
898 (a variant field) is an \bt_uint_field.
899
900 Consequently, the variant field class's selector field class is
901 an \bt_uint_fc.
902
903 @image html var-link.png "Variant field class with an unsigned integer selector field."
904
905 Create with bt_field_class_variant_create(), passing an
906 unsigned integer field class as the selector field class.
907
908 Append an option to such a variant field class with
909 bt_field_class_variant_with_selector_field_integer_unsigned_append_option().
910
911 Pass an \bt_uint_rs when you append an option to set which values of
912 the selector field can make the variant field have a given
913 current option.
914
915 Borrow such a variant field class's option with
916 bt_field_class_variant_with_selector_field_integer_unsigned_borrow_option_by_index_const()
917 and
918 bt_field_class_variant_with_selector_field_integer_unsigned_borrow_option_by_name_const().
919 </dd>
920
921 <dt>Variant field class with a signed selector field</dt>
922 <dd>
923 The linked selector field of a variant field class's instance
924 (a variant field) is a \bt_sint_field.
925
926 Consequently, the variant field class's selector field class is
927 a \bt_sint_fc.
928
929 Create with bt_field_class_variant_create(), passing a
930 signed integer field class as the selector field class.
931
932 Append an option to such a variant field class with
933 bt_field_class_variant_with_selector_field_integer_signed_append_option().
934
935 Pass a \bt_sint_rs when you append an option to set which values of
936 the selector field can make the variant field have a given
937 current option.
938
939 Borrow such a variant field class's option with
940 bt_field_class_variant_with_selector_field_integer_signed_borrow_option_by_index_const()
941 and
942 bt_field_class_variant_with_selector_field_integer_signed_borrow_option_by_name_const().
943 </dd>
944 </dl>
945
946 Variant field classes with a selector have the following common
947 property:
948
949 <dl>
950 <dt>
951 \anchor api-tir-fc-var-prop-sel-fp
952 Selector field path
953 </dt>
954 <dd>
955 Field path of the linked selector field class.
956
957 Borrow such a variant field class's selector field path with
958 bt_field_class_variant_with_selector_field_borrow_selector_field_path_const().
959 </dd>
960 </dl>
961
962 Variant field classes have the following common property:
963
964 <dl>
965 <dt>
966 \anchor api-tir-fc-var-prop-opts
967 Options
968 </dt>
969 <dd>
970 Options of the variant field class.
971
972 Each option has:
973
974 - A name, unique amongst all the option names of the same
975 variant field class.
976 - A field class.
977 - User attributes.
978
979 If the variant field class is linked to a selector field class, then
980 each option also has an \bt_int_rs. In that case, the ranges of a
981 given option cannot overlap any range of any other option.
982
983 A variant field class must contain at least one option.
984
985 Depending on whether or not the variant field class has a selector
986 field class, append an option to a variant field class
987 with bt_field_class_variant_without_selector_append_option(),
988 bt_field_class_variant_with_selector_field_integer_unsigned_append_option(),
989 or
990 bt_field_class_variant_with_selector_field_integer_signed_append_option().
991
992 Get the number of options contained in a variant field class
993 with bt_field_class_variant_get_option_count().
994
995 A variant field class option is a
996 \ref api-fund-unique-object "unique object": it
997 belongs to the variant field class which contains it.
998
999 Borrow any variant field class's option with
1000 bt_field_class_variant_borrow_option_by_index(),
1001 bt_field_class_variant_borrow_option_by_name(),
1002 bt_field_class_variant_borrow_option_by_index_const(), and
1003 bt_field_class_variant_borrow_option_by_name_const().
1004
1005 Those functions return the common #bt_field_class_variant_option
1006 type. Get the name of a variant field class option with
1007 bt_field_class_variant_option_get_name(). Borrow a variant field
1008 class option's field class with
1009 bt_field_class_variant_option_borrow_field_class() and
1010 bt_field_class_variant_option_borrow_field_class_const().
1011
1012 Borrow the option of a variant field classes with a selector field
1013 class with
1014 bt_field_class_variant_with_selector_field_integer_unsigned_borrow_option_by_index_const(),
1015 bt_field_class_variant_with_selector_field_integer_unsigned_borrow_option_by_name_const(),
1016 bt_field_class_variant_with_selector_field_integer_signed_borrow_option_by_index_const(), or
1017 bt_field_class_variant_with_selector_field_integer_signed_borrow_option_by_name_const(),
1018 depending on the selector field class's type.
1019
1020 Those functions return the
1021 #bt_field_class_variant_with_selector_field_integer_unsigned_option or
1022 #bt_field_class_variant_with_selector_field_integer_signed_option type.
1023 \ref api-fund-c-typing "Upcast" those types to the
1024 #bt_field_class_variant_option type with
1025 bt_field_class_variant_with_selector_field_integer_unsigned_option_as_option_const()
1026 or
1027 bt_field_class_variant_with_selector_field_integer_signed_option_as_option_const().
1028
1029 Borrow the option's ranges from a variant field class with a
1030 selector field class with
1031 bt_field_class_variant_with_selector_field_integer_unsigned_option_borrow_ranges_const()
1032 or
1033 bt_field_class_variant_with_selector_field_integer_signed_option_borrow_ranges_const().
1034
1035 Set a variant field class option's user attributes with
1036 bt_field_class_variant_option_set_user_attributes().
1037
1038 Borrow a variant field class option's user attributes with
1039 bt_field_class_variant_option_borrow_user_attributes() and
1040 bt_field_class_variant_option_borrow_user_attributes_const().
1041 </dd>
1042 </dl>
1043
1044 <h1>\anchor api-tir-fc-link Field classes with links to other field classes</h1>
1045
1046 \bt_cp_darray_fc, \bt_p_opt_fc, and \bt_p_var_fc \em can have links to
1047 other, preceding field classes.
1048
1049 When a field class&nbsp;A has a link to another field class&nbsp;B, then
1050 an instance (\bt_field) of A has a link to an instance of B.
1051
1052 This feature exists so that the linked field can contain the value of a
1053 dynamic property of the field. Those properties are:
1054
1055 <dl>
1056 <dt>\bt_c_darray_field</dt>
1057 <dd>
1058 The linked field, a \bt_uint_field, contains the \b length of the
1059 dynamic array field.
1060 </dd>
1061
1062 <dt>\bt_c_opt_field</dt>
1063 <dd>
1064 The linked field, either a \bt_bool_field or an \bt_int_field,
1065 indicates whether or not the option field has a field.
1066 </dd>
1067
1068 <dt>\bt_c_var_field</dt>
1069 <dd>
1070 The linked field, an \bt_int_field, indicates the variant field's
1071 current selected field.
1072 </dd>
1073 </dl>
1074
1075 Having a linked field class is <em>optional</em>: you always set the
1076 field properties with a dedicated function anyway. For example, even if
1077 a dynamic array field is linked to a preceding length field, you must
1078 still set its length with bt_field_array_dynamic_set_length(). In that
1079 case, the value of the length field must match what you pass to
1080 bt_field_array_dynamic_set_length().
1081
1082 The purpose of this feature is to eventually save space when a
1083 \bt_sink_comp writes trace files: if the trace format can convey that
1084 a preceding, existing field represents the length of a dynamic array
1085 field, then the sink component doesn't need to write the dynamic array
1086 field's length twice. This is the case of the
1087 <a href="https://diamon.org/ctf/">Common Trace Format</a>, for
1088 example.
1089
1090 @image html darray-link.png "A dynamic array field class linked to an unsigned integer field class."
1091
1092 To link a field class&nbsp;A to a preceding field class&nbsp;B, pass
1093 field class&nbsp;B when you create field class&nbsp;A. For example, pass
1094 the \bt_uint_fc to bt_field_class_array_dynamic_create() to create a
1095 \bt_darray_fc with a length field.
1096
1097 When you call bt_stream_class_set_packet_context_field_class(),
1098 bt_stream_class_set_event_common_context_field_class(),
1099 bt_event_class_set_specific_context_field_class(), or
1100 bt_event_class_set_payload_field_class() with a field class containing
1101 a field class&nbsp;A with a linked field class&nbsp;B, the path to
1102 B becomes available in A. The functions to borrow this field path are:
1103
1104 - bt_field_class_array_dynamic_with_length_field_borrow_length_field_path_const()
1105 - bt_field_class_option_with_selector_field_borrow_selector_field_path_const()
1106 - bt_field_class_variant_with_selector_field_borrow_selector_field_path_const()
1107
1108 A field path indicates how to reach a linked field from a given
1109 root <em>scope</em>. The available scopes are:
1110
1111 <dl>
1112 <dt>#BT_FIELD_PATH_SCOPE_PACKET_CONTEXT</dt>
1113 <dd>
1114 Packet context field.
1115
1116 See bt_packet_borrow_context_field_const().
1117 </dd>
1118
1119 <dt>#BT_FIELD_PATH_SCOPE_EVENT_COMMON_CONTEXT</dt>
1120 <dd>
1121 Event common context field.
1122
1123 See bt_event_borrow_common_context_field_const().
1124 </dd>
1125
1126 <dt>#BT_FIELD_PATH_SCOPE_EVENT_SPECIFIC_CONTEXT</dt>
1127 <dd>
1128 Event specific context field.
1129
1130 See bt_event_borrow_specific_context_field_const().
1131 </dd>
1132
1133 <dt>#BT_FIELD_PATH_SCOPE_EVENT_PAYLOAD</dt>
1134 <dd>
1135 Event payload field.
1136
1137 See bt_event_borrow_payload_field_const().
1138 </dd>
1139 </dl>
1140
1141 The rules regarding field class&nbsp;A vs. field class&nbsp;B (linked
1142 field class) are:
1143
1144 - If A is within a packet context field class, B must also be in the
1145 same packet context field class.
1146
1147 See bt_stream_class_set_packet_context_field_class().
1148
1149 - If A is within a event common context field class, B must be in one
1150 of:
1151
1152 - The same event common context field class.
1153 - The packet context field class of the same \bt_stream_cls.
1154
1155 See bt_stream_class_set_event_common_context_field_class().
1156
1157 - If A is within an event specific context field class, B must be in
1158 one of:
1159
1160 - The same event specific context field class.
1161 - The event common context field class of the same stream class.
1162 - The packet context field class of the same stream class.
1163
1164 See bt_event_class_set_specific_context_field_class().
1165
1166 - If A is within an event payload field class, B must be in one of:
1167
1168 - The same event payload field class.
1169 - The event specific context field class of the same \bt_ev_cls.
1170 - The event common context field class of the same stream class.
1171 - The packet context field class of the same stream class.
1172
1173 See bt_event_class_set_payload_field_class().
1174
1175 - If both A and B are in the same scope, then:
1176
1177 - The lowest common ancestor field class of A and B must be a
1178 \bt_struct_fc.
1179
1180 - B must precede A.
1181
1182 Considering that the members of a structure field class are ordered,
1183 then B must be part of a member that's before the member which
1184 contains A in their lowest common ancestor structure field class.
1185
1186 - The path from the lowest common ancestor structure field class of A
1187 and B to A and to B must only contain structure field classes.
1188
1189 - If A is in a different scope than B, the path from the root scope of B
1190 to B must only contain structure field classes.
1191 */
1192
1193 /*! @{ */
1194
1195 /*!
1196 @name Type
1197 @{
1198
1199 @typedef struct bt_field_class bt_field_class;
1200
1201 @brief
1202 Field class.
1203
1204 @}
1205 */
1206
1207 /*!
1208 @name Type query
1209 @{
1210 */
1211
1212 /*!
1213 @brief
1214 Field class type enumerators.
1215 */
1216 typedef enum bt_field_class_type {
1217 /*!
1218 @brief
1219 \bt_c_bool_fc.
1220 */
1221 BT_FIELD_CLASS_TYPE_BOOL = 1ULL << 0,
1222
1223 /*!
1224 @brief
1225 \bt_c_ba_fc.
1226 */
1227 BT_FIELD_CLASS_TYPE_BIT_ARRAY = 1ULL << 1,
1228
1229 /*!
1230 @brief
1231 \bt_c_int_fc.
1232
1233 No field class has this type: use it with
1234 bt_field_class_type_is().
1235 */
1236 BT_FIELD_CLASS_TYPE_INTEGER = 1ULL << 2,
1237
1238 /*!
1239 @brief
1240 \bt_c_uint_fc.
1241
1242 This type conceptually inherits #BT_FIELD_CLASS_TYPE_INTEGER.
1243 */
1244 BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER = (1ULL << 3) | BT_FIELD_CLASS_TYPE_INTEGER,
1245
1246 /*!
1247 @brief
1248 \bt_c_sint_fc.
1249
1250 This type conceptually inherits #BT_FIELD_CLASS_TYPE_INTEGER.
1251 */
1252 BT_FIELD_CLASS_TYPE_SIGNED_INTEGER = (1ULL << 4) | BT_FIELD_CLASS_TYPE_INTEGER,
1253
1254 /*!
1255 @brief
1256 \bt_c_enum_fc.
1257
1258 This type conceptually inherits #BT_FIELD_CLASS_TYPE_INTEGER.
1259
1260 No field class has this type: use it with
1261 bt_field_class_type_is().
1262 */
1263 BT_FIELD_CLASS_TYPE_ENUMERATION = 1ULL << 5,
1264
1265 /*!
1266 @brief
1267 \bt_c_uenum_fc.
1268
1269 This type conceptually inherits #BT_FIELD_CLASS_TYPE_ENUMERATION
1270 and #BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER.
1271 */
1272 BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION = BT_FIELD_CLASS_TYPE_ENUMERATION | BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER,
1273
1274 /*!
1275 @brief
1276 \bt_c_senum_fc.
1277
1278 This type conceptually inherits #BT_FIELD_CLASS_TYPE_ENUMERATION
1279 and #BT_FIELD_CLASS_TYPE_SIGNED_INTEGER.
1280 */
1281 BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION = BT_FIELD_CLASS_TYPE_ENUMERATION | BT_FIELD_CLASS_TYPE_SIGNED_INTEGER,
1282
1283 /*!
1284 @brief
1285 \bt_c_real_fc.
1286
1287 No field class has this type: use it with
1288 bt_field_class_type_is().
1289 */
1290 BT_FIELD_CLASS_TYPE_REAL = 1ULL << 6,
1291
1292 /*!
1293 @brief
1294 Single-precision \bt_real_fc.
1295
1296 This type conceptually inherits #BT_FIELD_CLASS_TYPE_REAL.
1297 */
1298 BT_FIELD_CLASS_TYPE_SINGLE_PRECISION_REAL = (1ULL << 7) | BT_FIELD_CLASS_TYPE_REAL,
1299
1300 /*!
1301 @brief
1302 Double-precision \bt_real_fc.
1303
1304 This type conceptually inherits #BT_FIELD_CLASS_TYPE_REAL.
1305 */
1306 BT_FIELD_CLASS_TYPE_DOUBLE_PRECISION_REAL = (1ULL << 8) | BT_FIELD_CLASS_TYPE_REAL,
1307
1308 /*!
1309 @brief
1310 \bt_c_string_fc..
1311 */
1312 BT_FIELD_CLASS_TYPE_STRING = 1ULL << 9,
1313
1314 /*!
1315 @brief
1316 \bt_c_struct_fc.
1317 */
1318 BT_FIELD_CLASS_TYPE_STRUCTURE = 1ULL << 10,
1319
1320 /*!
1321 @brief
1322 \bt_c_array_fc.
1323
1324 No field class has this type: use it with
1325 bt_field_class_type_is().
1326 */
1327 BT_FIELD_CLASS_TYPE_ARRAY = 1ULL << 11,
1328
1329 /*!
1330 @brief
1331 \bt_c_sarray_fc.
1332
1333 This type conceptually inherits #BT_FIELD_CLASS_TYPE_ARRAY.
1334 */
1335 BT_FIELD_CLASS_TYPE_STATIC_ARRAY = (1ULL << 12) | BT_FIELD_CLASS_TYPE_ARRAY,
1336
1337 /*!
1338 @brief
1339 \bt_c_darray_fc.
1340
1341 This type conceptually inherits #BT_FIELD_CLASS_TYPE_ARRAY.
1342
1343 No field class has this type: use it with
1344 bt_field_class_type_is().
1345 */
1346 BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY = (1ULL << 13) | BT_FIELD_CLASS_TYPE_ARRAY,
1347
1348 /*!
1349 @brief
1350 \bt_c_darray_fc (without a length field).
1351
1352 This type conceptually inherits
1353 #BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY.
1354 */
1355 BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD = (1ULL << 14) | BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY,
1356
1357 /*!
1358 @brief
1359 \bt_c_darray_fc (with a length field).
1360
1361 This type conceptually inherits
1362 #BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY.
1363 */
1364 BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD = (1ULL << 15) | BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY,
1365
1366 /*!
1367 @brief
1368 \bt_c_opt_fc.
1369
1370 No field class has this type: use it with
1371 bt_field_class_type_is().
1372 */
1373 BT_FIELD_CLASS_TYPE_OPTION = 1ULL << 16,
1374
1375 /*!
1376 @brief
1377 \bt_c_opt_fc (without a selector field).
1378 */
1379 BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR_FIELD = (1ULL << 17) | BT_FIELD_CLASS_TYPE_OPTION,
1380
1381 /*!
1382 @brief
1383 \bt_c_opt_fc (with a selector field).
1384
1385 This type conceptually inherits #BT_FIELD_CLASS_TYPE_OPTION.
1386
1387 No field class has this type: use it with
1388 bt_field_class_type_is().
1389 */
1390 BT_FIELD_CLASS_TYPE_OPTION_WITH_SELECTOR_FIELD = (1ULL << 18) | BT_FIELD_CLASS_TYPE_OPTION,
1391
1392 /*!
1393 @brief
1394 \bt_c_opt_fc (with a boolean selector field).
1395
1396 This type conceptually inherits
1397 #BT_FIELD_CLASS_TYPE_OPTION_WITH_SELECTOR_FIELD.
1398 */
1399 BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD = (1ULL << 19) | BT_FIELD_CLASS_TYPE_OPTION_WITH_SELECTOR_FIELD,
1400
1401 /*!
1402 @brief
1403 \bt_c_opt_fc (with an integer selector field).
1404
1405 This type conceptually inherits
1406 #BT_FIELD_CLASS_TYPE_OPTION_WITH_SELECTOR_FIELD.
1407
1408 No field class has this type: use it with
1409 bt_field_class_type_is().
1410 */
1411 BT_FIELD_CLASS_TYPE_OPTION_WITH_INTEGER_SELECTOR_FIELD = (1ULL << 20) | BT_FIELD_CLASS_TYPE_OPTION_WITH_SELECTOR_FIELD,
1412
1413 /*!
1414 @brief
1415 \bt_c_opt_fc (with an unsigned integer selector field).
1416
1417 This type conceptually inherits
1418 #BT_FIELD_CLASS_TYPE_OPTION_WITH_INTEGER_SELECTOR_FIELD.
1419 */
1420 BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD = (1ULL << 21) | BT_FIELD_CLASS_TYPE_OPTION_WITH_INTEGER_SELECTOR_FIELD,
1421
1422 /*!
1423 @brief
1424 \bt_c_opt_fc (with a signed integer selector field).
1425
1426 This type conceptually inherits
1427 #BT_FIELD_CLASS_TYPE_OPTION_WITH_INTEGER_SELECTOR_FIELD.
1428 */
1429 BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD = (1ULL << 22) | BT_FIELD_CLASS_TYPE_OPTION_WITH_INTEGER_SELECTOR_FIELD,
1430
1431 /*!
1432 @brief
1433 \bt_c_var_fc.
1434
1435 No field class has this type: use it with
1436 bt_field_class_type_is().
1437 */
1438 BT_FIELD_CLASS_TYPE_VARIANT = 1ULL << 23,
1439
1440 /*!
1441 @brief
1442 \bt_c_var_fc (without a selector field).
1443 */
1444 BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR_FIELD = (1ULL << 24) | BT_FIELD_CLASS_TYPE_VARIANT,
1445
1446 /*!
1447 @brief
1448 \bt_c_var_fc (with a selector field).
1449
1450 This type conceptually inherits
1451 #BT_FIELD_CLASS_TYPE_VARIANT.
1452
1453 No field class has this type: use it with
1454 bt_field_class_type_is().
1455 */
1456 BT_FIELD_CLASS_TYPE_VARIANT_WITH_SELECTOR_FIELD = (1ULL << 25) | BT_FIELD_CLASS_TYPE_VARIANT,
1457
1458 /*!
1459 @brief
1460 \bt_c_var_fc (with an integer selector field).
1461
1462 This type conceptually inherits
1463 #BT_FIELD_CLASS_TYPE_VARIANT_WITH_SELECTOR_FIELD.
1464
1465 No field class has this type: use it with
1466 bt_field_class_type_is().
1467 */
1468 BT_FIELD_CLASS_TYPE_VARIANT_WITH_INTEGER_SELECTOR_FIELD = (1ULL << 26) | BT_FIELD_CLASS_TYPE_VARIANT_WITH_SELECTOR_FIELD,
1469
1470 /*!
1471 @brief
1472 \bt_c_opt_fc (with an unsigned integer selector field).
1473
1474 This type conceptually inherits
1475 #BT_FIELD_CLASS_TYPE_VARIANT_WITH_INTEGER_SELECTOR_FIELD.
1476 */
1477 BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD = (1ULL << 27) | BT_FIELD_CLASS_TYPE_VARIANT_WITH_INTEGER_SELECTOR_FIELD,
1478
1479 /*!
1480 @brief
1481 \bt_c_opt_fc (with a signed integer selector field).
1482
1483 This type conceptually inherits
1484 #BT_FIELD_CLASS_TYPE_VARIANT_WITH_INTEGER_SELECTOR_FIELD.
1485 */
1486 BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD = (1ULL << 28) | BT_FIELD_CLASS_TYPE_VARIANT_WITH_INTEGER_SELECTOR_FIELD,
1487
1488 /*
1489 * Make sure the enumeration type is a 64-bit integer in case
1490 * the project needs field class types in the future.
1491 *
1492 * This is not part of the API.
1493 */
1494 __BT_FIELD_CLASS_TYPE_BIG_VALUE = 1ULL << 62,
1495 } bt_field_class_type;
1496
1497 /*!
1498 @brief
1499 Returns the type enumerator of the field class \bt_p{field_class}.
1500
1501 @param[in] field_class
1502 Field class of which to get the type enumerator
1503
1504 @returns
1505 Type enumerator of \bt_p{field_class}.
1506
1507 @bt_pre_not_null{field_class}
1508
1509 @sa bt_field_class_type_is() &mdash;
1510 Returns whether or not the type of a field class conceptually is a
1511 given type.
1512 */
1513 extern bt_field_class_type bt_field_class_get_type(
1514 const bt_field_class *field_class);
1515
1516 /*!
1517 @brief
1518 Returns whether or not the field class type \bt_p{type} conceptually
1519 \em is the field class type \bt_p{other_type}.
1520
1521 For example, an \bt_uint_fc conceptually \em is an integer field class,
1522 so
1523
1524 @code
1525 bt_field_class_type_is(BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER, BT_FIELD_CLASS_TYPE_INTEGER)
1526 @endcode
1527
1528 returns #BT_TRUE.
1529
1530 @param[in] type
1531 Field class type to check against \bt_p{other_type}.
1532 @param[in] other_type
1533 Field class type against which to check \bt_p{type}.
1534
1535 @returns
1536 #BT_TRUE if \bt_p{type} conceptually \em is \bt_p{other_type}.
1537
1538 @sa bt_field_class_get_type() &mdash;
1539 Returns the type enumerator of a field class.
1540 */
1541 static inline
1542 bt_bool bt_field_class_type_is(const bt_field_class_type type,
1543 const bt_field_class_type other_type)
1544 {
1545 return (type & other_type) == other_type;
1546 }
1547
1548 /*! @} */
1549
1550 /*!
1551 @name Common property
1552 @{
1553 */
1554
1555 /*!
1556 @brief
1557 Sets the user attributes of the field class \bt_p{field_class} to
1558 \bt_p{user_attributes}.
1559
1560 See the \ref api-tir-fc-prop-user-attrs "user attributes" property.
1561
1562 @note
1563 When you create a field class with one of the
1564 <code>bt_field_class_*_create()</code> functions, the field class's
1565 initial user attributes is an empty \bt_map_val. Therefore you can
1566 borrow it with bt_field_class_borrow_user_attributes() and fill it
1567 directly instead of setting a new one with this function.
1568
1569 @param[in] field_class
1570 Field class of which to set the user attributes to
1571 \bt_p{user_attributes}.
1572 @param[in] user_attributes
1573 New user attributes of \bt_p{field_class}.
1574
1575 @bt_pre_not_null{field_class}
1576 @bt_pre_hot{field_class}
1577 @bt_pre_not_null{user_attributes}
1578 @bt_pre_is_map_val{user_attributes}
1579
1580 @sa bt_field_class_borrow_user_attributes() &mdash;
1581 Borrows the user attributes of a field class.
1582 */
1583 extern void bt_field_class_set_user_attributes(
1584 bt_field_class *field_class, const bt_value *user_attributes);
1585
1586 /*!
1587 @brief
1588 Borrows the user attributes of the field class \bt_p{field_class}.
1589
1590 See the \ref api-tir-fc-prop-user-attrs "user attributes" property.
1591
1592 @note
1593 When you create a field class with one of the
1594 <code>bt_field_class_*_create()</code> functions, the field class's
1595 initial user attributes is an empty \bt_map_val.
1596
1597 @param[in] field_class
1598 Field class from which to borrow the user attributes.
1599
1600 @returns
1601 User attributes of \bt_p{field_class} (a \bt_map_val).
1602
1603 @bt_pre_not_null{field_class}
1604
1605 @sa bt_field_class_set_user_attributes() &mdash;
1606 Sets the user attributes of a field class.
1607 @sa bt_field_class_borrow_user_attributes_const() &mdash;
1608 \c const version of this function.
1609 */
1610 extern bt_value *bt_field_class_borrow_user_attributes(
1611 bt_field_class *field_class);
1612
1613 /*!
1614 @brief
1615 Borrows the user attributes of the field class \bt_p{field_class}
1616 (\c const version).
1617
1618 See bt_field_class_borrow_user_attributes().
1619 */
1620 extern const bt_value *bt_field_class_borrow_user_attributes_const(
1621 const bt_field_class *field_class);
1622
1623 /*! @} */
1624
1625 /*!
1626 @name Boolean field class
1627 @{
1628 */
1629
1630 /*!
1631 @brief
1632 Creates a \bt_bool_fc from the trace class \bt_p{trace_class}.
1633
1634 On success, the returned boolean field class has the following
1635 property value:
1636
1637 <table>
1638 <tr>
1639 <th>Property
1640 <th>Value
1641 <tr>
1642 <td>\ref api-tir-fc-prop-user-attrs "User attributes"
1643 <td>Empty \bt_map_val
1644 </table>
1645
1646 @param[in] trace_class
1647 Trace class from which to create a boolean field class.
1648
1649 @returns
1650 New boolean field class reference, or \c NULL on memory error.
1651
1652 @bt_pre_not_null{trace_class}
1653 */
1654 extern bt_field_class *bt_field_class_bool_create(
1655 bt_trace_class *trace_class);
1656
1657 /*!
1658 @}
1659 */
1660
1661 /*!
1662 @name Bit array field class
1663 @{
1664 */
1665
1666 /*!
1667 @brief
1668 Creates a \bt_ba_fc with the length \bt_p{length} from the trace
1669 class \bt_p{trace_class}.
1670
1671 On success, the returned bit array field class has the following
1672 property values:
1673
1674 <table>
1675 <tr>
1676 <th>Property
1677 <th>Value
1678 <tr>
1679 <td>\ref api-tir-fc-ba-prop-len "Length"
1680 <td>\bt_p{length}
1681 <tr>
1682 <td>\ref api-tir-fc-prop-user-attrs "User attributes"
1683 <td>Empty \bt_map_val
1684 </table>
1685
1686 @param[in] trace_class
1687 Trace class from which to create a bit array field class.
1688 @param[in] length
1689 Length (number of bits) of the instances of the bit array field
1690 class to create.
1691
1692 @returns
1693 New bit array field class reference, or \c NULL on memory error.
1694
1695 @bt_pre_not_null{trace_class}
1696 @pre
1697 0 < \bt_p{length} ≤ 64.
1698 */
1699 extern bt_field_class *bt_field_class_bit_array_create(
1700 bt_trace_class *trace_class, uint64_t length);
1701
1702 /*!
1703 @brief
1704 Returns the length of the \bt_ba_fc \bt_p{field_class}.
1705
1706 See the \ref api-tir-fc-ba-prop-len "length" property.
1707
1708 @param[in] field_class
1709 Bit array field class of which to get the length.
1710
1711 @returns
1712 Length of \bt_p{field_class}.
1713
1714 @bt_pre_not_null{field_class}
1715 @bt_pre_is_ba_fc{field_class}
1716 */
1717 extern uint64_t bt_field_class_bit_array_get_length(
1718 const bt_field_class *field_class);
1719
1720 /*!
1721 @}
1722 */
1723
1724 /*!
1725 @name Integer field class
1726 @{
1727 */
1728
1729 /*!
1730 @brief
1731 Sets the field value range of the \bt_int_fc \bt_p{field_class}
1732 to \bt_p{n}.
1733
1734 See the \ref api-tir-fc-int-prop-size "field value range" property.
1735
1736 @param[in] field_class
1737 Integer field class of which to set the field value range to
1738 \bt_p{n}.
1739 @param[in] n
1740 @parblock
1741 \em N in:
1742
1743 <dl>
1744 <dt>Unsigned integer field class</dt>
1745 <dd>[0,&nbsp;2<sup><em>N</em></sup>&nbsp;-&nbsp;1]</dd>
1746
1747 <dt>Signed integer field class</dt>
1748 <dd>[-2<sup><em>N</em></sup>,&nbsp;2<sup><em>N</em></sup>&nbsp;-&nbsp;1]</dd>
1749 </dl>
1750 @endparblock
1751
1752 @bt_pre_not_null{field_class}
1753 @bt_pre_hot{field_class}
1754 @bt_pre_is_int_fc{field_class}
1755 @pre
1756 \bt_p{n} â©˝ 64.
1757
1758 @sa bt_field_class_integer_get_field_value_range() &mdash;
1759 Returns the field value range of an integer field class.
1760 */
1761 extern void bt_field_class_integer_set_field_value_range(
1762 bt_field_class *field_class, uint64_t n);
1763
1764 /*!
1765 @brief
1766 Returns the field value range of the \bt_int_fc \bt_p{field_class}.
1767
1768 See the \ref api-tir-fc-int-prop-size "field value range" property.
1769
1770 @param[in] field_class
1771 Integer field class of which to get the field value range.
1772
1773 @returns
1774 @parblock
1775 Field value range of \bt_p{field_class}, that is, \em N in:
1776
1777 <dl>
1778 <dt>Unsigned integer field class</dt>
1779 <dd>[0,&nbsp;2<sup><em>N</em></sup>&nbsp;-&nbsp;1]</dd>
1780
1781 <dt>Signed integer field class</dt>
1782 <dd>[-2<sup><em>N</em></sup>,&nbsp;2<sup><em>N</em></sup>&nbsp;-&nbsp;1]</dd>
1783 </dl>
1784 @endparblock
1785
1786 @bt_pre_not_null{field_class}
1787 @bt_pre_is_int_fc{field_class}
1788
1789 @sa bt_field_class_integer_set_field_value_range() &mdash;
1790 Sets the field value range of an integer field class.
1791 */
1792 extern uint64_t bt_field_class_integer_get_field_value_range(
1793 const bt_field_class *field_class);
1794
1795 /*!
1796 @brief
1797 Integer field class preferred display bases.
1798 */
1799 typedef enum bt_field_class_integer_preferred_display_base {
1800 /*!
1801 @brief
1802 Binary (2).
1803 */
1804 BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_BINARY = 2,
1805
1806 /*!
1807 @brief
1808 Octal (8).
1809 */
1810 BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_OCTAL = 8,
1811
1812 /*!
1813 @brief
1814 Decimal (10).
1815 */
1816 BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL = 10,
1817
1818 /*!
1819 @brief
1820 Hexadecimal (16).
1821 */
1822 BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL = 16,
1823 } bt_field_class_integer_preferred_display_base;
1824
1825 /*!
1826 @brief
1827 Sets the preferred display base of the \bt_int_fc \bt_p{field_class}
1828 to \bt_p{preferred_display_base}.
1829
1830 See the \ref api-tir-fc-int-prop-base "preferred display base" property.
1831
1832 @param[in] field_class
1833 Integer field class of which to set the preferred display base to
1834 \bt_p{preferred_display_base}.
1835 @param[in] preferred_display_base
1836 New preferred display base of \bt_p{field_class}.
1837
1838 @bt_pre_not_null{field_class}
1839 @bt_pre_hot{field_class}
1840 @bt_pre_is_int_fc{field_class}
1841
1842 @sa bt_field_class_integer_get_preferred_display_base() &mdash;
1843 Returns the preferred display base of an integer field class.
1844 */
1845 extern void bt_field_class_integer_set_preferred_display_base(
1846 bt_field_class *field_class,
1847 bt_field_class_integer_preferred_display_base preferred_display_base);
1848
1849 /*!
1850 @brief
1851 Returns the preferred display base of the \bt_int_fc
1852 \bt_p{field_class}.
1853
1854 See the \ref api-tir-fc-int-prop-base "preferred display base" property.
1855
1856 @param[in] field_class
1857 Integer field class of which to get the preferred display base.
1858
1859 @retval #BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_BINARY
1860 2 (binary)
1861 @retval #BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_OCTAL
1862 8 (octal)
1863 @retval #BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL
1864 10 (decimal)
1865 @retval #BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL
1866 16 (hexadecimal)
1867
1868 @bt_pre_not_null{field_class}
1869 @bt_pre_is_int_fc{field_class}
1870
1871 @sa bt_field_class_integer_set_preferred_display_base() &mdash;
1872 Sets the preferred display base of an integer field class.
1873 */
1874 extern bt_field_class_integer_preferred_display_base
1875 bt_field_class_integer_get_preferred_display_base(
1876 const bt_field_class *field_class);
1877
1878 /*! @} */
1879
1880 /*!
1881 @name Unsigned integer field class
1882 @{
1883 */
1884
1885 /*!
1886 @brief
1887 Creates an \bt_uint_fc from the trace class \bt_p{trace_class}.
1888
1889 On success, the returned unsigned integer field class has the following
1890 property values:
1891
1892 <table>
1893 <tr>
1894 <th>Property
1895 <th>Value
1896 <tr>
1897 <td>\ref api-tir-fc-int-prop-size "Field value range"
1898 <td>[0,&nbsp;2<sup>64</sup>&nbsp;-&nbsp;1]
1899 <tr>
1900 <td>\ref api-tir-fc-int-prop-base "Preferred display base"
1901 <td>#BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL
1902 <tr>
1903 <td>\ref api-tir-fc-prop-user-attrs "User attributes"
1904 <td>Empty \bt_map_val
1905 </table>
1906
1907 @param[in] trace_class
1908 Trace class from which to create an unsigned integer field class.
1909
1910 @returns
1911 New unsigned integer field class reference, or \c NULL on memory error.
1912
1913 @bt_pre_not_null{trace_class}
1914 */
1915 extern bt_field_class *bt_field_class_integer_unsigned_create(
1916 bt_trace_class *trace_class);
1917
1918 /*! @} */
1919
1920 /*!
1921 @name Signed integer field class
1922 @{
1923 */
1924
1925 /*!
1926 @brief
1927 Creates an \bt_sint_fc from the trace class \bt_p{trace_class}.
1928
1929 On success, the returned signed integer field class has the following
1930 property values:
1931
1932 <table>
1933 <tr>
1934 <th>Property
1935 <th>Value
1936 <tr>
1937 <td>\ref api-tir-fc-int-prop-size "Field value range"
1938 <td>[-2<sup>63</sup>,&nbsp;2<sup>63</sup>&nbsp;-&nbsp;1]
1939 <tr>
1940 <td>\ref api-tir-fc-int-prop-base "Preferred display base"
1941 <td>#BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL
1942 <tr>
1943 <td>\ref api-tir-fc-prop-user-attrs "User attributes"
1944 <td>Empty \bt_map_val
1945 </table>
1946
1947 @param[in] trace_class
1948 Trace class from which to create a signed integer field class.
1949
1950 @returns
1951 New signed integer field class reference, or \c NULL on memory error.
1952
1953 @bt_pre_not_null{trace_class}
1954 */
1955 extern bt_field_class *bt_field_class_integer_signed_create(
1956 bt_trace_class *trace_class);
1957
1958 /*! @} */
1959
1960 /*!
1961 @name Single-precision real field class
1962 @{
1963 */
1964
1965 /*!
1966 @brief
1967 Creates a single-precision \bt_real_fc from the trace class
1968 \bt_p{trace_class}.
1969
1970 On success, the returned single-precision real field class has the
1971 following property value:
1972
1973 <table>
1974 <tr>
1975 <th>Property
1976 <th>Value
1977 <tr>
1978 <td>\ref api-tir-fc-prop-user-attrs "User attributes"
1979 <td>Empty \bt_map_val
1980 </table>
1981
1982 @param[in] trace_class
1983 Trace class from which to create a single-preicision real
1984 field class.
1985
1986 @returns
1987 New single-precision real field class reference, or \c NULL on
1988 memory error.
1989
1990 @bt_pre_not_null{trace_class}
1991 */
1992 extern bt_field_class *bt_field_class_real_single_precision_create(
1993 bt_trace_class *trace_class);
1994
1995 /*! @} */
1996
1997 /*!
1998 @name Double-precision real field class
1999 @{
2000 */
2001
2002 /*!
2003 @brief
2004 Creates a double-precision \bt_real_fc from the trace class
2005 \bt_p{trace_class}.
2006
2007 On success, the returned double-precision real field class has the
2008 following property value:
2009
2010 <table>
2011 <tr>
2012 <th>Property
2013 <th>Value
2014 <tr>
2015 <td>\ref api-tir-fc-prop-user-attrs "User attributes"
2016 <td>Empty \bt_map_val
2017 </table>
2018
2019 @param[in] trace_class
2020 Trace class from which to create a double-preicision real
2021 field class.
2022
2023 @returns
2024 New double-precision real field class reference, or \c NULL on
2025 memory error.
2026
2027 @bt_pre_not_null{trace_class}
2028 */
2029 extern bt_field_class *bt_field_class_real_double_precision_create(
2030 bt_trace_class *trace_class);
2031
2032 /*! @} */
2033
2034 /*!
2035 @name Enumeration field class
2036 @{
2037 */
2038
2039 /*!
2040 @brief
2041 Array of \c const \bt_enum_fc labels.
2042
2043 Returned by bt_field_class_enumeration_unsigned_get_mapping_labels_for_value()
2044 and bt_field_class_enumeration_signed_get_mapping_labels_for_value().
2045 */
2046 typedef char const * const *bt_field_class_enumeration_mapping_label_array;
2047
2048 /*!
2049 @brief
2050 Status codes for
2051 bt_field_class_enumeration_unsigned_get_mapping_labels_for_value()
2052 and
2053 bt_field_class_enumeration_signed_get_mapping_labels_for_value().
2054 */
2055 typedef enum bt_field_class_enumeration_get_mapping_labels_for_value_status {
2056 /*!
2057 @brief
2058 Success.
2059 */
2060 BT_FIELD_CLASS_ENUMERATION_GET_MAPPING_LABELS_BY_VALUE_STATUS_OK = __BT_FUNC_STATUS_OK,
2061
2062 /*!
2063 @brief
2064 Out of memory.
2065 */
2066 BT_FIELD_CLASS_ENUMERATION_GET_MAPPING_LABELS_BY_VALUE_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR,
2067 } bt_field_class_enumeration_get_mapping_labels_for_value_status;
2068
2069 /*!
2070 @brief
2071 Status codes for bt_field_class_enumeration_unsigned_add_mapping()
2072 and bt_field_class_enumeration_signed_add_mapping().
2073 */
2074 typedef enum bt_field_class_enumeration_add_mapping_status {
2075 /*!
2076 @brief
2077 Success.
2078 */
2079 BT_FIELD_CLASS_ENUMERATION_ADD_MAPPING_STATUS_OK = __BT_FUNC_STATUS_OK,
2080
2081 /*!
2082 @brief
2083 Out of memory.
2084 */
2085 BT_FIELD_CLASS_ENUMERATION_ADD_MAPPING_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR,
2086 } bt_field_class_enumeration_add_mapping_status;
2087
2088 /*! @} */
2089
2090 /*!
2091 @name Enumeration field class mapping
2092 @{
2093 */
2094
2095 /*!
2096 @typedef struct bt_field_class_enumeration_mapping bt_field_class_enumeration_mapping;
2097
2098 @brief
2099 Enumeration field class mapping.
2100 */
2101
2102 /*!
2103 @brief
2104 Returns the number of mappings contained in the \bt_enum_fc
2105 \bt_p{field_class}.
2106
2107 See the \ref api-tir-fc-enum-prop-mappings "mappings" property.
2108
2109 @param[in] field_class
2110 Enumeration field class of which to get the number of contained
2111 mappings.
2112
2113 @returns
2114 Number of contained mappings in \bt_p{field_class}.
2115
2116 @bt_pre_not_null{field_class}
2117 @bt_pre_is_enum_fc{field_class}
2118 */
2119 extern uint64_t bt_field_class_enumeration_get_mapping_count(
2120 const bt_field_class *field_class);
2121
2122 /*!
2123 @brief
2124 Returns the label of the \bt_enum_fc mapping \bt_p{mapping}.
2125
2126 See the \ref api-tir-fc-enum-prop-mappings "mappings" property.
2127
2128 @param[in] mapping
2129 Enumeration field class mapping of which to get the label.
2130
2131 @returns
2132 @parblock
2133 Label of \bt_p{mapping}.
2134
2135 The returned pointer remains valid as long as \bt_p{mapping} exists.
2136 @endparblock
2137
2138 @bt_pre_not_null{mapping}
2139 */
2140 extern const char *bt_field_class_enumeration_mapping_get_label(
2141 const bt_field_class_enumeration_mapping *mapping);
2142
2143 /*! @} */
2144
2145 /*!
2146 @name Unsigned enumeration field class
2147 @{
2148 */
2149
2150 /*!
2151 @brief
2152 Creates an \bt_uenum_fc from the trace class \bt_p{trace_class}.
2153
2154 On success, the returned unsigned enumeration field class has the
2155 following property values:
2156
2157 <table>
2158 <tr>
2159 <th>Property
2160 <th>Value
2161 <tr>
2162 <td>\ref api-tir-fc-int-prop-size "Field value range"
2163 <td>[0,&nbsp;2<sup>64</sup>&nbsp;-&nbsp;1]
2164 <tr>
2165 <td>\ref api-tir-fc-int-prop-base "Preferred display base"
2166 <td>#BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL
2167 <tr>
2168 <td>\ref api-tir-fc-enum-prop-mappings "Mappings"
2169 <td>\em None
2170 <tr>
2171 <td>\ref api-tir-fc-prop-user-attrs "User attributes"
2172 <td>Empty \bt_map_val
2173 </table>
2174
2175 @param[in] trace_class
2176 Trace class from which to create an unsigned enumeration field
2177 class.
2178
2179 @returns
2180 New unsigned enumeration field class reference, or \c NULL on memory
2181 error.
2182
2183 @bt_pre_not_null{trace_class}
2184 */
2185 extern bt_field_class *bt_field_class_enumeration_unsigned_create(
2186 bt_trace_class *trace_class);
2187
2188 /*!
2189 @brief
2190 Adds a mapping to the \bt_uenum_fc \bt_p{field_class} having the
2191 label \bt_p{label} and the unsigned integer ranges \bt_p{ranges}.
2192
2193 See the \ref api-tir-fc-enum-prop-mappings "mappings" property.
2194
2195 @param[in] field_class
2196 Unsigned enumeration field class to which to add a mapping having
2197 the label \bt_p{label} and the integer ranges \bt_p{ranges}.
2198 @param[in] label
2199 Label of the mapping to add to \bt_p{field_class} (copied).
2200 @param[in] ranges
2201 Unsigned integer ranges of the mapping to add to
2202 \bt_p{field_class}.
2203
2204 @retval #BT_FIELD_CLASS_ENUMERATION_ADD_MAPPING_STATUS_OK
2205 Success.
2206 @retval #BT_FIELD_CLASS_ENUMERATION_ADD_MAPPING_STATUS_MEMORY_ERROR
2207 Out of memory.
2208
2209 @bt_pre_not_null{field_class}
2210 @bt_pre_hot{field_class}
2211 @bt_pre_is_uenum_fc{field_class}
2212 @bt_pre_not_null{label}
2213 @pre
2214 \bt_p{field_class} has no mapping with the label \bt_p{label}.
2215 @bt_pre_not_null{ranges}
2216 @pre
2217 \bt_p{ranges} contains one or more unsigned integer ranges.
2218 */
2219 extern bt_field_class_enumeration_add_mapping_status
2220 bt_field_class_enumeration_unsigned_add_mapping(
2221 bt_field_class *field_class, const char *label,
2222 const bt_integer_range_set_unsigned *ranges);
2223
2224 /*!
2225 @brief
2226 Borrows the mapping at index \bt_p{index} from the
2227 \bt_uenum_fc \bt_p{field_class}.
2228
2229 See the \ref api-tir-fc-enum-prop-mappings "mappings" property.
2230
2231 @param[in] field_class
2232 Unsigned enumeration field class from which to borrow the mapping at
2233 index \bt_p{index}.
2234 @param[in] index
2235 Index of the mapping to borrow from \bt_p{field_class}.
2236
2237 @returns
2238 @parblock
2239 \em Borrowed reference of the mapping of
2240 \bt_p{field_class} at index \bt_p{index}.
2241
2242 The returned pointer remains valid as long as \bt_p{field_class}
2243 is not modified.
2244 @endparblock
2245
2246 @bt_pre_not_null{field_class}
2247 @bt_pre_is_uenum_fc{field_class}
2248 @pre
2249 \bt_p{index} is less than the number of mappings in
2250 \bt_p{field_class} (as returned by
2251 bt_field_class_enumeration_get_mapping_count()).
2252
2253 @sa bt_field_class_enumeration_get_mapping_count() &mdash;
2254 Returns the number of mappings contained in an
2255 enumeration field class.
2256 */
2257 extern const bt_field_class_enumeration_unsigned_mapping *
2258 bt_field_class_enumeration_unsigned_borrow_mapping_by_index_const(
2259 const bt_field_class *field_class, uint64_t index);
2260
2261 /*!
2262 @brief
2263 Borrows the mapping having the label \bt_p{label} from the
2264 \bt_uenum_fc \bt_p{field_class}.
2265
2266 See the \ref api-tir-fc-enum-prop-mappings "mappings" property.
2267
2268 If there's no mapping having the label \bt_p{label} in
2269 \bt_p{field_class}, this function returns \c NULL.
2270
2271 @param[in] field_class
2272 Unsigned enumeration field class from which to borrow the mapping
2273 having the label \bt_p{label}.
2274 @param[in] label
2275 Label of the mapping to borrow from \bt_p{field_class}.
2276
2277 @returns
2278 @parblock
2279 \em Borrowed reference of the mapping of
2280 \bt_p{field_class} having the label \bt_p{label}, or \c NULL
2281 if none.
2282
2283 The returned pointer remains valid as long as \bt_p{field_class}
2284 is not modified.
2285 @endparblock
2286
2287 @bt_pre_not_null{field_class}
2288 @bt_pre_is_uenum_fc{field_class}
2289 @bt_pre_not_null{label}
2290 */
2291 extern const bt_field_class_enumeration_unsigned_mapping *
2292 bt_field_class_enumeration_unsigned_borrow_mapping_by_label_const(
2293 const bt_field_class *field_class, const char *label);
2294
2295 /*!
2296 @brief
2297 Returns an array of all the labels of the mappings of the
2298 \bt_uenum_fc \bt_p{field_class} of which the \bt_p_uint_rg contain
2299 the integral value \bt_p{value}.
2300
2301 See the \ref api-tir-fc-enum-prop-mappings "mappings" property.
2302
2303 This function sets \bt_p{*labels} to the resulting array and
2304 \bt_p{*count} to the number of labels in \bt_p{*labels}.
2305
2306 On success, if there's no mapping ranges containing the value
2307 \bt_p{value}, \bt_p{*count} is 0.
2308
2309 @param[in] field_class
2310 Unsigned enumeration field class from which to get the labels of the
2311 mappings of which the ranges contain \bt_p{value}.
2312 @param[in] value
2313 Value for which to get the mapped labels in \bt_p{field_class}.
2314 @param[out] labels
2315 @parblock
2316 <strong>On success</strong>, \bt_p{*labels}
2317 is an array of labels of the mappings of \bt_p{field_class}
2318 containing \bt_p{value}.
2319
2320 The number of labels in \bt_p{*labels} is \bt_p{*count}.
2321
2322 The array is owned by \bt_p{field_class} and remains valid as long
2323 as:
2324
2325 - \bt_p{field_class} is not modified.
2326 - You don't call this function again with \bt_p{field_class}.
2327 @endparblock
2328 @param[out] count
2329 <strong>On success</strong>, \bt_p{*count} is the number of labels
2330 in \bt_p{*labels} (can be 0).
2331
2332 @retval #BT_FIELD_CLASS_ENUMERATION_GET_MAPPING_LABELS_BY_VALUE_STATUS_OK
2333 Success.
2334 @retval #BT_FIELD_CLASS_ENUMERATION_GET_MAPPING_LABELS_BY_VALUE_STATUS_MEMORY_ERROR
2335 Out of memory.
2336
2337 @bt_pre_not_null{field_class}
2338 @bt_pre_is_uenum_fc{field_class}
2339 @bt_pre_not_null{labels}
2340 @bt_pre_not_null{count}
2341 */
2342 extern bt_field_class_enumeration_get_mapping_labels_for_value_status
2343 bt_field_class_enumeration_unsigned_get_mapping_labels_for_value(
2344 const bt_field_class *field_class, uint64_t value,
2345 bt_field_class_enumeration_mapping_label_array *labels,
2346 uint64_t *count);
2347
2348 /*! @} */
2349
2350 /*!
2351 @name Unsigned enumeration field class mapping
2352 @{
2353 */
2354
2355 /*!
2356 @typedef struct bt_field_class_enumeration_unsigned_mapping bt_field_class_enumeration_unsigned_mapping;
2357
2358 @brief
2359 Unsigned enumeration field class mapping.
2360 */
2361
2362 /*!
2363 @brief
2364 Borrows the \bt_p_uint_rg from the \bt_uenum_fc mapping
2365 \bt_p{mapping}.
2366
2367 See the \ref api-tir-fc-enum-prop-mappings "mappings" property.
2368
2369 @param[in] mapping
2370 Unsigned enumeration field class mapping from which to borrow the
2371 unsigned integer ranges.
2372
2373 @returns
2374 Unsigned integer ranges of \bt_p{mapping}.
2375
2376 @bt_pre_not_null{mapping}
2377 */
2378 extern const bt_integer_range_set_unsigned *
2379 bt_field_class_enumeration_unsigned_mapping_borrow_ranges_const(
2380 const bt_field_class_enumeration_unsigned_mapping *mapping);
2381
2382 /*!
2383 @brief
2384 \ref api-fund-c-typing "Upcasts" the \bt_uenum_fc mapping
2385 \bt_p{mapping} to the common #bt_field_class_enumeration_mapping
2386 type.
2387
2388 See the \ref api-tir-fc-enum-prop-mappings "mappings" property.
2389
2390 @param[in] mapping
2391 @parblock
2392 Unsigned enumeration field class mapping to upcast.
2393
2394 Can be \c NULL.
2395 @endparblock
2396
2397 @returns
2398 \bt_p{mapping} as a common enumeration field class mapping.
2399 */
2400 static inline
2401 const bt_field_class_enumeration_mapping *
2402 bt_field_class_enumeration_unsigned_mapping_as_mapping_const(
2403 const bt_field_class_enumeration_unsigned_mapping *mapping)
2404 {
2405 return __BT_UPCAST_CONST(bt_field_class_enumeration_mapping, mapping);
2406 }
2407
2408 /*! @} */
2409
2410 /*!
2411 @name Signed enumeration field class
2412 @{
2413 */
2414
2415 /*!
2416 @brief
2417 Creates a \bt_senum_fc from the trace class \bt_p{trace_class}.
2418
2419 On success, the returned signed enumeration field class has the
2420 following property values:
2421
2422 <table>
2423 <tr>
2424 <th>Property
2425 <th>Value
2426 <tr>
2427 <td>\ref api-tir-fc-int-prop-size "Field value range"
2428 <td>[-2<sup>63</sup>,&nbsp;2<sup>63</sup>&nbsp;-&nbsp;1]
2429 <tr>
2430 <td>\ref api-tir-fc-int-prop-base "Preferred display base"
2431 <td>#BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL
2432 <tr>
2433 <td>\ref api-tir-fc-enum-prop-mappings "Mappings"
2434 <td>\em None
2435 <tr>
2436 <td>\ref api-tir-fc-prop-user-attrs "User attributes"
2437 <td>Empty \bt_map_val
2438 </table>
2439
2440 @param[in] trace_class
2441 Trace class from which to create a signed enumeration field
2442 class.
2443
2444 @returns
2445 New signed enumeration field class reference, or \c NULL on memory
2446 error.
2447
2448 @bt_pre_not_null{trace_class}
2449 */
2450 extern bt_field_class *bt_field_class_enumeration_signed_create(
2451 bt_trace_class *trace_class);
2452
2453 /*!
2454 @brief
2455 Adds a mapping to the \bt_senum_fc \bt_p{field_class} having the
2456 label \bt_p{label} and the \bt_p_sint_rg \bt_p{ranges}.
2457
2458 See the \ref api-tir-fc-enum-prop-mappings "mappings" property.
2459
2460 @param[in] field_class
2461 Signed enumeration field class to which to add a mapping having
2462 the label \bt_p{label} and the integer ranges \bt_p{ranges}.
2463 @param[in] label
2464 Label of the mapping to add to \bt_p{field_class} (copied).
2465 @param[in] ranges
2466 Signed integer ranges of the mapping to add to
2467 \bt_p{field_class}.
2468
2469 @retval #BT_FIELD_CLASS_ENUMERATION_ADD_MAPPING_STATUS_OK
2470 Success.
2471 @retval #BT_FIELD_CLASS_ENUMERATION_ADD_MAPPING_STATUS_MEMORY_ERROR
2472 Out of memory.
2473
2474 @bt_pre_not_null{field_class}
2475 @bt_pre_hot{field_class}
2476 @bt_pre_is_senum_fc{field_class}
2477 @bt_pre_not_null{label}
2478 @pre
2479 \bt_p{field_class} has no mapping with the label \bt_p{label}.
2480 @bt_pre_not_null{ranges}
2481 @pre
2482 \bt_p{ranges} contains one or more signed integer ranges.
2483 */
2484 extern bt_field_class_enumeration_add_mapping_status
2485 bt_field_class_enumeration_signed_add_mapping(
2486 bt_field_class *field_class, const char *label,
2487 const bt_integer_range_set_signed *ranges);
2488
2489 /*!
2490 @brief
2491 Borrows the mapping at index \bt_p{index} from the
2492 \bt_senum_fc \bt_p{field_class}.
2493
2494 See the \ref api-tir-fc-enum-prop-mappings "mappings" property.
2495
2496 @param[in] field_class
2497 Signed enumeration field class from which to borrow the mapping at
2498 index \bt_p{index}.
2499 @param[in] index
2500 Index of the mapping to borrow from \bt_p{field_class}.
2501
2502 @returns
2503 @parblock
2504 \em Borrowed reference of the mapping of
2505 \bt_p{field_class} at index \bt_p{index}.
2506
2507 The returned pointer remains valid as long as \bt_p{field_class}
2508 is not modified.
2509 @endparblock
2510
2511 @bt_pre_not_null{field_class}
2512 @bt_pre_is_senum_fc{field_class}
2513 @pre
2514 \bt_p{index} is less than the number of mappings in
2515 \bt_p{field_class} (as returned by
2516 bt_field_class_enumeration_get_mapping_count()).
2517
2518 @sa bt_field_class_enumeration_get_mapping_count() &mdash;
2519 Returns the number of mappings contained in an
2520 enumeration field class.
2521 */
2522 extern const bt_field_class_enumeration_signed_mapping *
2523 bt_field_class_enumeration_signed_borrow_mapping_by_index_const(
2524 const bt_field_class *field_class, uint64_t index);
2525
2526 /*!
2527 @brief
2528 Borrows the mapping having the label \bt_p{label} from the
2529 \bt_senum_fc \bt_p{field_class}.
2530
2531 See the \ref api-tir-fc-enum-prop-mappings "mappings" property.
2532
2533 If there's no mapping having the label \bt_p{label} in
2534 \bt_p{field_class}, this function returns \c NULL.
2535
2536 @param[in] field_class
2537 Signed enumeration field class from which to borrow the mapping
2538 having the label \bt_p{label}.
2539 @param[in] label
2540 Label of the mapping to borrow from \bt_p{field_class}.
2541
2542 @returns
2543 @parblock
2544 \em Borrowed reference of the mapping of
2545 \bt_p{field_class} having the label \bt_p{label}, or \c NULL
2546 if none.
2547
2548 The returned pointer remains valid as long as \bt_p{field_class}
2549 is not modified.
2550 @endparblock
2551
2552 @bt_pre_not_null{field_class}
2553 @bt_pre_is_senum_fc{field_class}
2554 @bt_pre_not_null{label}
2555 */
2556 extern const bt_field_class_enumeration_signed_mapping *
2557 bt_field_class_enumeration_signed_borrow_mapping_by_label_const(
2558 const bt_field_class *field_class, const char *label);
2559
2560 /*!
2561 @brief
2562 Returns an array of all the labels of the mappings of the
2563 \bt_senum_fc \bt_p{field_class} of which the \bt_p_sint_rg contain
2564 the integral value \bt_p{value}.
2565
2566 See the \ref api-tir-fc-enum-prop-mappings "mappings" property.
2567
2568 This function sets \bt_p{*labels} to the resulting array and
2569 \bt_p{*count} to the number of labels in \bt_p{*labels}.
2570
2571 On success, if there's no mapping ranges containing the value
2572 \bt_p{value}, \bt_p{*count} is 0.
2573
2574 @param[in] field_class
2575 Signed enumeration field class from which to get the labels of the
2576 mappings of which the ranges contain \bt_p{value}.
2577 @param[in] value
2578 Value for which to get the mapped labels in \bt_p{field_class}.
2579 @param[out] labels
2580 @parblock
2581 <strong>On success</strong>, \bt_p{*labels}
2582 is an array of labels of the mappings of \bt_p{field_class}
2583 containing \bt_p{value}.
2584
2585 The number of labels in \bt_p{*labels} is \bt_p{*count}.
2586
2587 The array is owned by \bt_p{field_class} and remains valid as long
2588 as:
2589
2590 - \bt_p{field_class} is not modified.
2591 - You don't call this function again with \bt_p{field_class}.
2592 @endparblock
2593 @param[out] count
2594 <strong>On success</strong>, \bt_p{*count} is the number of labels
2595 in \bt_p{*labels} (can be 0).
2596
2597 @retval #BT_FIELD_CLASS_ENUMERATION_GET_MAPPING_LABELS_BY_VALUE_STATUS_OK
2598 Success.
2599 @retval #BT_FIELD_CLASS_ENUMERATION_GET_MAPPING_LABELS_BY_VALUE_STATUS_MEMORY_ERROR
2600 Out of memory.
2601
2602 @bt_pre_not_null{field_class}
2603 @bt_pre_is_senum_fc{field_class}
2604 @bt_pre_not_null{labels}
2605 @bt_pre_not_null{count}
2606 */
2607 extern bt_field_class_enumeration_get_mapping_labels_for_value_status
2608 bt_field_class_enumeration_signed_get_mapping_labels_for_value(
2609 const bt_field_class *field_class, int64_t value,
2610 bt_field_class_enumeration_mapping_label_array *labels,
2611 uint64_t *count);
2612
2613 /*! @} */
2614
2615 /*!
2616 @name Signed enumeration field class mapping
2617 @{
2618 */
2619
2620 /*!
2621 @typedef struct bt_field_class_enumeration_signed_mapping bt_field_class_enumeration_signed_mapping;
2622
2623 @brief
2624 Signed enumeration field class mapping.
2625 */
2626
2627 /*!
2628 @brief
2629 Borrows the \bt_p_sint_rg from the \bt_senum_fc mapping
2630 \bt_p{mapping}.
2631
2632 See the \ref api-tir-fc-enum-prop-mappings "mappings" property.
2633
2634 @param[in] mapping
2635 Signed enumeration field class mapping from which to borrow the
2636 signed integer ranges.
2637
2638 @returns
2639 Signed integer ranges of \bt_p{mapping}.
2640
2641 @bt_pre_not_null{mapping}
2642 */
2643 extern const bt_integer_range_set_signed *
2644 bt_field_class_enumeration_signed_mapping_borrow_ranges_const(
2645 const bt_field_class_enumeration_signed_mapping *mapping);
2646
2647 /*!
2648 @brief
2649 \ref api-fund-c-typing "Upcasts" the \bt_senum_fc mapping
2650 \bt_p{mapping} to the common #bt_field_class_enumeration_mapping
2651 type.
2652
2653 See the \ref api-tir-fc-enum-prop-mappings "mappings" property.
2654
2655 @param[in] mapping
2656 @parblock
2657 Signed enumeration field class mapping to upcast.
2658
2659 Can be \c NULL.
2660 @endparblock
2661
2662 @returns
2663 \bt_p{mapping} as a common enumeration field class mapping.
2664 */
2665 static inline
2666 const bt_field_class_enumeration_mapping *
2667 bt_field_class_enumeration_signed_mapping_as_mapping_const(
2668 const bt_field_class_enumeration_signed_mapping *mapping)
2669 {
2670 return __BT_UPCAST_CONST(bt_field_class_enumeration_mapping, mapping);
2671 }
2672
2673 /*! @} */
2674
2675 /*!
2676 @name String field class
2677 @{
2678 */
2679
2680 /*!
2681 @brief
2682 Creates a \bt_string_fc from the trace class \bt_p{trace_class}.
2683
2684 On success, the returned string field class has the following property
2685 value:
2686
2687 <table>
2688 <tr>
2689 <th>Property
2690 <th>Value
2691 <tr>
2692 <td>\ref api-tir-fc-prop-user-attrs "User attributes"
2693 <td>Empty \bt_map_val
2694 </table>
2695
2696 @param[in] trace_class
2697 Trace class from which to create a string field class.
2698
2699 @returns
2700 New string field class reference, or \c NULL on memory error.
2701
2702 @bt_pre_not_null{trace_class}
2703 */
2704 extern bt_field_class *bt_field_class_string_create(
2705 bt_trace_class *trace_class);
2706
2707 /*! @} */
2708
2709 /*!
2710 @name Array field class
2711 @{
2712 */
2713
2714 /*!
2715 @brief
2716 Borrows the element field class from the \bt_array_fc
2717 \bt_p{field_class}.
2718
2719 See the \ref api-tir-fc-array-prop-elem-fc "element field class"
2720 property.
2721
2722 @param[in] field_class
2723 Array field class from which to borrow the element field class.
2724
2725 @returns
2726 Element field class of \bt_p{field_class}.
2727
2728 @bt_pre_not_null{field_class}
2729 @bt_pre_is_array_fc{field_class}
2730
2731 @sa bt_field_class_array_borrow_element_field_class_const() &mdash;
2732 \c const version of this function.
2733 */
2734 extern bt_field_class *bt_field_class_array_borrow_element_field_class(
2735 bt_field_class *field_class);
2736
2737 /*!
2738 @brief
2739 Borrows the element field class from the \bt_array_fc
2740 \bt_p{field_class} (\c const version).
2741
2742 See bt_field_class_array_borrow_element_field_class().
2743 */
2744 extern const bt_field_class *
2745 bt_field_class_array_borrow_element_field_class_const(
2746 const bt_field_class *field_class);
2747
2748 /*! @} */
2749
2750 /*!
2751 @name Static array field class
2752 @{
2753 */
2754
2755 /*!
2756 @brief
2757 Creates a \bt_sarray_fc having the element field class
2758 \bt_p{element_field_class} and the length \bt_p{length} from the
2759 trace class \bt_p{trace_class}.
2760
2761 On success, the returned static array field class has the following
2762 property values:
2763
2764 <table>
2765 <tr>
2766 <th>Property
2767 <th>Value
2768 <tr>
2769 <td>\ref api-tir-fc-array-prop-elem-fc "Element field class"
2770 <td>\bt_p{element_field_class}
2771 <tr>
2772 <td>\ref api-tir-fc-sarray-prop-len "Length"
2773 <td>\bt_p{length}
2774 <tr>
2775 <td>\ref api-tir-fc-prop-user-attrs "User attributes"
2776 <td>Empty \bt_map_val
2777 </table>
2778
2779 @param[in] trace_class
2780 Trace class from which to create a static array field class.
2781 @param[in] element_field_class
2782 Class of the element fields of the instances of the static array
2783 field class to create.
2784 @param[in] length
2785 Length of the instances of the static array field class to create.
2786
2787 @returns
2788 New static array field class reference, or \c NULL on memory error.
2789
2790 @bt_pre_not_null{trace_class}
2791 @bt_pre_not_null{element_field_class}
2792 bt_pre_fc_not_in_tc{element_field_class}
2793
2794 @bt_post_success_frozen{element_field_class}
2795 */
2796 extern bt_field_class *bt_field_class_array_static_create(
2797 bt_trace_class *trace_class,
2798 bt_field_class *element_field_class, uint64_t length);
2799
2800 /*!
2801 @brief
2802 Returns the length of the \bt_sarray_fc \bt_p{field_class}.
2803
2804 See the \ref api-tir-fc-sarray-prop-len "length" property.
2805
2806 @param[in] field_class
2807 Static array field class of which to get the length.
2808
2809 @returns
2810 Length of \bt_p{field_class}.
2811
2812 @bt_pre_not_null{field_class}
2813 @bt_pre_is_sarray_fc{field_class}
2814 */
2815 extern uint64_t bt_field_class_array_static_get_length(
2816 const bt_field_class *field_class);
2817
2818 /*! @} */
2819
2820 /*!
2821 @name Dynamic array field class
2822 @{
2823 */
2824
2825 /*!
2826 @brief
2827 Creates a \bt_darray_fc having the element field class
2828 \bt_p{element_field_class} from the trace class \bt_p{trace_class}.
2829
2830 If \bt_p{length_field_class} is not \c NULL, then the created dynamic
2831 array field class has a linked length field class.
2832 See
2833 \ref api-tir-fc-link "Field classes with links to other field classes"
2834 to learn more.
2835
2836 On success, the returned dynamic array field class has the following
2837 property values:
2838
2839 <table>
2840 <tr>
2841 <th>Property
2842 <th>Value
2843 <tr>
2844 <td>\ref api-tir-fc-array-prop-elem-fc "Element field class"
2845 <td>\bt_p{element_field_class}
2846 <tr>
2847 <td>\ref api-tir-fc-darray-prop-len-fp "Length field path"
2848 <td>
2849 \em None (if \bt_p{length_field_class} is not \c NULL, this
2850 property becomes available when the returned field class becomes
2851 part of an \bt_ev_cls or of a \bt_stream_cls)
2852 <tr>
2853 <td>\ref api-tir-fc-prop-user-attrs "User attributes"
2854 <td>Empty \bt_map_val
2855 </table>
2856
2857 @param[in] trace_class
2858 Trace class from which to create a dynamic array field class.
2859 @param[in] element_field_class
2860 Class of the element fields of the instances of the dynamic array
2861 field class to create.
2862 @param[in] length_field_class
2863 @parblock
2864 Linked length field class of the dynamic array field class to
2865 create.
2866
2867 Can be \c NULL.
2868 @endparblock
2869
2870 @returns
2871 New dynamic array field class reference, or \c NULL on memory error.
2872
2873 @bt_pre_not_null{trace_class}
2874 @bt_pre_not_null{element_field_class}
2875 @bt_pre_fc_not_in_tc{element_field_class}
2876 @pre
2877 <strong>If \bt_p{length_field_class} is not \c NULL</strong>,
2878 \bt_p{length_field_class} is an \bt_uint_fc.
2879
2880 @bt_post_success_frozen{element_field_class}
2881 @bt_post_success_frozen{length_field_class}
2882 */
2883 extern bt_field_class *bt_field_class_array_dynamic_create(
2884 bt_trace_class *trace_class,
2885 bt_field_class *element_field_class,
2886 bt_field_class *length_field_class);
2887
2888 /*! @} */
2889
2890 /*!
2891 @name Dynamic array field class with length field
2892 @{
2893 */
2894
2895 /*!
2896 @brief
2897 Borrows the length field path from the \bt_darray_fc (with a length
2898 field) \bt_p{field_class}.
2899
2900 See the \ref api-tir-fc-darray-prop-len-fp "length field path" property.
2901
2902 This property is only available when a \bt_struct_fc containing
2903 (recursively) \bt_p{field_class} is passed to one of:
2904
2905 - bt_stream_class_set_packet_context_field_class()
2906 - bt_stream_class_set_event_common_context_field_class()
2907 - bt_event_class_set_specific_context_field_class()
2908 - bt_event_class_set_payload_field_class()
2909
2910 In the meantime, this function returns \c NULL.
2911
2912 @param[in] field_class
2913 Dynamic array field class from which to borrow the length
2914 field path.
2915
2916 @returns
2917 Length field path of \bt_p{field_class}.
2918
2919 @bt_pre_not_null{field_class}
2920 @bt_pre_is_darray_wl_fc{field_class}
2921 */
2922 extern const bt_field_path *
2923 bt_field_class_array_dynamic_with_length_field_borrow_length_field_path_const(
2924 const bt_field_class *field_class);
2925
2926 /*! @} */
2927
2928 /*!
2929 @name Structure field class
2930 @{
2931 */
2932
2933 /*!
2934 @brief
2935 Creates a \bt_struct_fc from the trace class \bt_p{trace_class}.
2936
2937 On success, the returned structure field class has the following
2938 property values:
2939
2940 <table>
2941 <tr>
2942 <th>Property
2943 <th>Value
2944 <tr>
2945 <td>\ref api-tir-fc-struct-prop-members "Members"
2946 <td>\em None
2947 <tr>
2948 <td>\ref api-tir-fc-prop-user-attrs "User attributes"
2949 <td>Empty \bt_map_val
2950 </table>
2951
2952 @param[in] trace_class
2953 Trace class from which to create a structure field class.
2954
2955 @returns
2956 New structure field class reference, or \c NULL on memory error.
2957
2958 @bt_pre_not_null{trace_class}
2959 */
2960 extern bt_field_class *bt_field_class_structure_create(
2961 bt_trace_class *trace_class);
2962
2963 /*!
2964 @brief
2965 Status codes for bt_field_class_structure_append_member().
2966 */
2967 typedef enum bt_field_class_structure_append_member_status {
2968 /*!
2969 @brief
2970 Success.
2971 */
2972 BT_FIELD_CLASS_STRUCTURE_APPEND_MEMBER_STATUS_OK = __BT_FUNC_STATUS_OK,
2973
2974 /*!
2975 @brief
2976 Out of memory.
2977 */
2978 BT_FIELD_CLASS_STRUCTURE_APPEND_MEMBER_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR,
2979 } bt_field_class_structure_append_member_status;
2980
2981 /*!
2982 @brief
2983 Appends a member to the \bt_struct_fc \bt_p{field_class} having the
2984 name \bt_p{name} and the field class \bt_p{member_field_class}.
2985
2986 See the \ref api-tir-fc-struct-prop-members "members" property.
2987
2988 @param[in] field_class
2989 Structure field class to which to append a member having
2990 the name \bt_p{name} and the field class \bt_p{member_field_class}.
2991 @param[in] name
2992 Name of the member to append to \bt_p{field_class} (copied).
2993 @param[in] member_field_class
2994 Field class of the member to append to \bt_p{field_class}.
2995
2996 @retval #BT_FIELD_CLASS_STRUCTURE_APPEND_MEMBER_STATUS_OK
2997 Success.
2998 @retval #BT_FIELD_CLASS_STRUCTURE_APPEND_MEMBER_STATUS_MEMORY_ERROR
2999 Out of memory.
3000
3001 @bt_pre_not_null{field_class}
3002 @bt_pre_hot{field_class}
3003 @bt_pre_is_struct_fc{field_class}
3004 @pre
3005 \bt_p{field_class} has no member with the name \bt_p{name}.
3006 @bt_pre_not_null{name}
3007 @bt_pre_not_null{member_field_class}
3008 @bt_pre_fc_not_in_tc{member_field_class}
3009
3010 @bt_post_success_frozen{member_field_class}
3011 */
3012 extern bt_field_class_structure_append_member_status
3013 bt_field_class_structure_append_member(
3014 bt_field_class *field_class,
3015 const char *name, bt_field_class *member_field_class);
3016
3017 /*!
3018 @brief
3019 Returns the number of members contained in the \bt_struct_fc
3020 \bt_p{field_class}.
3021
3022 See the \ref api-tir-fc-struct-prop-members "members" property.
3023
3024 @param[in] field_class
3025 Structure field class of which to get the number of contained
3026 members.
3027
3028 @returns
3029 Number of contained members in \bt_p{field_class}.
3030
3031 @bt_pre_not_null{field_class}
3032 @bt_pre_is_struct_fc{field_class}
3033 */
3034 extern uint64_t bt_field_class_structure_get_member_count(
3035 const bt_field_class *field_class);
3036
3037 /*!
3038 @brief
3039 Borrows the member at index \bt_p{index} from the
3040 \bt_struct_fc \bt_p{field_class}.
3041
3042 See the \ref api-tir-fc-struct-prop-members "members" property.
3043
3044 @param[in] field_class
3045 Structure field class from which to borrow the member at
3046 index \bt_p{index}.
3047 @param[in] index
3048 Index of the member to borrow from \bt_p{field_class}.
3049
3050 @returns
3051 @parblock
3052 \em Borrowed reference of the member of
3053 \bt_p{field_class} at index \bt_p{index}.
3054
3055 The returned pointer remains valid as long as \bt_p{field_class}
3056 is not modified.
3057 @endparblock
3058
3059 @bt_pre_not_null{field_class}
3060 @bt_pre_is_struct_fc{field_class}
3061 @pre
3062 \bt_p{index} is less than the number of members in
3063 \bt_p{field_class} (as returned by
3064 bt_field_class_structure_get_member_count()).
3065
3066 @sa bt_field_class_structure_get_member_count() &mdash;
3067 Returns the number of members contained in a structure field class.
3068 @sa bt_field_class_structure_borrow_member_by_index_const() &mdash;
3069 \c const version of this function.
3070 */
3071 extern bt_field_class_structure_member *
3072 bt_field_class_structure_borrow_member_by_index(
3073 bt_field_class *field_class, uint64_t index);
3074
3075 /*!
3076 @brief
3077 Borrows the member at index \bt_p{index} from the
3078 \bt_struct_fc \bt_p{field_class} (\c const version).
3079
3080 See bt_field_class_structure_borrow_member_by_index().
3081 */
3082 extern const bt_field_class_structure_member *
3083 bt_field_class_structure_borrow_member_by_index_const(
3084 const bt_field_class *field_class, uint64_t index);
3085
3086 /*!
3087 @brief
3088 Borrows the member having the name \bt_p{name} from the
3089 \bt_struct_fc \bt_p{field_class}.
3090
3091 See the \ref api-tir-fc-struct-prop-members "members" property.
3092
3093 If there's no member having the name \bt_p{name} in
3094 \bt_p{field_class}, this function returns \c NULL.
3095
3096 @param[in] field_class
3097 Structure field class from which to borrow the member having the
3098 name \bt_p{name}.
3099 @param[in] name
3100 Name of the member to borrow from \bt_p{field_class}.
3101
3102 @returns
3103 @parblock
3104 \em Borrowed reference of the member of
3105 \bt_p{field_class} having the name \bt_p{name}, or \c NULL
3106 if none.
3107
3108 The returned pointer remains valid as long as \bt_p{field_class}
3109 is not modified.
3110 @endparblock
3111
3112 @bt_pre_not_null{field_class}
3113 @bt_pre_is_struct_fc{field_class}
3114 @bt_pre_not_null{name}
3115
3116 @sa bt_field_class_structure_borrow_member_by_name_const() &mdash;
3117 \c const version of this function.
3118 */
3119 extern bt_field_class_structure_member *
3120 bt_field_class_structure_borrow_member_by_name(
3121 bt_field_class *field_class, const char *name);
3122
3123 /*!
3124 @brief
3125 Borrows the member having the name \bt_p{name} from the
3126 \bt_struct_fc \bt_p{field_class} (\c const version).
3127
3128 See bt_field_class_structure_borrow_member_by_name().
3129 */
3130 extern const bt_field_class_structure_member *
3131 bt_field_class_structure_borrow_member_by_name_const(
3132 const bt_field_class *field_class, const char *name);
3133
3134 /*! @} */
3135
3136 /*!
3137 @name Structure field class member
3138 @{
3139 */
3140
3141 /*!
3142 @typedef struct bt_field_class_structure_member bt_field_class_structure_member;
3143
3144 @brief
3145 Structure field class member.
3146 */
3147
3148 /*!
3149 @brief
3150 Returns the name of the \bt_struct_fc member \bt_p{member}.
3151
3152 See the \ref api-tir-fc-struct-prop-members "members" property.
3153
3154 @param[in] member
3155 Structure field class member of which to get the name.
3156
3157 @returns
3158 @parblock
3159 Name of \bt_p{member}.
3160
3161 The returned pointer remains valid as long as \bt_p{member} exists.
3162 @endparblock
3163
3164 @bt_pre_not_null{member}
3165 */
3166 extern const char *bt_field_class_structure_member_get_name(
3167 const bt_field_class_structure_member *member);
3168
3169 /*!
3170 @brief
3171 Borrows the field class from the \bt_struct_fc member
3172 \bt_p{member}.
3173
3174 See the \ref api-tir-fc-struct-prop-members "members" property.
3175
3176 @param[in] member
3177 Structure field class member from which to borrow the field class.
3178
3179 @returns
3180 Field class of \bt_p{member}.
3181
3182 @bt_pre_not_null{member}
3183
3184 @sa bt_field_class_structure_member_borrow_field_class_const() &mdash;
3185 \c const version of this function.
3186 */
3187 extern bt_field_class *
3188 bt_field_class_structure_member_borrow_field_class(
3189 bt_field_class_structure_member *member);
3190
3191 /*!
3192 @brief
3193 Borrows the field class from the \bt_struct_fc member
3194 \bt_p{member} (\c const version).
3195
3196 See bt_field_class_structure_member_borrow_field_class().
3197 */
3198 extern const bt_field_class *
3199 bt_field_class_structure_member_borrow_field_class_const(
3200 const bt_field_class_structure_member *member);
3201
3202 /*!
3203 @brief
3204 Sets the user attributes of the \bt_struct_fc member \bt_p{member}
3205 to \bt_p{user_attributes}.
3206
3207 See the \ref api-tir-fc-struct-prop-members "members" property.
3208
3209 @note
3210 When you append a member to a structure field class with
3211 bt_field_class_structure_append_member(), the member's
3212 initial user attributes is an empty \bt_map_val. Therefore you can
3213 borrow it with
3214 bt_field_class_structure_member_borrow_user_attributes() and fill it
3215 directly instead of setting a new one with this function.
3216
3217 @param[in] member
3218 Structure field class member of which to set the user attributes to
3219 \bt_p{user_attributes}.
3220 @param[in] user_attributes
3221 New user attributes of \bt_p{member}.
3222
3223 @bt_pre_not_null{member}
3224 @bt_pre_hot{member}
3225 @bt_pre_not_null{user_attributes}
3226 @bt_pre_is_map_val{user_attributes}
3227
3228 @sa bt_field_class_structure_member_borrow_user_attributes() &mdash;
3229 Borrows the user attributes of a structure field class member.
3230 */
3231 extern void bt_field_class_structure_member_set_user_attributes(
3232 bt_field_class_structure_member *member,
3233 const bt_value *user_attributes);
3234
3235 /*!
3236 @brief
3237 Borrows the user attributes of the \bt_struct_fc member
3238 \bt_p{member}.
3239
3240 See the \ref api-tir-fc-struct-prop-members "members" property.
3241
3242 @note
3243 When you append a member to a structure field class with
3244 bt_field_class_structure_append_member(), the member's
3245 initial user attributes is an empty \bt_map_val.
3246
3247 @param[in] member
3248 Structure field class member from which to borrow the user
3249 attributes.
3250
3251 @returns
3252 User attributes of \bt_p{member} (a \bt_map_val).
3253
3254 @bt_pre_not_null{member}
3255
3256 @sa bt_field_class_structure_member_set_user_attributes() &mdash;
3257 Sets the user attributes of a structure field class member.
3258 @sa bt_field_class_structure_member_borrow_user_attributes_const() &mdash;
3259 \c const version of this function.
3260 */
3261 extern bt_value *
3262 bt_field_class_structure_member_borrow_user_attributes(
3263 bt_field_class_structure_member *member);
3264
3265 /*!
3266 @brief
3267 Borrows the user attributes of the \bt_struct_fc member
3268 \bt_p{member} (\c const version).
3269
3270 See bt_field_class_structure_member_borrow_user_attributes().
3271 */
3272 extern const bt_value *
3273 bt_field_class_structure_member_borrow_user_attributes_const(
3274 const bt_field_class_structure_member *member);
3275
3276 /*! @} */
3277
3278 /*!
3279 @name Option field class
3280 @{
3281 */
3282
3283 /*!
3284 @brief
3285 Borrows the optional field class from the \bt_opt_fc
3286 \bt_p{field_class}.
3287
3288 See the \ref api-tir-fc-opt-prop-fc "optional field class" property.
3289
3290 @param[in] field_class
3291 Option field class from which to borrow the optional field class.
3292
3293 @returns
3294 Optional field class of \bt_p{field_class}.
3295
3296 @bt_pre_not_null{field_class}
3297 @bt_pre_is_opt_fc{field_class}
3298
3299 @sa bt_field_class_option_borrow_field_class_const() &mdash;
3300 \c const version of this function.
3301 */
3302 extern bt_field_class *bt_field_class_option_borrow_field_class(
3303 bt_field_class *field_class);
3304
3305 /*!
3306 @brief
3307 Borrows the optional field class from the \bt_opt_fc
3308 \bt_p{field_class} (\c const version).
3309
3310 See bt_field_class_option_borrow_field_class().
3311 */
3312 extern const bt_field_class *
3313 bt_field_class_option_borrow_field_class_const(
3314 const bt_field_class *field_class);
3315
3316 /*! @} */
3317
3318 /*!
3319 @name Option field class without a selector field
3320 @{
3321 */
3322
3323 /*!
3324 @brief
3325 Creates an \bt_opt_fc (without a selector field) having the optional
3326 field class \bt_p{optional_field_class} from the trace class
3327 \bt_p{trace_class}.
3328
3329 On success, the returned option field class has the following property
3330 values:
3331
3332 <table>
3333 <tr>
3334 <th>Property
3335 <th>Value
3336 <tr>
3337 <td>\ref api-tir-fc-opt-prop-fc "Optional field class"
3338 <td>\bt_p{optional_field_class}
3339 <tr>
3340 <td>\ref api-tir-fc-prop-user-attrs "User attributes"
3341 <td>Empty \bt_map_val
3342 </table>
3343
3344 @param[in] trace_class
3345 Trace class from which to create an option field class.
3346 @param[in] optional_field_class
3347 Class of the optional fields of the instances of the option field
3348 class to create.
3349
3350 @returns
3351 New option field class reference, or \c NULL on memory error.
3352
3353 @bt_pre_not_null{trace_class}
3354 @bt_pre_not_null{optional_field_class}
3355 @bt_pre_fc_not_in_tc{optional_field_class}
3356
3357 @bt_post_success_frozen{optional_field_class}
3358 */
3359 extern bt_field_class *bt_field_class_option_without_selector_create(
3360 bt_trace_class *trace_class,
3361 bt_field_class *optional_field_class);
3362
3363 /*! @} */
3364
3365 /*!
3366 @name Option field class with a selector field
3367 @{
3368 */
3369
3370 /*!
3371 @brief
3372 Borrows the selector field path from the \bt_opt_fc (with a selector
3373 field) \bt_p{field_class}.
3374
3375 See the \ref api-tir-fc-opt-prop-sel-fp "selector field path" property.
3376
3377 This property is only available when a \bt_struct_fc containing
3378 (recursively) \bt_p{field_class} is passed to one of:
3379
3380 - bt_stream_class_set_packet_context_field_class()
3381 - bt_stream_class_set_event_common_context_field_class()
3382 - bt_event_class_set_specific_context_field_class()
3383 - bt_event_class_set_payload_field_class()
3384
3385 In the meantime, this function returns \c NULL.
3386
3387 @param[in] field_class
3388 Option field class from which to borrow the selector field path.
3389
3390 @returns
3391 Selector field path of \bt_p{field_class}.
3392
3393 @bt_pre_not_null{field_class}
3394 @bt_pre_is_opt_ws_fc{field_class}
3395 */
3396 extern const bt_field_path *
3397 bt_field_class_option_with_selector_field_borrow_selector_field_path_const(
3398 const bt_field_class *field_class);
3399
3400 /*! @} */
3401
3402 /*!
3403 @name Option field class with a boolean selector field
3404 @{
3405 */
3406
3407 /*!
3408 @brief
3409 Creates an \bt_opt_fc (with a boolean selector field) having the
3410 optional field class \bt_p{optional_field_class} from the trace
3411 class \bt_p{trace_class}.
3412
3413 On success, the returned option field class has the following property
3414 values:
3415
3416 <table>
3417 <tr>
3418 <th>Property
3419 <th>Value
3420 <tr>
3421 <td>\ref api-tir-fc-opt-prop-fc "Optional field class"
3422 <td>\bt_p{optional_field_class}
3423 <tr>
3424 <td>\ref api-tir-fc-opt-prop-sel-fp "Selector field path"
3425 <td>
3426 \em None (this property becomes available when the returned field
3427 class becomes part of an \bt_ev_cls or of a \bt_stream_cls)
3428 <tr>
3429 <td>\ref api-tir-fc-opt-prop-sel-rev "Selector is reversed?"
3430 <td>#BT_FALSE
3431 <tr>
3432 <td>\ref api-tir-fc-prop-user-attrs "User attributes"
3433 <td>Empty \bt_map_val
3434 </table>
3435
3436 @param[in] trace_class
3437 Trace class from which to create an option field class.
3438 @param[in] optional_field_class
3439 Class of the optional fields of the instances of the option field
3440 class to create.
3441 @param[in] selector_field_class
3442 Linked selector field class of the option field class to create.
3443
3444 @returns
3445 New option field class reference, or \c NULL on memory error.
3446
3447 @bt_pre_not_null{trace_class}
3448 @bt_pre_not_null{optional_field_class}
3449 @bt_pre_fc_not_in_tc{optional_field_class}
3450 @bt_pre_not_null{selector_field_class}
3451 @pre
3452 \bt_p{selector_field_class} is a \bt_bool_fc.
3453
3454 @bt_post_success_frozen{optional_field_class}
3455 @bt_post_success_frozen{selector_field_class}
3456 */
3457 extern bt_field_class *bt_field_class_option_with_selector_field_bool_create(
3458 bt_trace_class *trace_class,
3459 bt_field_class *optional_field_class,
3460 bt_field_class *selector_field_class);
3461
3462 /*!
3463 @brief
3464 Sets whether or not the selector of the \bt_opt_fc (with a boolean
3465 selector field) \bt_p{field_class} is reversed.
3466
3467 See the \ref api-tir-fc-opt-prop-sel-rev "selector is reversed?"
3468 property.
3469
3470 @param[in] field_class
3471 Option field class of which to set whether or not its selector
3472 is reversed.
3473 @param[in] selector_is_reversed
3474 #BT_TRUE to make \bt_p{field_class} have a reversed selector.
3475
3476 @bt_pre_not_null{field_class}
3477 @bt_pre_hot{field_class}
3478 @bt_pre_is_opt_wbs_fc{field_class}
3479
3480 @sa bt_field_class_option_with_selector_field_bool_selector_is_reversed() &mdash;
3481 Returns whether or not the selector of an option field class (with
3482 a boolean selector field) is reversed.
3483 */
3484 extern void
3485 bt_field_class_option_with_selector_field_bool_set_selector_is_reversed(
3486 bt_field_class *field_class, bt_bool selector_is_reversed);
3487
3488 /*!
3489 @brief
3490 Returns whether or not the selector of the
3491 \bt_opt_fc (with a boolean selector field) is reversed.
3492
3493 See the \ref api-tir-fc-opt-prop-sel-rev "selector is reversed?"
3494 property.
3495
3496 @param[in] field_class
3497 Option field class of which to get whether or not its selector is
3498 reversed.
3499
3500 @returns
3501 #BT_TRUE if the selector of \bt_p{field_class} is reversed.
3502
3503 @bt_pre_not_null{field_class}
3504 @bt_pre_is_opt_wbs_fc{field_class}
3505
3506 @sa bt_field_class_option_with_selector_field_bool_set_selector_is_reversed() &mdash;
3507 Sets whether or not the selector of an option field class (with
3508 a boolean selector field) is reversed.
3509 */
3510 extern bt_bool
3511 bt_field_class_option_with_selector_field_bool_selector_is_reversed(
3512 const bt_field_class *field_class);
3513
3514 /*! @} */
3515
3516 /*!
3517 @name Option field class with an unsigned integer selector field
3518 @{
3519 */
3520
3521 /*!
3522 @brief
3523 Creates an \bt_opt_fc (with an unsigned integer selector field)
3524 having the optional field class \bt_p{optional_field_class} from the
3525 trace class \bt_p{trace_class}.
3526
3527 On success, the returned option field class has the following property
3528 values:
3529
3530 <table>
3531 <tr>
3532 <th>Property
3533 <th>Value
3534 <tr>
3535 <td>\ref api-tir-fc-opt-prop-fc "Optional field class"
3536 <td>\bt_p{optional_field_class}
3537 <tr>
3538 <td>\ref api-tir-fc-opt-prop-sel-fp "Selector field path"
3539 <td>
3540 \em None (this property becomes available when the returned field
3541 class becomes part of an \bt_ev_cls or of a \bt_stream_cls)
3542 <tr>
3543 <td>\ref api-tir-fc-opt-prop-uint-rs "Selector's unsigned integer ranges"
3544 <td>\bt_p{ranges}
3545 <tr>
3546 <td>\ref api-tir-fc-prop-user-attrs "User attributes"
3547 <td>Empty \bt_map_val
3548 </table>
3549
3550 @param[in] trace_class
3551 Trace class from which to create an option field class.
3552 @param[in] optional_field_class
3553 Class of the optional fields of the instances of the option field
3554 class to create.
3555 @param[in] selector_field_class
3556 Linked selector field class of the option field class to create.
3557 @param[in] ranges
3558 Selector's unsigned integer ranges of the option field class to
3559 create.
3560
3561 @returns
3562 New option field class reference, or \c NULL on memory error.
3563
3564 @bt_pre_not_null{trace_class}
3565 @bt_pre_not_null{optional_field_class}
3566 @bt_pre_fc_not_in_tc{optional_field_class}
3567 @bt_pre_not_null{selector_field_class}
3568 @pre
3569 \bt_p{selector_field_class} is a \bt_uint_fc.
3570 @bt_pre_not_null{ranges}
3571 @pre
3572 \bt_p{ranges} contains one or more \bt_p_uint_rg.
3573
3574 @bt_post_success_frozen{optional_field_class}
3575 @bt_post_success_frozen{selector_field_class}
3576 @bt_post_success_frozen{ranges}
3577 */
3578 extern bt_field_class *
3579 bt_field_class_option_with_selector_field_integer_unsigned_create(
3580 bt_trace_class *trace_class,
3581 bt_field_class *optional_field_class,
3582 bt_field_class *selector_field_class,
3583 const bt_integer_range_set_unsigned *ranges);
3584
3585 /*!
3586 @brief
3587 Borrows the \bt_p_uint_rg from the \bt_opt_fc (with an unsigned
3588 integer selector field) \bt_p{field_class}.
3589
3590 See the
3591 \ref api-tir-fc-opt-prop-uint-rs "selector's unsigned integer ranges"
3592 property.
3593
3594 @param[in] field_class
3595 Option field class from which to borrow the unsigned integer ranges.
3596
3597 @returns
3598 Unsigned integer ranges of \bt_p{field_class}.
3599
3600 @bt_pre_not_null{field_class}
3601 @bt_pre_is_opt_wuis_fc{field_class}
3602 */
3603 extern const bt_integer_range_set_unsigned *
3604 bt_field_class_option_with_selector_field_integer_unsigned_borrow_selector_ranges_const(
3605 const bt_field_class *field_class);
3606
3607 /*! @} */
3608
3609 /*!
3610 @name Option field class with a signed integer selector field
3611 @{
3612 */
3613
3614 /*!
3615 @brief
3616 Creates an \bt_opt_fc (with a signed integer selector field)
3617 having the optional field class \bt_p{optional_field_class} from the
3618 trace class \bt_p{trace_class}.
3619
3620 On success, the returned option field class has the following property
3621 values:
3622
3623 <table>
3624 <tr>
3625 <th>Property
3626 <th>Value
3627 <tr>
3628 <td>\ref api-tir-fc-opt-prop-fc "Optional field class"
3629 <td>\bt_p{optional_field_class}
3630 <tr>
3631 <td>\ref api-tir-fc-opt-prop-sel-fp "Selector field path"
3632 <td>
3633 \em None (this property becomes available when the returned field
3634 class becomes part of an \bt_ev_cls or of a \bt_stream_cls)
3635 <tr>
3636 <td>\ref api-tir-fc-opt-prop-sint-rs "Selector's signed integer ranges"
3637 <td>\bt_p{ranges}
3638 <tr>
3639 <td>\ref api-tir-fc-prop-user-attrs "User attributes"
3640 <td>Empty \bt_map_val
3641 </table>
3642
3643 @param[in] trace_class
3644 Trace class from which to create an option field class.
3645 @param[in] optional_field_class
3646 Class of the optional fields of the instances of the option field
3647 class to create.
3648 @param[in] selector_field_class
3649 Linked selector field class of the option field class to create.
3650 @param[in] ranges
3651 Selector's signed integer ranges of the option field class to
3652 create.
3653
3654 @returns
3655 New option field class reference, or \c NULL on memory error.
3656
3657 @bt_pre_not_null{trace_class}
3658 @bt_pre_not_null{optional_field_class}
3659 @bt_pre_fc_not_in_tc{optional_field_class}
3660 @bt_pre_not_null{selector_field_class}
3661 @pre
3662 \bt_p{selector_field_class} is a \bt_uint_fc.
3663 @bt_pre_not_null{ranges}
3664 @pre
3665 \bt_p{ranges} contains one or more \bt_p_uint_rg.
3666
3667 @bt_post_success_frozen{optional_field_class}
3668 @bt_post_success_frozen{selector_field_class}
3669 @bt_post_success_frozen{ranges}
3670 */
3671 extern bt_field_class *
3672 bt_field_class_option_with_selector_field_integer_signed_create(
3673 bt_trace_class *trace_class,
3674 bt_field_class *optional_field_class,
3675 bt_field_class *selector_field_class,
3676 const bt_integer_range_set_signed *ranges);
3677
3678 /*!
3679 @brief
3680 Borrows the \bt_p_sint_rg from the \bt_opt_fc (with a signed
3681 integer selector field) \bt_p{field_class}.
3682
3683 See the
3684 \ref api-tir-fc-opt-prop-sint-rs "selector's signed integer ranges"
3685 property.
3686
3687 @param[in] field_class
3688 Option field class from which to borrow the signed integer ranges.
3689
3690 @returns
3691 Signed integer ranges of \bt_p{field_class}.
3692
3693 @bt_pre_not_null{field_class}
3694 @bt_pre_is_opt_wsis_fc{field_class}
3695 */
3696 extern const bt_integer_range_set_signed *
3697 bt_field_class_option_with_selector_field_integer_signed_borrow_selector_ranges_const(
3698 const bt_field_class *field_class);
3699
3700 /*! @} */
3701
3702 /*!
3703 @name Variant field class
3704 @{
3705 */
3706
3707 /*!
3708 @brief
3709 Creates a \bt_var_fc from the trace class \bt_p{trace_class}.
3710
3711 If \bt_p{selector_field_class} is not \c NULL, then the created variant
3712 field class has a linked selector field class.
3713 See
3714 \ref api-tir-fc-link "Field classes with links to other field classes"
3715 to learn more.
3716
3717 On success, the returned variant field class has the following
3718 property values:
3719
3720 <table>
3721 <tr>
3722 <th>Property
3723 <th>Value
3724 <tr>
3725 <td>\ref api-tir-fc-var-prop-sel-fp "Selector field path"
3726 <td>
3727 \em None (if \bt_p{selector_field_class} is not \c NULL, this
3728 property becomes available when the returned field class becomes
3729 part of an \bt_ev_cls or of a \bt_stream_cls)
3730 <tr>
3731 <td>\ref api-tir-fc-var-prop-opts "Options"
3732 <td>\em None
3733 <tr>
3734 <td>\ref api-tir-fc-prop-user-attrs "User attributes"
3735 <td>Empty \bt_map_val
3736 </table>
3737
3738 @param[in] trace_class
3739 Trace class from which to create a variant field class.
3740 @param[in] selector_field_class
3741 @parblock
3742 Linked selector field class of the variant field class to create.
3743
3744 Can be \c NULL.
3745 @endparblock
3746
3747 @returns
3748 New variant field class reference, or \c NULL on memory error.
3749
3750 @bt_pre_not_null{trace_class}
3751 @pre
3752 <strong>If \bt_p{selector_field_class} is not \c NULL</strong>,
3753 \bt_p{selector_field_class} is an \bt_int_fc.
3754
3755 @bt_post_success_frozen{element_field_class}
3756 @bt_post_success_frozen{selector_field_class}
3757 */
3758 extern bt_field_class *bt_field_class_variant_create(
3759 bt_trace_class *trace_class,
3760 bt_field_class *selector_field_class);
3761
3762 /*!
3763 @brief
3764 Returns the number of options contained in the \bt_var_fc
3765 \bt_p{field_class}.
3766
3767 See the \ref api-tir-fc-var-prop-opts "options" property.
3768
3769 @param[in] field_class
3770 Variant field class of which to get the number of contained
3771 options.
3772
3773 @returns
3774 Number of contained options in \bt_p{field_class}.
3775
3776 @bt_pre_not_null{field_class}
3777 @bt_pre_is_var_fc{field_class}
3778 */
3779 extern uint64_t bt_field_class_variant_get_option_count(
3780 const bt_field_class *field_class);
3781
3782 /*!
3783 @brief
3784 Borrows the option at index \bt_p{index} from the
3785 \bt_var_fc \bt_p{field_class}.
3786
3787 See the \ref api-tir-fc-var-prop-opts "options" property.
3788
3789 @param[in] field_class
3790 Variant field class from which to borrow the option at
3791 index \bt_p{index}.
3792 @param[in] index
3793 Index of the option to borrow from \bt_p{field_class}.
3794
3795 @returns
3796 @parblock
3797 \em Borrowed reference of the option of
3798 \bt_p{field_class} at index \bt_p{index}.
3799
3800 The returned pointer remains valid as long as \bt_p{field_class}
3801 is not modified.
3802 @endparblock
3803
3804 @bt_pre_not_null{field_class}
3805 @bt_pre_is_var_fc{field_class}
3806 @pre
3807 \bt_p{index} is less than the number of options in
3808 \bt_p{field_class} (as returned by
3809 bt_field_class_variant_get_option_count()).
3810
3811 @sa bt_field_class_variant_get_option_count() &mdash;
3812 Returns the number of options contained in a variant field class.
3813 @sa bt_field_class_variant_borrow_option_by_index_const() &mdash;
3814 \c const version of this function.
3815 */
3816 extern bt_field_class_variant_option *
3817 bt_field_class_variant_borrow_option_by_index(
3818 bt_field_class *field_class, uint64_t index);
3819
3820 /*!
3821 @brief
3822 Borrows the option at index \bt_p{index} from the
3823 \bt_var_fc \bt_p{field_class} (\c const version).
3824
3825 See bt_field_class_variant_borrow_option_by_index().
3826 */
3827 extern const bt_field_class_variant_option *
3828 bt_field_class_variant_borrow_option_by_index_const(
3829 const bt_field_class *field_class, uint64_t index);
3830
3831 /*!
3832 @brief
3833 Borrows the option having the name \bt_p{name} from the
3834 \bt_var_fc \bt_p{field_class}.
3835
3836 See the \ref api-tir-fc-var-prop-opts "options" property.
3837
3838 If there's no option having the name \bt_p{name} in
3839 \bt_p{field_class}, this function returns \c NULL.
3840
3841 @param[in] field_class
3842 Variant field class from which to borrow the option having the
3843 name \bt_p{name}.
3844 @param[in] name
3845 Name of the option to borrow from \bt_p{field_class}.
3846
3847 @returns
3848 @parblock
3849 \em Borrowed reference of the option of
3850 \bt_p{field_class} having the name \bt_p{name}, or \c NULL
3851 if none.
3852
3853 The returned pointer remains valid as long as \bt_p{field_class}
3854 is not modified.
3855 @endparblock
3856
3857 @bt_pre_not_null{field_class}
3858 @bt_pre_is_var_fc{field_class}
3859 @bt_pre_not_null{name}
3860
3861 @sa bt_field_class_variant_borrow_option_by_name_const() &mdash;
3862 \c const version of this function.
3863 */
3864 extern bt_field_class_variant_option *
3865 bt_field_class_variant_borrow_option_by_name(
3866 bt_field_class *field_class, const char *name);
3867
3868 /*!
3869 @brief
3870 Borrows the option having the name \bt_p{name} from the
3871 \bt_var_fc \bt_p{field_class} (\c const version).
3872
3873 See bt_field_class_variant_borrow_option_by_name().
3874 */
3875 extern const bt_field_class_variant_option *
3876 bt_field_class_variant_borrow_option_by_name_const(
3877 const bt_field_class *field_class, const char *name);
3878
3879 /*! @} */
3880
3881 /*!
3882 @name Variant field class option
3883 @{
3884 */
3885
3886 /*!
3887 @typedef struct bt_field_class_variant_option bt_field_class_variant_option;
3888
3889 @brief
3890 Variant field class option.
3891 */
3892
3893 /*!
3894 @brief
3895 Returns the name of the \bt_var_fc option \bt_p{option}.
3896
3897 See the \ref api-tir-fc-var-prop-opts "options" property.
3898
3899 @param[in] option
3900 Variant field class option of which to get the name.
3901
3902 @returns
3903 @parblock
3904 Name of \bt_p{option}.
3905
3906 The returned pointer remains valid as long as \bt_p{option} exists.
3907 @endparblock
3908
3909 @bt_pre_not_null{option}
3910 */
3911 extern const char *bt_field_class_variant_option_get_name(
3912 const bt_field_class_variant_option *option);
3913
3914 /*!
3915 @brief
3916 Borrows the field class from the \bt_var_fc option
3917 \bt_p{option}.
3918
3919 See the \ref api-tir-fc-var-prop-opts "options" property.
3920
3921 @param[in] option
3922 Variant field class option from which to borrow the field class.
3923
3924 @returns
3925 Field class of \bt_p{option}.
3926
3927 @bt_pre_not_null{option}
3928
3929 @sa bt_field_class_variant_option_borrow_field_class_const() &mdash;
3930 \c const version of this function.
3931 */
3932 extern bt_field_class *bt_field_class_variant_option_borrow_field_class(
3933 bt_field_class_variant_option *option);
3934
3935 /*!
3936 @brief
3937 Borrows the field class from the \bt_var_fc option
3938 \bt_p{option} (\c const version).
3939
3940 See bt_field_class_variant_option_borrow_field_class().
3941 */
3942 extern const bt_field_class *
3943 bt_field_class_variant_option_borrow_field_class_const(
3944 const bt_field_class_variant_option *option);
3945
3946 /*!
3947 @brief
3948 Sets the user attributes of the \bt_var_fc option \bt_p{option}
3949 to \bt_p{user_attributes}.
3950
3951 See the \ref api-tir-fc-var-prop-opts "options" property.
3952
3953 @note
3954 When you append an option to a variant field class with
3955 bt_field_class_variant_without_selector_append_option(),
3956 bt_field_class_variant_with_selector_field_integer_unsigned_append_option(),
3957 or
3958 bt_field_class_variant_with_selector_field_integer_signed_append_option(),
3959 the option's initial user attributes is an empty \bt_map_val.
3960 Therefore you can borrow it with
3961 bt_field_class_variant_option_borrow_user_attributes() and fill it
3962 directly instead of setting a new one with this function.
3963
3964 @param[in] option
3965 Variant field class option of which to set the user attributes to
3966 \bt_p{user_attributes}.
3967 @param[in] user_attributes
3968 New user attributes of \bt_p{option}.
3969
3970 @bt_pre_not_null{option}
3971 @bt_pre_hot{option}
3972 @bt_pre_not_null{user_attributes}
3973 @bt_pre_is_map_val{user_attributes}
3974
3975 @sa bt_field_class_variant_option_borrow_user_attributes() &mdash;
3976 Borrows the user attributes of a variant field class option.
3977 */
3978 extern void bt_field_class_variant_option_set_user_attributes(
3979 bt_field_class_variant_option *option,
3980 const bt_value *user_attributes);
3981
3982 /*!
3983 @brief
3984 Borrows the user attributes of the \bt_var_fc option \bt_p{option}.
3985
3986 See the \ref api-tir-fc-var-prop-opts "options" property.
3987
3988 @note
3989 When you append an option to a variant field class with
3990 bt_field_class_variant_without_selector_append_option(),
3991 bt_field_class_variant_with_selector_field_integer_unsigned_append_option(),
3992 or
3993 bt_field_class_variant_with_selector_field_integer_signed_append_option(),
3994 the option's initial user attributes is an empty \bt_map_val.
3995
3996 @param[in] option
3997 Variant field class option from which to borrow the user
3998 attributes.
3999
4000 @returns
4001 User attributes of \bt_p{option} (a \bt_map_val).
4002
4003 @bt_pre_not_null{option}
4004
4005 @sa bt_field_class_variant_option_set_user_attributes() &mdash;
4006 Sets the user attributes of a variant field class option.
4007 @sa bt_field_class_variant_option_borrow_user_attributes_const() &mdash;
4008 \c const version of this function.
4009 */
4010 extern bt_value *bt_field_class_variant_option_borrow_user_attributes(
4011 bt_field_class_variant_option *option);
4012
4013 /*!
4014 @brief
4015 Borrows the user attributes of the \bt_var_fc option \bt_p{option}
4016 (\c const version).
4017
4018 See bt_field_class_variant_option_borrow_user_attributes().
4019 */
4020 extern const bt_value *bt_field_class_variant_option_borrow_user_attributes_const(
4021 const bt_field_class_variant_option *option);
4022
4023 /*! @} */
4024
4025 /*!
4026 @name Variant field class without a selector field
4027 @{
4028 */
4029
4030 /*!
4031 @brief
4032 Status codes for
4033 bt_field_class_variant_without_selector_append_option().
4034 */
4035 typedef enum bt_field_class_variant_without_selector_append_option_status {
4036 /*!
4037 @brief
4038 Success.
4039 */
4040 BT_FIELD_CLASS_VARIANT_WITHOUT_SELECTOR_FIELD_APPEND_OPTION_STATUS_OK = __BT_FUNC_STATUS_OK,
4041
4042 /*!
4043 @brief
4044 Out of memory.
4045 */
4046 BT_FIELD_CLASS_VARIANT_WITHOUT_SELECTOR_FIELD_APPEND_OPTION_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR,
4047 } bt_field_class_variant_without_selector_append_option_status;
4048
4049 /*!
4050 @brief
4051 Appends an option to the \bt_var_fc (without a selector field)
4052 \bt_p{field_class} having the name \bt_p{name} and the
4053 field class \bt_p{option_field_class}.
4054
4055 See the \ref api-tir-fc-var-prop-opts "options" property.
4056
4057 @param[in] field_class
4058 Variant field class to which to append an option having
4059 the name \bt_p{name} and the field class \bt_p{option_field_class}.
4060 @param[in] name
4061 Name of the option to append to \bt_p{field_class} (copied).
4062 @param[in] option_field_class
4063 Field class of the option to append to \bt_p{field_class}.
4064
4065 @retval #BT_FIELD_CLASS_VARIANT_WITHOUT_SELECTOR_FIELD_APPEND_OPTION_STATUS_OK
4066 Success.
4067 @retval #BT_FIELD_CLASS_VARIANT_WITHOUT_SELECTOR_FIELD_APPEND_OPTION_STATUS_MEMORY_ERROR
4068 Out of memory.
4069
4070 @bt_pre_not_null{field_class}
4071 @bt_pre_hot{field_class}
4072 @bt_pre_is_var_wos_fc{field_class}
4073 @pre
4074 \bt_p{field_class} has no option with the name \bt_p{name}.
4075 @bt_pre_not_null{name}
4076 @bt_pre_not_null{option_field_class}
4077 @bt_pre_fc_not_in_tc{option_field_class}
4078
4079 @bt_post_success_frozen{option_field_class}
4080 */
4081 extern bt_field_class_variant_without_selector_append_option_status
4082 bt_field_class_variant_without_selector_append_option(
4083 bt_field_class *field_class, const char *name,
4084 bt_field_class *option_field_class);
4085
4086 /*! @} */
4087
4088 /*!
4089 @name Variant field class with a selector field
4090 @{
4091 */
4092
4093 /*!
4094 @brief
4095 Status codes for
4096 bt_field_class_variant_with_selector_field_integer_unsigned_append_option()
4097 and
4098 bt_field_class_variant_with_selector_field_integer_signed_append_option().
4099 */
4100 typedef enum bt_field_class_variant_with_selector_field_integer_append_option_status {
4101 /*!
4102 @brief
4103 Success.
4104 */
4105 BT_FIELD_CLASS_VARIANT_WITH_SELECTOR_FIELD_APPEND_OPTION_STATUS_OK = __BT_FUNC_STATUS_OK,
4106
4107 /*!
4108 @brief
4109 Out of memory.
4110 */
4111 BT_FIELD_CLASS_VARIANT_WITH_SELECTOR_FIELD_APPEND_OPTION_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR,
4112 } bt_field_class_variant_with_selector_field_integer_append_option_status;
4113
4114 /*!
4115 @brief
4116 Borrows the selector field path from the \bt_var_fc (with a selector
4117 field) \bt_p{field_class}.
4118
4119 See the \ref api-tir-fc-var-prop-sel-fp "selector field path" property.
4120
4121 This property is only available when a \bt_struct_fc containing
4122 (recursively) \bt_p{field_class} is passed to one of:
4123
4124 - bt_stream_class_set_packet_context_field_class()
4125 - bt_stream_class_set_event_common_context_field_class()
4126 - bt_event_class_set_specific_context_field_class()
4127 - bt_event_class_set_payload_field_class()
4128
4129 In the meantime, this function returns \c NULL.
4130
4131 @param[in] field_class
4132 Variant field class from which to borrow the selector field path.
4133
4134 @returns
4135 Selector field path of \bt_p{field_class}.
4136
4137 @bt_pre_not_null{field_class}
4138 @bt_pre_is_var_ws_fc{field_class}
4139 */
4140 extern const bt_field_path *
4141 bt_field_class_variant_with_selector_field_borrow_selector_field_path_const(
4142 const bt_field_class *field_class);
4143
4144 /*! @} */
4145
4146 /*!
4147 @name Variant field class with an unsigned integer selector field
4148 @{
4149 */
4150
4151 /*!
4152 @brief
4153 Appends an option to the \bt_var_fc (with an unsigned integer
4154 selector field) \bt_p{field_class} having the name \bt_p{name},
4155 the field class \bt_p{option_field_class}, and the
4156 \bt_p_uint_rg \bt_p{ranges}.
4157
4158 See the \ref api-tir-fc-var-prop-opts "options" property.
4159
4160 @param[in] field_class
4161 Variant field class to which to append an option having
4162 the name \bt_p{name}, the field class \bt_p{option_field_class},
4163 and the unsigned integer ranges \bt_p{ranges}.
4164 @param[in] name
4165 Name of the option to append to \bt_p{field_class} (copied).
4166 @param[in] option_field_class
4167 Field class of the option to append to \bt_p{field_class}.
4168 @param[in] ranges
4169 Unsigned integer ranges of the option to append to
4170 \bt_p{field_class}.
4171
4172 @retval #BT_FIELD_CLASS_VARIANT_WITH_SELECTOR_FIELD_APPEND_OPTION_STATUS_OK
4173 Success.
4174 @retval #BT_FIELD_CLASS_VARIANT_WITH_SELECTOR_FIELD_APPEND_OPTION_STATUS_MEMORY_ERROR
4175 Out of memory.
4176
4177 @bt_pre_not_null{field_class}
4178 @bt_pre_hot{field_class}
4179 @bt_pre_is_var_wuis_fc{field_class}
4180 @pre
4181 \bt_p{field_class} has no option with the name \bt_p{name}.
4182 @bt_pre_not_null{name}
4183 @bt_pre_not_null{option_field_class}
4184 @bt_pre_fc_not_in_tc{option_field_class}
4185 @bt_pre_not_null{Ĺ—anges}
4186 @pre
4187 \bt_p{ranges} contains one or more unsigned integer ranges.
4188 @pre
4189 The unsigned integer ranges in \bt_p{ranges} do not overlap
4190 any unsigned integer range of any existing option in
4191 \bt_p{field_class}.
4192
4193 @bt_post_success_frozen{option_field_class}
4194 */
4195 extern bt_field_class_variant_with_selector_field_integer_append_option_status
4196 bt_field_class_variant_with_selector_field_integer_unsigned_append_option(
4197 bt_field_class *field_class, const char *name,
4198 bt_field_class *option_field_class,
4199 const bt_integer_range_set_unsigned *ranges);
4200
4201 /*!
4202 @brief
4203 Borrows the option at index \bt_p{index} from the
4204 \bt_var_fc (with an unsigned integer selector field)
4205 \bt_p{field_class}.
4206
4207 See the \ref api-tir-fc-var-prop-opts "options" property.
4208
4209 @param[in] field_class
4210 Variant field class from which to borrow the option at
4211 index \bt_p{index}.
4212 @param[in] index
4213 Index of the option to borrow from \bt_p{field_class}.
4214
4215 @returns
4216 @parblock
4217 \em Borrowed reference of the option of
4218 \bt_p{field_class} at index \bt_p{index}.
4219
4220 The returned pointer remains valid as long as \bt_p{field_class}
4221 is not modified.
4222 @endparblock
4223
4224 @bt_pre_not_null{field_class}
4225 @bt_pre_is_var_wuis_fc{field_class}
4226 @pre
4227 \bt_p{index} is less than the number of options in
4228 \bt_p{field_class} (as returned by
4229 bt_field_class_variant_get_option_count()).
4230
4231 @sa bt_field_class_variant_get_option_count() &mdash;
4232 Returns the number of options contained in a variant field class.
4233 */
4234 extern const bt_field_class_variant_with_selector_field_integer_unsigned_option *
4235 bt_field_class_variant_with_selector_field_integer_unsigned_borrow_option_by_index_const(
4236 const bt_field_class *field_class, uint64_t index);
4237
4238 /*!
4239 @brief
4240 Borrows the option having the name \bt_p{name} from the
4241 \bt_var_fc (with an unsigned integer selector field)
4242 \bt_p{field_class}.
4243
4244 See the \ref api-tir-fc-var-prop-opts "options" property.
4245
4246 If there's no option having the name \bt_p{name} in
4247 \bt_p{field_class}, this function returns \c NULL.
4248
4249 @param[in] field_class
4250 Variant field class from which to borrow the option having the
4251 name \bt_p{name}.
4252 @param[in] name
4253 Name of the option to borrow from \bt_p{field_class}.
4254
4255 @returns
4256 @parblock
4257 \em Borrowed reference of the option of
4258 \bt_p{field_class} having the name \bt_p{name}, or \c NULL
4259 if none.
4260
4261 The returned pointer remains valid as long as \bt_p{field_class}
4262 is not modified.
4263 @endparblock
4264
4265 @bt_pre_not_null{field_class}
4266 @bt_pre_is_var_wuis_fc{field_class}
4267 @bt_pre_not_null{name}
4268
4269 @sa bt_field_class_variant_borrow_option_by_name_const() &mdash;
4270 Borrows an option by name from a variant field class.
4271 */
4272 extern const bt_field_class_variant_with_selector_field_integer_unsigned_option *
4273 bt_field_class_variant_with_selector_field_integer_unsigned_borrow_option_by_name_const(
4274 const bt_field_class *field_class, const char *name);
4275
4276 /*! @} */
4277
4278 /*!
4279 @name Variant field class (with an unsigned integer selector field) option
4280 @{
4281 */
4282
4283 /*!
4284 @typedef struct bt_field_class_variant_with_selector_field_integer_unsigned_option bt_field_class_variant_with_selector_field_integer_unsigned_option;
4285
4286 @brief
4287 Variant field class (with an unsigned integer selector field) option.
4288 */
4289
4290 /*!
4291 @brief
4292 Borrows the \bt_p_uint_rg from the \bt_var_fc (with an unsigned
4293 integer selector field) option \bt_p{option}.
4294
4295 See the \ref api-tir-fc-var-prop-opts "options" property.
4296
4297 @param[in] option
4298 Variant field class option from which to borrow the
4299 unsigned integer ranges.
4300
4301 @returns
4302 Unsigned integer ranges of \bt_p{option}.
4303
4304 @bt_pre_not_null{option}
4305 */
4306 extern const bt_integer_range_set_unsigned *
4307 bt_field_class_variant_with_selector_field_integer_unsigned_option_borrow_ranges_const(
4308 const bt_field_class_variant_with_selector_field_integer_unsigned_option *option);
4309
4310 /*!
4311 @brief
4312 \ref api-fund-c-typing "Upcasts" the \bt_var_fc (with an
4313 unsigned integer selector field) option \bt_p{option} to the
4314 common #bt_field_class_variant_option type.
4315
4316 See the \ref api-tir-fc-var-prop-opts "options" property.
4317
4318 @param[in] option
4319 @parblock
4320 Variant field class option to upcast.
4321
4322 Can be \c NULL.
4323 @endparblock
4324
4325 @returns
4326 \bt_p{option} as a common variant field class option.
4327 */
4328 static inline
4329 const bt_field_class_variant_option *
4330 bt_field_class_variant_with_selector_field_integer_unsigned_option_as_option_const(
4331 const bt_field_class_variant_with_selector_field_integer_unsigned_option *option)
4332 {
4333 return __BT_UPCAST_CONST(bt_field_class_variant_option, option);
4334 }
4335
4336 /*! @} */
4337
4338 /*!
4339 @name Variant field class with a signed integer selector field
4340 @{
4341 */
4342
4343 /*!
4344 @brief
4345 Appends an option to the \bt_var_fc (with a signed integer
4346 selector field) \bt_p{field_class} having the name \bt_p{name},
4347 the field class \bt_p{option_field_class}, and the
4348 \bt_p_sint_rg \bt_p{ranges}.
4349
4350 See the \ref api-tir-fc-var-prop-opts "options" property.
4351
4352 @param[in] field_class
4353 Variant field class to which to append an option having
4354 the name \bt_p{name} and the field class \bt_p{option_field_class},
4355 and the signed integer ranges \bt_p{ranges}.
4356 @param[in] name
4357 Name of the option to append to \bt_p{field_class} (copied).
4358 @param[in] option_field_class
4359 Field class of the option to append to \bt_p{field_class}.
4360 @param[in] ranges
4361 Signed integer ranges of the option to append to
4362 \bt_p{field_class}.
4363
4364 @retval #BT_FIELD_CLASS_VARIANT_WITH_SELECTOR_FIELD_APPEND_OPTION_STATUS_OK
4365 Success.
4366 @retval #BT_FIELD_CLASS_VARIANT_WITH_SELECTOR_FIELD_APPEND_OPTION_STATUS_MEMORY_ERROR
4367 Out of memory.
4368
4369 @bt_pre_not_null{field_class}
4370 @bt_pre_hot{field_class}
4371 @bt_pre_is_var_wsis_fc{field_class}
4372 @pre
4373 \bt_p{field_class} has no option with the name \bt_p{name}.
4374 @bt_pre_not_null{name}
4375 @bt_pre_not_null{option_field_class}
4376 @bt_pre_fc_not_in_tc{option_field_class}
4377 @bt_pre_not_null{Ĺ—anges}
4378 @pre
4379 \bt_p{ranges} contains one or more signed integer ranges.
4380 @pre
4381 The signed integer ranges in \bt_p{ranges} do not overlap with
4382 any signed integer range of any existing option in
4383 \bt_p{field_class}.
4384
4385 @bt_post_success_frozen{option_field_class}
4386 */
4387 extern bt_field_class_variant_with_selector_field_integer_append_option_status
4388 bt_field_class_variant_with_selector_field_integer_signed_append_option(
4389 bt_field_class *field_class, const char *name,
4390 bt_field_class *option_field_class,
4391 const bt_integer_range_set_signed *ranges);
4392
4393 /*!
4394 @brief
4395 Borrows the option at index \bt_p{index} from the
4396 \bt_var_fc (with a signed integer selector field)
4397 \bt_p{field_class}.
4398
4399 See the \ref api-tir-fc-var-prop-opts "options" property.
4400
4401 @param[in] field_class
4402 Variant field class from which to borrow the option at
4403 index \bt_p{index}.
4404 @param[in] index
4405 Index of the option to borrow from \bt_p{field_class}.
4406
4407 @returns
4408 @parblock
4409 \em Borrowed reference of the option of
4410 \bt_p{field_class} at index \bt_p{index}.
4411
4412 The returned pointer remains valid as long as \bt_p{field_class}
4413 is not modified.
4414 @endparblock
4415
4416 @bt_pre_not_null{field_class}
4417 @bt_pre_is_var_wsis_fc{field_class}
4418 @pre
4419 \bt_p{index} is less than the number of options in
4420 \bt_p{field_class} (as returned by
4421 bt_field_class_variant_get_option_count()).
4422
4423 @sa bt_field_class_variant_get_option_count() &mdash;
4424 Returns the number of options contained in a variant field class.
4425 */
4426 extern const bt_field_class_variant_with_selector_field_integer_signed_option *
4427 bt_field_class_variant_with_selector_field_integer_signed_borrow_option_by_index_const(
4428 const bt_field_class *field_class, uint64_t index);
4429
4430 /*!
4431 @brief
4432 Borrows the option having the name \bt_p{name} from the
4433 \bt_var_fc (with a signed integer selector field)
4434 \bt_p{field_class}.
4435
4436 See the \ref api-tir-fc-var-prop-opts "options" property.
4437
4438 If there's no option having the name \bt_p{name} in
4439 \bt_p{field_class}, this function returns \c NULL.
4440
4441 @param[in] field_class
4442 Variant field class from which to borrow the option having the
4443 name \bt_p{name}.
4444 @param[in] name
4445 Name of the option to borrow from \bt_p{field_class}.
4446
4447 @returns
4448 @parblock
4449 \em Borrowed reference of the option of
4450 \bt_p{field_class} having the name \bt_p{name}, or \c NULL
4451 if none.
4452
4453 The returned pointer remains valid as long as \bt_p{field_class}
4454 is not modified.
4455 @endparblock
4456
4457 @bt_pre_not_null{field_class}
4458 @bt_pre_is_var_wsis_fc{field_class}
4459 @bt_pre_not_null{name}
4460
4461 @sa bt_field_class_variant_borrow_option_by_name_const() &mdash;
4462 Borrows an option by name from a variant field class.
4463 */
4464 extern const bt_field_class_variant_with_selector_field_integer_signed_option *
4465 bt_field_class_variant_with_selector_field_integer_signed_borrow_option_by_name_const(
4466 const bt_field_class *field_class, const char *name);
4467
4468 /*! @} */
4469
4470 /*!
4471 @name Variant field class (with a signed integer selector field) option
4472 @{
4473 */
4474
4475 /*!
4476 @typedef struct bt_field_class_variant_with_selector_field_integer_signed_option bt_field_class_variant_with_selector_field_integer_signed_option;
4477
4478 @brief
4479 Variant field class (with a signed integer selector field) option.
4480 */
4481
4482 /*!
4483 @brief
4484 Borrows the \bt_p_sint_rg from the \bt_var_fc (with a signed
4485 integer selector field) option \bt_p{option}.
4486
4487 See the \ref api-tir-fc-var-prop-opts "options" property.
4488
4489 @param[in] option
4490 Variant field class option from which to borrow the
4491 signed integer ranges.
4492
4493 @returns
4494 Signed integer ranges of \bt_p{option}.
4495
4496 @bt_pre_not_null{option}
4497 */
4498 extern const bt_integer_range_set_signed *
4499 bt_field_class_variant_with_selector_field_integer_signed_option_borrow_ranges_const(
4500 const bt_field_class_variant_with_selector_field_integer_signed_option *option);
4501
4502 /*!
4503 @brief
4504 \ref api-fund-c-typing "Upcasts" the \bt_var_fc (with a signed
4505 integer selector field) option \bt_p{option} to the
4506 common #bt_field_class_variant_option type.
4507
4508 See the \ref api-tir-fc-var-prop-opts "options" property.
4509
4510 @param[in] option
4511 @parblock
4512 Variant field class option to upcast.
4513
4514 Can be \c NULL.
4515 @endparblock
4516
4517 @returns
4518 \bt_p{option} as a common variant field class option.
4519 */
4520 static inline
4521 const bt_field_class_variant_option *
4522 bt_field_class_variant_with_selector_field_integer_signed_option_as_option_const(
4523 const bt_field_class_variant_with_selector_field_integer_signed_option *option)
4524 {
4525 return __BT_UPCAST_CONST(bt_field_class_variant_option, option);
4526 }
4527
4528 /*! @} */
4529
4530 /*!
4531 @name Reference count
4532 @{
4533 */
4534
4535 /*!
4536 @brief
4537 Increments the \ref api-fund-shared-object "reference count" of
4538 the field class \bt_p{field_class}.
4539
4540 @param[in] field_class
4541 @parblock
4542 Field class of which to increment the reference count.
4543
4544 Can be \c NULL.
4545 @endparblock
4546
4547 @sa bt_field_class_put_ref() &mdash;
4548 Decrements the reference count of a field class.
4549 */
4550 extern void bt_field_class_get_ref(const bt_field_class *field_class);
4551
4552 /*!
4553 @brief
4554 Decrements the \ref api-fund-shared-object "reference count" of
4555 the field class \bt_p{field_class}.
4556
4557 @param[in] field_class
4558 @parblock
4559 Field class of which to decrement the reference count.
4560
4561 Can be \c NULL.
4562 @endparblock
4563
4564 @sa bt_field_class_get_ref() &mdash;
4565 Increments the reference count of a field class.
4566 */
4567 extern void bt_field_class_put_ref(const bt_field_class *field_class);
4568
4569 /*!
4570 @brief
4571 Decrements the reference count of the field class
4572 \bt_p{_field_class}, and then sets \bt_p{_field_class} to \c NULL.
4573
4574 @param _field_class
4575 @parblock
4576 Field class of which to decrement the reference count.
4577
4578 Can contain \c NULL.
4579 @endparblock
4580
4581 @bt_pre_assign_expr{_field_class}
4582 */
4583 #define BT_FIELD_CLASS_PUT_REF_AND_RESET(_field_class) \
4584 do { \
4585 bt_field_class_put_ref(_field_class); \
4586 (_field_class) = NULL; \
4587 } while (0)
4588
4589 /*!
4590 @brief
4591 Decrements the reference count of the field class \bt_p{_dst}, sets
4592 \bt_p{_dst} to \bt_p{_src}, and then sets \bt_p{_src} to \c NULL.
4593
4594 This macro effectively moves a field class reference from the expression
4595 \bt_p{_src} to the expression \bt_p{_dst}, putting the existing
4596 \bt_p{_dst} reference.
4597
4598 @param _dst
4599 @parblock
4600 Destination expression.
4601
4602 Can contain \c NULL.
4603 @endparblock
4604 @param _src
4605 @parblock
4606 Source expression.
4607
4608 Can contain \c NULL.
4609 @endparblock
4610
4611 @bt_pre_assign_expr{_dst}
4612 @bt_pre_assign_expr{_src}
4613 */
4614 #define BT_FIELD_CLASS_MOVE_REF(_dst, _src) \
4615 do { \
4616 bt_field_class_put_ref(_dst); \
4617 (_dst) = (_src); \
4618 (_src) = NULL; \
4619 } while (0)
4620
4621 /*! @} */
4622
4623 /*! @} */
4624
4625 #ifdef __cplusplus
4626 }
4627 #endif
4628
4629 #endif /* BABELTRACE2_TRACE_IR_FIELD_CLASS_H */
This page took 0.191317 seconds and 3 git commands to generate.