Remove BT_CTF_FIELD_TYPE_UNTAGGED_VARIANT
[babeltrace.git] / include / babeltrace / ctf-ir / field-types.h
1 #ifndef BABELTRACE_CTF_IR_FIELD_TYPES_H
2 #define BABELTRACE_CTF_IR_FIELD_TYPES_H
3
4 /*
5 * BabelTrace - CTF IR: Event field types
6 *
7 * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
8 *
9 * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
10 *
11 * Permission is hereby granted, free of charge, to any person obtaining a copy
12 * of this software and associated documentation files (the "Software"), to deal
13 * in the Software without restriction, including without limitation the rights
14 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 * copies of the Software, and to permit persons to whom the Software is
16 * furnished to do so, subject to the following conditions:
17 *
18 * The above copyright notice and this permission notice shall be included in
19 * all copies or substantial portions of the Software.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 * SOFTWARE.
28 *
29 * The Common Trace Format (CTF) Specification is available at
30 * http://www.efficios.com/ctf
31 */
32
33 #include <stdint.h>
34 #include <stddef.h>
35
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39
40 /**
41 @defgroup ctfirfieldtypes CTF IR field types
42 @ingroup ctfir
43 @brief CTF IR field types.
44
45 @code
46 #include <babeltrace/ctf-ir/field-types.h>
47 @endcode
48
49 A CTF IR <strong><em>field type</em></strong> is a field type that you
50 can use to create concrete @fields.
51
52 You can create a @field object from a CTF IR field type object
53 with bt_ctf_field_create().
54
55 In the CTF IR hierarchy, you can set the root field types of three
56 objects:
57
58 - \ref ctfirtraceclass
59 - Trace packet header field type: bt_ctf_trace_set_packet_header_type().
60 - \ref ctfirstreamclass
61 - Stream packet context field type:
62 bt_ctf_stream_class_set_packet_context_type().
63 - Stream event header field type:
64 bt_ctf_stream_class_set_event_header_type().
65 - Stream event context field type:
66 bt_ctf_stream_class_set_event_context_type().
67 - \ref ctfireventclass
68 - Event context field type: bt_ctf_event_class_set_context_type().
69 - Event payload field type: bt_ctf_event_class_set_payload_type().
70
71 As of Babeltrace \btversion, those six previous "root" field types
72 \em must be @structft objects.
73
74 If, at any level within a given root field type, you add a @seqft or a
75 @varft, you do not need to specify its associated length
76 or tag field type: the length or tag string is enough for the Babeltrace
77 system to resolve the needed field type depending on where this
78 dynamic field type is located within the whole hierarchy. It is
79 guaranteed that this automatic resolving is performed for all the field
80 types contained in a given
81 \link ctfirstreamclass CTF IR stream class\endlink (and in its
82 children \link ctfireventclass CTF IR event classes\endlink) once you
83 add it to a \link ctfirtraceclass CTF IR trace class\endlink with
84 bt_ctf_trace_add_stream_class(). Once a stream class is the child of
85 a trace class, this automatic resolving is performed for the field
86 types of an event class when you add it with
87 bt_ctf_stream_class_add_event_class(). If the system cannot find a path
88 to a field in the hierarchy for a dynamic field type, the adding
89 function fails.
90
91 The standard CTF field types are:
92
93 <table>
94 <tr>
95 <th>Type ID
96 <th>CTF IR field type
97 <th>CTF IR field which you can create from this field type
98 </tr>
99 <tr>
100 <td>#BT_CTF_FIELD_TYPE_ID_INTEGER
101 <td>\ref ctfirintfieldtype
102 <td>\ref ctfirintfield
103 </tr>
104 <tr>
105 <td>#BT_CTF_FIELD_TYPE_ID_FLOAT
106 <td>\ref ctfirfloatfieldtype
107 <td>\ref ctfirfloatfield
108 </tr>
109 <tr>
110 <td>#BT_CTF_FIELD_TYPE_ID_ENUM
111 <td>\ref ctfirenumfieldtype
112 <td>\ref ctfirenumfield
113 </tr>
114 <tr>
115 <td>#BT_CTF_FIELD_TYPE_ID_STRING
116 <td>\ref ctfirstringfieldtype
117 <td>\ref ctfirstringfield
118 </tr>
119 <tr>
120 <td>#BT_CTF_FIELD_TYPE_ID_STRUCT
121 <td>\ref ctfirstructfieldtype
122 <td>\ref ctfirstructfield
123 </tr>
124 <tr>
125 <td>#BT_CTF_FIELD_TYPE_ID_ARRAY
126 <td>\ref ctfirarrayfieldtype
127 <td>\ref ctfirarrayfield
128 </tr>
129 <tr>
130 <td>#BT_CTF_FIELD_TYPE_ID_SEQUENCE
131 <td>\ref ctfirseqfieldtype
132 <td>\ref ctfirseqfield
133 </tr>
134 <tr>
135 <td>#BT_CTF_FIELD_TYPE_ID_VARIANT
136 <td>\ref ctfirvarfieldtype
137 <td>\ref ctfirvarfield
138 </tr>
139 </table>
140
141 Each field type has its own <strong>type ID</strong> (see
142 #bt_ctf_field_type_id). You get the type ID of a field type object
143 with bt_ctf_field_type_get_type_id().
144
145 You can get a deep copy of a field type with bt_ctf_field_type_copy().
146 This function resets, in the field type copy, the resolved field type
147 of the dynamic field types. The automatic resolving can be done again
148 when you eventually call bt_ctf_event_create(),
149 bt_ctf_stream_class_add_event_class(), or
150 bt_ctf_trace_add_stream_class().
151
152 You \em must always use bt_ctf_field_type_compare() to compare two
153 field types. Since some parts of the Babeltrace system can copy field
154 types behind the scenes, you \em cannot rely on a simple field type
155 pointer comparison.
156
157 As with any Babeltrace object, CTF IR field type objects have
158 <a href="https://en.wikipedia.org/wiki/Reference_counting">reference
159 counts</a>. See \ref refs to learn more about the reference counting
160 management of Babeltrace objects.
161
162 The following functions can \em freeze field type objects:
163
164 - bt_ctf_field_create() freezes its field type parameter.
165 - bt_ctf_stream_class_add_event_class(), if its
166 \link ctfirstreamclass CTF IR stream class\endlink parameter has a
167 \link ctfirtraceclass CTF IR trace class\endlink parent, freezes
168 the root field types of its
169 \link ctfireventclass CTF IR event class\endlink parameter.
170 - bt_ctf_trace_add_stream_class() freezes the root field types of the
171 whole trace class hierarchy (trace class, children stream classes,
172 and their children event classes).
173 - bt_ctf_writer_create_stream() freezes the root field types of the
174 whole CTF writer's trace class hierarchy.
175 - bt_ctf_event_create() freezes the root field types of its event class
176 parameter and of ther parent stream class of this event class.
177
178 You cannot modify a frozen field type object: it is considered
179 immutable, except for \link refs reference counting\endlink.
180
181 @sa ctfirfields
182 @sa \ref ctfirfieldtypesexamples "Examples"
183
184 @file
185 @brief CTF IR field types type and functions.
186 @sa ctfirfieldtypes
187
188 @addtogroup ctfirfieldtypes
189 @{
190 */
191
192 /**
193 @struct bt_ctf_field_type
194 @brief A CTF IR field type.
195 @sa ctfirfieldtypes
196 */
197 struct bt_ctf_field_type;
198 struct bt_ctf_event_class;
199 struct bt_ctf_event;
200 struct bt_ctf_field;
201 struct bt_ctf_field_path;
202 struct bt_ctf_field_type_enumeration_mapping_iterator;
203
204 /** @cond DOCUMENT */
205
206 /*
207 * Babeltrace 1.x enumerations that were also used in CTF writer's API.
208 * They are left here for backward compatibility reasons, but
209 * enum bt_ctf_field_type_id and enum bt_ctf_string_encoding should be used
210 * in new code. Both new enumerations are compatible with their legacy
211 * counterpart.
212 */
213 enum ctf_type_id {
214 CTF_TYPE_UNKNOWN = -1,
215 CTF_TYPE_INTEGER = 0,
216 CTF_TYPE_FLOAT = 1,
217 CTF_TYPE_ENUM = 2,
218 CTF_TYPE_STRING = 3,
219 CTF_TYPE_STRUCT = 4,
220 CTF_TYPE_UNTAGGED_VARIANT = 5,
221 CTF_TYPE_VARIANT = 5,
222 CTF_TYPE_ARRAY = 6,
223 CTF_TYPE_SEQUENCE = 7,
224 NR_CTF_TYPES,
225 };
226
227 /*
228 * Old enum.
229 */
230 enum ctf_string_encoding {
231 CTF_STRING_NONE = 0,
232 CTF_STRING_UTF8,
233 CTF_STRING_ASCII,
234 CTF_STRING_UNKNOWN,
235 };
236
237 /** @endcond */
238
239 /**
240 @brief CTF scope.
241 */
242 enum bt_ctf_scope {
243 /// Unknown, used for errors.
244 BT_CTF_SCOPE_UNKNOWN = -1,
245
246 /// Trace packet header.
247 BT_CTF_SCOPE_TRACE_PACKET_HEADER = 1,
248
249 /// Stream packet context.
250 BT_CTF_SCOPE_STREAM_PACKET_CONTEXT = 2,
251
252 /// Stream event header.
253 BT_CTF_SCOPE_STREAM_EVENT_HEADER = 3,
254
255 /// Stream event context.
256 BT_CTF_SCOPE_STREAM_EVENT_CONTEXT = 4,
257
258 /// Event context.
259 BT_CTF_SCOPE_EVENT_CONTEXT = 5,
260
261 /// Event payload.
262 BT_CTF_SCOPE_EVENT_PAYLOAD = 6,
263
264 /// @cond DOCUMENT
265 BT_CTF_SCOPE_ENV = 0,
266 BT_CTF_SCOPE_EVENT_FIELDS = 6,
267 /// @endcond
268 };
269
270 /**
271 @name Type information
272 @{
273 */
274
275 /**
276 @brief Type ID of a @ft.
277 */
278 enum bt_ctf_field_type_id {
279 /// Unknown, used for errors.
280 BT_CTF_FIELD_TYPE_ID_UNKNOWN = CTF_TYPE_UNKNOWN,
281
282 /// \ref ctfirintfieldtype
283 BT_CTF_FIELD_TYPE_ID_INTEGER = CTF_TYPE_INTEGER,
284
285 /// \ref ctfirfloatfieldtype
286 BT_CTF_FIELD_TYPE_ID_FLOAT = CTF_TYPE_FLOAT,
287
288 /// \ref ctfirenumfieldtype
289 BT_CTF_FIELD_TYPE_ID_ENUM = CTF_TYPE_ENUM,
290
291 /// \ref ctfirstringfieldtype
292 BT_CTF_FIELD_TYPE_ID_STRING = CTF_TYPE_STRING,
293
294 /// \ref ctfirstructfieldtype
295 BT_CTF_FIELD_TYPE_ID_STRUCT = CTF_TYPE_STRUCT,
296
297 /// \ref ctfirarrayfieldtype
298 BT_CTF_FIELD_TYPE_ID_ARRAY = CTF_TYPE_ARRAY,
299
300 /// \ref ctfirseqfieldtype
301 BT_CTF_FIELD_TYPE_ID_SEQUENCE = CTF_TYPE_SEQUENCE,
302
303 /// \ref ctfirvarfieldtype
304 BT_CTF_FIELD_TYPE_ID_VARIANT = CTF_TYPE_VARIANT,
305
306 /// Number of enumeration entries.
307 BT_CTF_NR_TYPE_IDS = NR_CTF_TYPES,
308 };
309
310 /**
311 @brief Returns the type ID of the @ft \p field_type.
312
313 @param[in] field_type Field type of which to get the type ID.
314 @returns Type ID of \p field_type,
315 or #BT_CTF_FIELD_TYPE_ID_UNKNOWN on error.
316
317 @prenotnull{field_type}
318 @postrefcountsame{field_type}
319
320 @sa #bt_ctf_field_type_id: CTF IR field type ID.
321 @sa bt_ctf_field_type_is_integer(): Returns whether or not a given
322 field type is a @intft.
323 @sa bt_ctf_field_type_is_floating_point(): Returns whether or not a
324 given field type is a @floatft.
325 @sa bt_ctf_field_type_is_enumeration(): Returns whether or not a given
326 field type is a @enumft.
327 @sa bt_ctf_field_type_is_string(): Returns whether or not a given
328 field type is a @stringft.
329 @sa bt_ctf_field_type_is_structure(): Returns whether or not a given
330 field type is a @structft.
331 @sa bt_ctf_field_type_is_array(): Returns whether or not a given
332 field type is a @arrayft.
333 @sa bt_ctf_field_type_is_sequence(): Returns whether or not a given
334 field type is a @seqft.
335 @sa bt_ctf_field_type_is_variant(): Returns whether or not a given
336 field type is a @varft.
337 */
338 extern enum bt_ctf_field_type_id bt_ctf_field_type_get_type_id(
339 struct bt_ctf_field_type *field_type);
340
341 /**
342 @brief Returns whether or not the @ft \p field_type is a @intft.
343
344 @param[in] field_type Field type to check (can be \c NULL).
345 @returns 1 if \p field_type is an integer field type,
346 or 0 otherwise (including if \p field_type is
347 \c NULL).
348
349 @prenotnull{field_type}
350 @postrefcountsame{field_type}
351
352 @sa bt_ctf_field_type_get_type_id(): Returns the type ID of a given
353 field type.
354 */
355 extern int bt_ctf_field_type_is_integer(struct bt_ctf_field_type *field_type);
356
357 /**
358 @brief Returns whether or not the @ft \p field_type is a @floatft.
359
360 @param[in] field_type Field type to check (can be \c NULL).
361 @returns 1 if \p field_type is a floating point
362 number field type,
363 or 0 otherwise (including if \p field_type is
364 \c NULL).
365
366 @postrefcountsame{field_type}
367
368 @sa bt_ctf_field_type_get_type_id(): Returns the type ID of a given
369 field type.
370 */
371 extern int bt_ctf_field_type_is_floating_point(struct bt_ctf_field_type *field_type);
372
373 /**
374 @brief Returns whether or not the @ft \p field_type is a @enumft.
375
376 @param[in] field_type Field type to check (can be \c NULL).
377 @returns 1 if \p field_type is an enumeration field type,
378 or 0 otherwise (including if \p field_type is
379 \c NULL).
380
381 @postrefcountsame{field_type}
382
383 @sa bt_ctf_field_type_get_type_id(): Returns the type ID of a given
384 field type.
385 */
386 extern int bt_ctf_field_type_is_enumeration(struct bt_ctf_field_type *field_type);
387
388 /**
389 @brief Returns whether or not the @ft \p field_type is a @stringft.
390
391 @param[in] field_type Field type to check (can be \c NULL).
392 @returns 1 if \p field_type is a string field type,
393 or 0 otherwise (including if \p field_type is
394 \c NULL).
395
396 @postrefcountsame{field_type}
397
398 @sa bt_ctf_field_type_get_type_id(): Returns the type ID of a given
399 field type.
400 */
401 extern int bt_ctf_field_type_is_string(struct bt_ctf_field_type *field_type);
402
403 /**
404 @brief Returns whether or not the @ft \p field_type is a @structft.
405
406 @param[in] field_type Field type to check (can be \c NULL).
407 @returns 1 if \p field_type is a structure field type,
408 or 0 otherwise (including if \p field_type is
409 \c NULL).
410
411 @postrefcountsame{field_type}
412
413 @sa bt_ctf_field_type_get_type_id(): Returns the type ID of a given
414 field type.
415 */
416 extern int bt_ctf_field_type_is_structure(struct bt_ctf_field_type *field_type);
417
418 /**
419 @brief Returns whether or not the @ft \p field_type is a @arrayft.
420
421 @param[in] field_type Field type to check (can be \c NULL).
422 @returns 1 if \p field_type is an array field type,
423 or 0 otherwise (including if \p field_type is
424 \c NULL).
425
426 @postrefcountsame{field_type}
427
428 @sa bt_ctf_field_type_get_type_id(): Returns the type ID of a given
429 field type.
430 */
431 extern int bt_ctf_field_type_is_array(struct bt_ctf_field_type *field_type);
432
433 /**
434 @brief Returns whether or not the @ft \p field_type is a @seqft.
435
436 @param[in] field_type Field type to check (can be \c NULL).
437 @returns 1 if \p field_type is a sequence field type,
438 or 0 otherwise (including if \p field_type is
439 \c NULL).
440
441 @postrefcountsame{field_type}
442
443 @sa bt_ctf_field_type_get_type_id(): Returns the type ID of a given
444 field type.
445 */
446 extern int bt_ctf_field_type_is_sequence(struct bt_ctf_field_type *field_type);
447
448 /**
449 @brief Returns whether or not the @ft \p field_type is a @varft.
450
451 @param[in] field_type Field type to check (can be \c NULL).
452 @returns 1 if \p field_type is a variant field type,
453 or 0 otherwise (including if \p field_type is
454 \c NULL).
455
456 @postrefcountsame{field_type}
457
458 @sa bt_ctf_field_type_get_type_id(): Returns the type ID of a given
459 field type.
460 */
461 extern int bt_ctf_field_type_is_variant(struct bt_ctf_field_type *field_type);
462
463 /** @} */
464
465 /**
466 @name Common properties types and functions
467 @{
468 */
469
470 /**
471 @brief <a href="https://en.wikipedia.org/wiki/Endianness">Byte order</a>
472 of a @ft.
473 */
474 enum bt_ctf_byte_order {
475 /// Unknown, used for errors.
476 BT_CTF_BYTE_ORDER_UNKNOWN = -1,
477
478 /*
479 * Note that native, in the context of the CTF specification, is defined
480 * as "the byte order described in the trace" and does not mean that the
481 * host's endianness will be used.
482 */
483 /// Native (default) byte order.
484 BT_CTF_BYTE_ORDER_NATIVE = 0,
485
486 /// Little-endian.
487 BT_CTF_BYTE_ORDER_LITTLE_ENDIAN,
488
489 /// Big-endian.
490 BT_CTF_BYTE_ORDER_BIG_ENDIAN,
491
492 /// Network byte order (big-endian).
493 BT_CTF_BYTE_ORDER_NETWORK,
494 };
495
496 /**
497 @brief String encoding of a @ft.
498 */
499 enum bt_ctf_string_encoding {
500 /// Unknown, used for errors.
501 BT_CTF_STRING_ENCODING_UNKNOWN = CTF_STRING_UNKNOWN,
502
503 /// No encoding.
504 BT_CTF_STRING_ENCODING_NONE = CTF_STRING_NONE,
505
506 /// <a href="https://en.wikipedia.org/wiki/UTF-8">UTF-8</a>.
507 BT_CTF_STRING_ENCODING_UTF8 = CTF_STRING_UTF8,
508
509 /// <a href="https://en.wikipedia.org/wiki/ASCII">ASCII</a>.
510 BT_CTF_STRING_ENCODING_ASCII = CTF_STRING_ASCII,
511 };
512
513 /**
514 @brief Returns the alignment of the @fields described by
515 the @ft \p field_type.
516
517 @param[in] field_type Field type which describes the
518 fields of which to get the alignment.
519 @returns Alignment of the fields described by
520 \p field_type, or a negative value on error.
521
522 @prenotnull{field_type}
523 @postrefcountsame{field_type}
524
525 @sa bt_ctf_field_type_set_alignment(): Sets the alignment
526 of the fields described by a given field type.
527 */
528 extern int bt_ctf_field_type_get_alignment(
529 struct bt_ctf_field_type *field_type);
530
531 /**
532 @brief Sets the alignment of the @fields described by the
533 @ft \p field_type to \p alignment.
534
535 \p alignment \em must be greater than 0 and a power of two.
536
537 @param[in] field_type Field type which describes the fields of
538 which to set the alignment.
539 @param[in] alignment Alignment of the fields described by
540 \p field_type.
541 @returns 0 on success, or a negative value on error.
542
543 @prenotnull{field_type}
544 @prehot{field_type}
545 @pre \p alignment is greater than 0 and a power of two.
546 @postrefcountsame{field_type}
547
548 @sa bt_ctf_field_type_get_alignment(): Returns the alignment of the
549 fields described by a given field type.
550 */
551 extern int bt_ctf_field_type_set_alignment(struct bt_ctf_field_type *field_type,
552 unsigned int alignment);
553
554 /**
555 @brief Returns the byte order of the @fields described by
556 the @ft \p field_type.
557
558 You can only call this function if \p field_type is a @intft, a
559 @floatft, or a @enumft.
560
561 @param[in] field_type Field type which describes the
562 fields of which to get the byte order.
563 @returns Byte order of the fields described by
564 \p field_type, or #BT_CTF_BYTE_ORDER_UNKNOWN on
565 error.
566
567 @prenotnull{field_type}
568 @pre \p field_type is a @intft, a @floatft, or a @enumft.
569 @postrefcountsame{field_type}
570
571 @sa bt_ctf_field_type_set_byte_order(): Sets the byte order
572 of the fields described by a given field type.
573 */
574 extern enum bt_ctf_byte_order bt_ctf_field_type_get_byte_order(
575 struct bt_ctf_field_type *field_type);
576
577 /**
578 @brief Sets the byte order of the @fields described by the
579 @ft \p field_type to \p byte_order.
580
581 If \p field_type is a compound field type, this function also
582 recursively sets the byte order of its children to \p byte_order.
583
584 @param[in] field_type Field type which describes the fields of
585 which to set the byte order.
586 @param[in] byte_order Alignment of the fields described by
587 \p field_type.
588 @returns 0 on success, or a negative value on error.
589
590 @prenotnull{field_type}
591 @prehot{field_type}
592 @pre \p byte_order is #BT_CTF_BYTE_ORDER_NATIVE,
593 #BT_CTF_BYTE_ORDER_LITTLE_ENDIAN, #BT_CTF_BYTE_ORDER_BIG_ENDIAN,
594 or #BT_CTF_BYTE_ORDER_NETWORK.
595 @postrefcountsame{field_type}
596
597 @sa bt_ctf_field_type_get_byte_order(): Returns the byte order of the
598 fields described by a given field type.
599 */
600 extern int bt_ctf_field_type_set_byte_order(
601 struct bt_ctf_field_type *field_type,
602 enum bt_ctf_byte_order byte_order);
603
604 /** @} */
605
606 /**
607 @name Utility functions
608 @{
609 */
610
611 /**
612 @brief Returns whether or not the @ft \p field_type_a
613 is equivalent to the field type \p field_type_b.
614
615 You \em must use this function to compare two field types: it is not
616 safe to compare two pointer values directly, because, for internal
617 reasons, some parts of the Babeltrace system can copy user field types
618 and discard the original ones.
619
620 @param[in] field_type_a Field type to compare to \p field_type_b.
621 @param[in] field_type_b Field type to compare to \p field_type_a.
622 @returns 0 if \p field_type_a is equivalent to
623 \p field_type_b, 1 if they are not equivalent,
624 or a negative value on error.
625
626 @prenotnull{field_type_a}
627 @prenotnull{field_type_b}
628 @postrefcountsame{field_type_a}
629 @postrefcountsame{field_type_b}
630 */
631 extern int bt_ctf_field_type_compare(struct bt_ctf_field_type *field_type_a,
632 struct bt_ctf_field_type *field_type_b);
633
634 /**
635 @brief Creates a \em deep copy of the @ft \p field_type.
636
637 You can copy a frozen field type: the resulting copy is
638 <em>not frozen</em>.
639
640 This function resets the tag field type of a copied @varft. The
641 automatic field resolving which some functions of the API perform
642 can set it again when the returned field type is used (learn more
643 in the detailed description of this module).
644
645 @param[in] field_type Field type to copy.
646 @returns Deep copy of \p field_type on success,
647 or \c NULL on error.
648
649 @prenotnull{field_type}
650 @postrefcountsame{field_type}
651 @postsuccessrefcountret1
652 @post <strong>On success</strong>, the returned field type is not frozen.
653 */
654 extern struct bt_ctf_field_type *bt_ctf_field_type_copy(
655 struct bt_ctf_field_type *field_type);
656
657 /** @} */
658
659 /** @} */
660
661 /**
662 @defgroup ctfirintfieldtype CTF IR integer field type
663 @ingroup ctfirfieldtypes
664 @brief CTF IR integer field type.
665
666 @code
667 #include <babeltrace/ctf-ir/field-types.h>
668 @endcode
669
670 A CTF IR <strong><em>integer field type</em></strong> is a field type that
671 you can use to create concrete @intfield objects.
672
673 You can create an integer field type
674 with bt_ctf_field_type_integer_create().
675
676 An integer field type has the following properties:
677
678 <table>
679 <tr>
680 <th>Property
681 <th>Value at creation
682 <th>Getter
683 <th>Setter
684 </tr>
685 <tr>
686 <td>\b Alignment (bits) of the described integer fields
687 <td>1
688 <td>bt_ctf_field_type_get_alignment()
689 <td>bt_ctf_field_type_set_alignment()
690 </tr>
691 <tr>
692 <td><strong>Byte order</strong> of the described integer fields
693 <td>#BT_CTF_BYTE_ORDER_NATIVE
694 <td>bt_ctf_field_type_get_byte_order()
695 <td>bt_ctf_field_type_set_byte_order()
696 </tr>
697 <tr>
698 <td><strong>Storage size</strong> (bits) of the described
699 integer fields
700 <td>Specified at creation
701 <td>bt_ctf_field_type_integer_get_size()
702 <td>bt_ctf_field_type_integer_set_size()
703 </tr>
704 <tr>
705 <td><strong>Signedness</strong> of the described integer fields
706 <td>Unsigned
707 <td>bt_ctf_field_type_integer_is_signed()
708 <td>bt_ctf_field_type_integer_set_is_signed()
709 </tr>
710 <tr>
711 <td><strong>Preferred display base</strong> of the described
712 integer fields
713 <td>#BT_CTF_INTEGER_BASE_DECIMAL
714 <td>bt_ctf_field_type_integer_get_base()
715 <td>bt_ctf_field_type_integer_set_base()
716 </tr>
717 <tr>
718 <td>\b Encoding of the described integer fields
719 <td>#BT_CTF_STRING_ENCODING_NONE
720 <td>bt_ctf_field_type_integer_get_encoding()
721 <td>bt_ctf_field_type_integer_set_encoding()
722 </tr>
723 <tr>
724 <td><strong>Mapped
725 \link ctfirclockclass CTF IR clock class\endlink</strong>
726 <td>None
727 <td>bt_ctf_field_type_integer_get_mapped_clock_class()
728 <td>bt_ctf_field_type_integer_set_mapped_clock_class()
729 </tr>
730 </table>
731
732 @sa ctfirintfield
733 @sa ctfirfieldtypes
734 @sa \ref ctfirfieldtypesexamples_intfieldtype "Examples"
735
736 @addtogroup ctfirintfieldtype
737 @{
738 */
739
740 /**
741 @brief Preferred display base (radix) of a @intft.
742 */
743 enum bt_ctf_integer_base {
744 /// Unknown, used for errors.
745 BT_CTF_INTEGER_BASE_UNKNOWN = -1,
746
747 /// Binary.
748 BT_CTF_INTEGER_BASE_BINARY = 2,
749
750 /// Octal.
751 BT_CTF_INTEGER_BASE_OCTAL = 8,
752
753 /// Decimal.
754 BT_CTF_INTEGER_BASE_DECIMAL = 10,
755
756 /// Hexadecimal.
757 BT_CTF_INTEGER_BASE_HEXADECIMAL = 16,
758 };
759
760 /**
761 @brief Creates a default @intft with \p size bits as the storage size
762 of the @intfields it describes.
763
764 You can change the storage size of the integer fields described by
765 the created integer field type later with
766 bt_ctf_field_type_integer_set_size().
767
768 @param[in] size Storage size (bits) of the described integer fields.
769 @returns Created integer field type, or \c NULL on error.
770
771 @pre \p size is greater than 0 and lesser than or equal to 64.
772 @postsuccessrefcountret1
773 */
774 extern struct bt_ctf_field_type *bt_ctf_field_type_integer_create(
775 unsigned int size);
776
777 /**
778 @brief Returns the storage size, in bits, of the @intfields
779 described by the @intft \p int_field_type.
780
781 @param[in] int_field_type Integer field type which describes the
782 integer fields of which to get the
783 storage size.
784 @returns Storage size (bits) of the integer
785 fields described by \p int_field_type,
786 or a negative value on error.
787
788 @prenotnull{int_field_type}
789 @preisintft{int_field_type}
790 @postrefcountsame{int_field_type}
791
792 @sa bt_ctf_field_type_integer_set_size(): Sets the storage size of the
793 integer fields described by a given integer field type.
794 */
795 extern int bt_ctf_field_type_integer_get_size(
796 struct bt_ctf_field_type *int_field_type);
797
798 /**
799 @brief Sets the storage size, in bits, of the @intfields described by
800 the @intft \p int_field_type.
801
802 @param[in] int_field_type Integer field type which describes the
803 integer fields of which to set the
804 storage size.
805 @param[in] size Storage size (bits) of the integer fields
806 described by \p int_field_type.
807 @returns 0 on success, or a negative value on error.
808
809 @prenotnull{int_field_type}
810 @preisintft{int_field_type}
811 @prehot{int_field_type}
812 @pre \p size is greater than 0 and lesser than or equal to 64.
813 @postrefcountsame{int_field_type}
814
815 @sa bt_ctf_field_type_integer_get_size(): Returns the storage size of
816 the integer fields described by a given integer field type.
817 */
818 extern int bt_ctf_field_type_integer_set_size(
819 struct bt_ctf_field_type *int_field_type, size_t size);
820
821 /**
822 @brief Returns whether or not the @intfields described by the @intft
823 \p int_field_type are signed.
824
825 @param[in] int_field_type Integer field type which describes the
826 integer fields of which to get the
827 signedness.
828 @returns 1 if the integer fields described by
829 \p int_field_type are signed, 0 if they
830 are unsigned, or a negative value on
831 error.
832
833 @prenotnull{int_field_type}
834 @preisintft{int_field_type}
835 @postrefcountsame{int_field_type}
836
837 @sa bt_ctf_field_type_integer_set_is_signed(): Sets the signedness of the
838 integer fields described by a given integer field type.
839 */
840 extern int bt_ctf_field_type_integer_is_signed(
841 struct bt_ctf_field_type *int_field_type);
842
843 /* Pre-2.0 CTF writer compatibility */
844 #define bt_ctf_field_type_integer_get_signed bt_ctf_field_type_integer_is_signed
845
846 /**
847 @brief Sets whether or not the @intfields described by
848 the @intft \p int_field_type are signed.
849
850 @param[in] int_field_type Integer field type which describes the
851 integer fields of which to set the
852 signedness.
853 @param[in] is_signed Signedness of the integer fields
854 described by \p int_field_type; 0 means
855 \em unsigned, 1 means \em signed.
856 @returns 0 on success, or a negative value on error.
857
858 @prenotnull{int_field_type}
859 @preisintft{int_field_type}
860 @prehot{int_field_type}
861 @pre \p is_signed is 0 or 1.
862 @postrefcountsame{int_field_type}
863
864 @sa bt_ctf_field_type_integer_is_signed(): Returns the signedness of
865 the integer fields described by a given integer field type.
866 */
867 extern int bt_ctf_field_type_integer_set_is_signed(
868 struct bt_ctf_field_type *int_field_type, int is_signed);
869
870 /* Pre-2.0 CTF writer compatibility */
871 #define bt_ctf_field_type_integer_set_signed bt_ctf_field_type_integer_set_is_signed
872
873 /**
874 @brief Returns the preferred display base (radix) of the @intfields
875 described by the @intft \p int_field_type.
876
877 @param[in] int_field_type Integer field type which describes the
878 integer fields of which to get the
879 preferred display base.
880 @returns Preferred display base of the integer
881 fields described by \p int_field_type,
882 or #BT_CTF_INTEGER_BASE_UNKNOWN on
883 error.
884
885 @prenotnull{int_field_type}
886 @preisintft{int_field_type}
887 @postrefcountsame{int_field_type}
888
889 @sa bt_ctf_field_type_integer_set_base(): Sets the preferred display
890 base of the integer fields described by a given integer field
891 type.
892 */
893 extern enum bt_ctf_integer_base bt_ctf_field_type_integer_get_base(
894 struct bt_ctf_field_type *int_field_type);
895
896 /**
897 @brief Sets the preferred display base (radix) of the @intfields
898 described by the @intft \p int_field_type to \p base.
899
900 @param[in] int_field_type Integer field type which describes the
901 integer fields of which to set the
902 preferred display base.
903 @param[in] base Preferred display base of the integer
904 fields described by \p int_field_type.
905 @returns 0 on success, or a negative value on error.
906
907 @prenotnull{int_field_type}
908 @preisintft{int_field_type}
909 @prehot{int_field_type}
910 @pre \p base is #BT_CTF_INTEGER_BASE_BINARY, #BT_CTF_INTEGER_BASE_OCTAL,
911 #BT_CTF_INTEGER_BASE_DECIMAL, or
912 #BT_CTF_INTEGER_BASE_HEXADECIMAL.
913 @postrefcountsame{int_field_type}
914
915 @sa bt_ctf_field_type_integer_get_base(): Returns the preferred display
916 base of the integer fields described by a given
917 integer field type.
918 */
919 extern int bt_ctf_field_type_integer_set_base(
920 struct bt_ctf_field_type *int_field_type,
921 enum bt_ctf_integer_base base);
922
923 /**
924 @brief Returns the encoding of the @intfields described by
925 the @intft \p int_field_type.
926
927 @param[in] int_field_type Integer field type which describes the
928 integer fields of which to get the
929 encoding.
930 @returns Encoding of the integer
931 fields described by \p int_field_type,
932 or #BT_CTF_STRING_ENCODING_UNKNOWN on
933 error.
934
935 @prenotnull{int_field_type}
936 @preisintft{int_field_type}
937 @postrefcountsame{int_field_type}
938
939 @sa bt_ctf_field_type_integer_set_encoding(): Sets the encoding
940 of the integer fields described by a given integer field type.
941 */
942 extern enum bt_ctf_string_encoding bt_ctf_field_type_integer_get_encoding(
943 struct bt_ctf_field_type *int_field_type);
944
945 /**
946 @brief Sets the encoding of the @intfields described by the @intft
947 \p int_field_type to \p encoding.
948
949 You can use this property, in CTF IR, to create "text" @arrayfts or
950 @seqfts. A text array field type is array field type with an unsigned,
951 8-bit integer field type having an encoding as its element field type.
952
953 @param[in] int_field_type Integer field type which describes the
954 integer fields of which to set the
955 encoding.
956 @param[in] encoding Encoding of the integer
957 fields described by \p int_field_type.
958 @returns 0 on success, or a negative value on error.
959
960 @prenotnull{int_field_type}
961 @preisintft{int_field_type}
962 @prehot{int_field_type}
963 @pre \p encoding is #BT_CTF_STRING_ENCODING_NONE,
964 #BT_CTF_STRING_ENCODING_ASCII, or
965 #BT_CTF_STRING_ENCODING_UTF8.
966 @postrefcountsame{int_field_type}
967
968 @sa bt_ctf_field_type_integer_get_encoding(): Returns the encoding of
969 the integer fields described by a given integer field type.
970 */
971 extern int bt_ctf_field_type_integer_set_encoding(
972 struct bt_ctf_field_type *int_field_type,
973 enum bt_ctf_string_encoding encoding);
974
975 /**
976 @brief Returns the \link ctfirclockclass CTF IR clock class\endlink
977 mapped to the @intft \p int_field_type.
978
979 The mapped clock class, if any, indicates the class of the clock which
980 an @intfield described by \p int_field_type should sample or update.
981 This mapped clock class is only indicative.
982
983 @param[in] int_field_type Integer field type of which to get the
984 mapped clock class.
985 @returns Mapped clock class of \p int_field_type,
986 or \c NULL if there's no mapped clock
987 class or on error.
988
989 @prenotnull{int_field_type}
990 @preisintft{int_field_type}
991 @postrefcountsame{int_field_type}
992 @postsuccessrefcountretinc
993
994 @sa bt_ctf_field_type_integer_set_mapped_clock_class(): Sets the mapped
995 clock class of a given integer field type.
996 */
997 extern struct bt_ctf_clock_class *bt_ctf_field_type_integer_get_mapped_clock_class(
998 struct bt_ctf_field_type *int_field_type);
999
1000 /**
1001 @brief Sets the \link ctfirclockclass CTF IR clock class\endlink mapped
1002 to the @intft \p int_field_type to \p clock_class.
1003
1004 The mapped clock class, if any, indicates the class of the clock which
1005 an integer field described by \p int_field_type should sample or update.
1006 This mapped clock class is only indicative.
1007
1008 @param[in] int_field_type Integer field type of which to set the
1009 mapped clock class.
1010 @param[in] clock_class Mapped clock class of \p int_field_type.
1011 @returns 0 on success, or a negative value on error.
1012
1013 @prenotnull{int_field_type}
1014 @prenotnull{clock_class}
1015 @preisintft{int_field_type}
1016 @prehot{int_field_type}
1017 @postrefcountsame{int_field_type}
1018 @postsuccessrefcountinc{clock_class}
1019
1020 @sa bt_ctf_field_type_integer_get_mapped_clock_class(): Returns the mapped
1021 clock class of a given integer field type.
1022 */
1023 extern int bt_ctf_field_type_integer_set_mapped_clock_class(
1024 struct bt_ctf_field_type *int_field_type,
1025 struct bt_ctf_clock_class *clock_class);
1026
1027 /** @} */
1028
1029 /**
1030 @defgroup ctfirfloatfieldtype CTF IR floating point number field type
1031 @ingroup ctfirfieldtypes
1032 @brief CTF IR floating point number field type.
1033
1034 @code
1035 #include <babeltrace/ctf-ir/field-types.h>
1036 @endcode
1037
1038 A CTF IR <strong><em>floating point number field type</em></strong> is
1039 a field type that you can use to create concrete @floatfields.
1040
1041 You can create a floating point number field type
1042 with bt_ctf_field_type_floating_point_create().
1043
1044 A floating point number field type has the following properties:
1045
1046 <table>
1047 <tr>
1048 <th>Property
1049 <th>Value at creation
1050 <th>Getter
1051 <th>Setter
1052 </tr>
1053 <tr>
1054 <td>\b Alignment (bits) of the described floating point
1055 number fields
1056 <td>1
1057 <td>bt_ctf_field_type_get_alignment()
1058 <td>bt_ctf_field_type_set_alignment()
1059 </tr>
1060 <tr>
1061 <td><strong>Byte order</strong> of the described floating point
1062 number fields
1063 <td>#BT_CTF_BYTE_ORDER_NATIVE
1064 <td>bt_ctf_field_type_get_byte_order()
1065 <td>bt_ctf_field_type_set_byte_order()
1066 </tr>
1067 <tr>
1068 <td><strong>Exponent storage size</strong> (bits) of the described
1069 floating point number fields
1070 <td>8
1071 <td>bt_ctf_field_type_floating_point_get_exponent_digits()
1072 <td>bt_ctf_field_type_floating_point_set_exponent_digits()
1073 </tr>
1074 <tr>
1075 <td><strong>Mantissa and sign storage size</strong> (bits) of the
1076 described floating point number fields
1077 <td>24 (23-bit mantissa, 1-bit sign)
1078 <td>bt_ctf_field_type_floating_point_get_mantissa_digits()
1079 <td>bt_ctf_field_type_floating_point_set_mantissa_digits()
1080 </tr>
1081 </table>
1082
1083 @sa ctfirfloatfield
1084 @sa ctfirfieldtypes
1085 @sa \ref ctfirfieldtypesexamples_floatfieldtype "Examples"
1086
1087 @addtogroup ctfirfloatfieldtype
1088 @{
1089 */
1090
1091 /**
1092 @brief Creates a default @floatft.
1093
1094 @returns Created floating point number field type,
1095 or \c NULL on error.
1096
1097 @postsuccessrefcountret1
1098 */
1099 extern struct bt_ctf_field_type *bt_ctf_field_type_floating_point_create(void);
1100
1101 /**
1102 @brief Returns the exponent storage size of the @floatfields
1103 described by the @floatft \p float_field_type.
1104
1105 @param[in] float_field_type Floating point number field type which
1106 describes the floating point number
1107 fields of which to get the exponent
1108 storage size.
1109 @returns Exponent storage size of the
1110 floating point number fields
1111 described by \p float_field_type,
1112 or a negative value on error.
1113
1114 @prenotnull{float_field_type}
1115 @preisfloatft{float_field_type}
1116 @postrefcountsame{float_field_type}
1117
1118 @sa bt_ctf_field_type_floating_point_set_exponent_digits(): Sets the
1119 exponent storage size of the floating point number fields
1120 described by a given floating point number field type.
1121 */
1122 extern int bt_ctf_field_type_floating_point_get_exponent_digits(
1123 struct bt_ctf_field_type *float_field_type);
1124
1125 /**
1126 @brief Sets the exponent storage size of the @floatfields described by
1127 the @floatft \p float_field_type to \p exponent_size.
1128
1129 As of Babeltrace \btversion, \p exponent_size can only be 8 or 11.
1130
1131 @param[in] float_field_type Floating point number field type which
1132 describes the floating point number
1133 fields of which to set the exponent
1134 storage size.
1135 @param[in] exponent_size Exponent storage size of the floating
1136 point number fields described by \p
1137 float_field_type.
1138 @returns 0 on success, or a negative value on error.
1139
1140 @prenotnull{float_field_type}
1141 @preisfloatft{float_field_type}
1142 @prehot{float_field_type}
1143 @pre \p exponent_size is 8 or 11.
1144 @postrefcountsame{float_field_type}
1145
1146 @sa bt_ctf_field_type_floating_point_get_exponent_digits(): Returns the
1147 exponent storage size of the floating point number fields
1148 described by a given floating point number field type.
1149 */
1150 extern int bt_ctf_field_type_floating_point_set_exponent_digits(
1151 struct bt_ctf_field_type *float_field_type,
1152 unsigned int exponent_size);
1153
1154 /**
1155 @brief Returns the mantissa and sign storage size of the @floatfields
1156 described by the @floatft \p float_field_type.
1157
1158 On success, the returned value is the sum of the mantissa \em and
1159 sign storage sizes.
1160
1161 @param[in] float_field_type Floating point number field type which
1162 describes the floating point number
1163 fields of which to get the mantissa and
1164 sign storage size.
1165 @returns Mantissa and sign storage size of the
1166 floating point number fields
1167 described by \p float_field_type,
1168 or a negative value on error.
1169
1170 @prenotnull{float_field_type}
1171 @preisfloatft{float_field_type}
1172 @postrefcountsame{float_field_type}
1173
1174 @sa bt_ctf_field_type_floating_point_set_mantissa_digits(): Sets the
1175 mantissa and size storage size of the floating point number
1176 fields described by a given floating point number field type.
1177 */
1178 extern int bt_ctf_field_type_floating_point_get_mantissa_digits(
1179 struct bt_ctf_field_type *float_field_type);
1180
1181 /**
1182 @brief Sets the mantissa and sign storage size of the @floatfields
1183 described by the @floatft \p float_field_type to \p
1184 mantissa_sign_size.
1185
1186 As of Babeltrace \btversion, \p mantissa_sign_size can only be 24 or 53.
1187
1188 @param[in] float_field_type Floating point number field type which
1189 describes the floating point number
1190 fields of which to set the mantissa and
1191 sign storage size.
1192 @param[in] mantissa_sign_size Mantissa and sign storage size of the
1193 floating point number fields described
1194 by \p float_field_type.
1195 @returns 0 on success, or a negative value on error.
1196
1197 @prenotnull{float_field_type}
1198 @preisfloatft{float_field_type}
1199 @prehot{float_field_type}
1200 @pre \p mantissa_sign_size is 24 or 53.
1201 @postrefcountsame{float_field_type}
1202
1203 @sa bt_ctf_field_type_floating_point_get_mantissa_digits(): Returns the
1204 mantissa and sign storage size of the floating point number
1205 fields described by a given floating point number field type.
1206 */
1207 extern int bt_ctf_field_type_floating_point_set_mantissa_digits(
1208 struct bt_ctf_field_type *float_field_type,
1209 unsigned int mantissa_sign_size);
1210
1211 /** @} */
1212
1213 /**
1214 @defgroup ctfirenumfieldtype CTF IR enumeration field type
1215 @ingroup ctfirfieldtypes
1216 @brief CTF IR enumeration field type.
1217
1218 @code
1219 #include <babeltrace/ctf-ir/field-types.h>
1220 @endcode
1221
1222 A CTF IR <strong><em>enumeration field type</em></strong> is
1223 a field type that you can use to create concrete @enumfields.
1224
1225 You can create an enumeration field type with
1226 bt_ctf_field_type_enumeration_create(). This function needs a @intft
1227 which represents the storage field type of the created enumeration field
1228 type. In other words, an enumeration field type wraps an integer field
1229 type and adds label-value mappings to it.
1230
1231 An enumeration mapping has:
1232
1233 - A <strong>name</strong>.
1234 - A <strong>range of values</strong> given by a beginning and an ending
1235 value, both included in the range.
1236
1237 You can add a mapping to an enumeration field type with
1238 bt_ctf_field_type_enumeration_add_mapping() or
1239 bt_ctf_field_type_enumeration_add_mapping_unsigned(), depending on the
1240 signedness of the wrapped @intft.
1241
1242 You can find mappings by name or by value with the following find
1243 operations:
1244
1245 - bt_ctf_field_type_enumeration_find_mappings_by_name(): Finds the
1246 mappings with a given name.
1247 - bt_ctf_field_type_enumeration_find_mappings_by_unsigned_value():
1248 Finds the mappings which contain a given unsigned value in their
1249 range.
1250 - bt_ctf_field_type_enumeration_find_mappings_by_signed_value():
1251 Finds the mappings which contain a given signed value in their range.
1252
1253 Those functions return a @enumftiter on the result set of the find
1254 operation.
1255
1256 Many mappings can share the same name, and the ranges of a given
1257 enumeration field type are allowed to overlap. For example,
1258 this is a valid set of mappings:
1259
1260 @verbatim
1261 APPLE -> [ 3, 19]
1262 BANANA -> [-15, 1]
1263 CHERRY -> [ 25, 34]
1264 APPLE -> [ 55, 55]
1265 @endverbatim
1266
1267 The following set of mappings is also valid:
1268
1269 @verbatim
1270 APPLE -> [ 3, 19]
1271 BANANA -> [-15, 1]
1272 CHERRY -> [ 25, 34]
1273 APPLE -> [ 30, 55]
1274 @endverbatim
1275
1276 Here, the range of the second \c APPLE mapping overlaps the range of
1277 the \c CHERRY mapping.
1278
1279 @sa ctfirenumftmappingiter
1280 @sa ctfirenumfield
1281 @sa ctfirfieldtypes
1282
1283 @addtogroup ctfirenumfieldtype
1284 @{
1285 */
1286
1287 /**
1288 @brief Creates a default @enumft wrapping the @intft \p int_field_type.
1289
1290 @param[in] int_field_type Integer field type wrapped by the
1291 created enumeration field type.
1292 @returns Created enumeration field type,
1293 or \c NULL on error.
1294
1295 @prenotnull{int_field_type}
1296 @preisintft{int_field_type}
1297 @postsuccessrefcountinc{int_field_type}
1298 @postsuccessrefcountret1
1299 */
1300 extern struct bt_ctf_field_type *bt_ctf_field_type_enumeration_create(
1301 struct bt_ctf_field_type *int_field_type);
1302
1303 /**
1304 @brief Returns the @intft wrapped by the @enumft \p enum_field_type.
1305
1306 @param[in] enum_field_type Enumeration field type of which to get
1307 the wrapped integer field type.
1308 @returns Integer field type wrapped by
1309 \p enum_field_type, or \c NULL on
1310 error.
1311
1312 @prenotnull{enum_field_type}
1313 @preisenumft{enum_field_type}
1314 @postrefcountsame{enum_field_type}
1315 @postsuccessrefcountretinc
1316 */
1317 extern
1318 struct bt_ctf_field_type *bt_ctf_field_type_enumeration_get_container_type(
1319 struct bt_ctf_field_type *enum_field_type);
1320
1321 /**
1322 @brief Returns the number of mappings contained in the
1323 @enumft \p enum_field_type.
1324
1325 @param[in] enum_field_type Enumeration field type of which to get
1326 the number of contained mappings.
1327 @returns Number of mappings contained in
1328 \p enum_field_type, or a negative
1329 value on error.
1330
1331 @prenotnull{enum_field_type}
1332 @preisenumft{enum_field_type}
1333 @postrefcountsame{enum_field_type}
1334 */
1335 extern int64_t bt_ctf_field_type_enumeration_get_mapping_count(
1336 struct bt_ctf_field_type *enum_field_type);
1337
1338 /**
1339 @brief Returns the signed mapping of the @enumft
1340 \p enum_field_type at index \p index.
1341
1342 The @intft wrapped by \p enum_field_type, as returned by
1343 bt_ctf_field_type_enumeration_get_container_type(), must be \b signed
1344 to use this function.
1345
1346 On success, \p enum_field_type remains the sole owner of \p *name.
1347
1348 @param[in] enum_field_type Enumeration field type of which to get
1349 the mapping at index \p index.
1350 @param[in] index Index of the mapping to get from
1351 \p enum_field_type.
1352 @param[out] name Returned name of the mapping at index
1353 \p index.
1354 @param[out] range_begin Returned beginning of the range
1355 (included) of the mapping at index \p
1356 index.
1357 @param[out] range_end Returned end of the range (included) of
1358 the mapping at index \p index.
1359 @returns 0 on success, or a negative value on error.
1360
1361 @prenotnull{enum_field_type}
1362 @prenotnull{name}
1363 @prenotnull{range_begin}
1364 @prenotnull{range_end}
1365 @preisenumft{enum_field_type}
1366 @pre The wrapped @intft of \p enum_field_type is signed.
1367 @pre \p index is lesser than the number of mappings contained in the
1368 enumeration field type \p enum_field_type (see
1369 bt_ctf_field_type_enumeration_get_mapping_count()).
1370 @postrefcountsame{enum_field_type}
1371
1372 @sa bt_ctf_field_type_enumeration_get_mapping_unsigned(): Returns the
1373 unsigned mapping contained by a given enumeration field type
1374 at a given index.
1375 */
1376 extern int bt_ctf_field_type_enumeration_get_mapping_signed(
1377 struct bt_ctf_field_type *enum_field_type, uint64_t index,
1378 const char **name, int64_t *range_begin, int64_t *range_end);
1379
1380 /**
1381 @brief Returns the unsigned mapping of the @enumft
1382 \p enum_field_type at index \p index.
1383
1384 The @intft wrapped by \p enum_field_type, as returned by
1385 bt_ctf_field_type_enumeration_get_container_type(), must be
1386 \b unsigned to use this function.
1387
1388 On success, \p enum_field_type remains the sole owner of \p *name.
1389
1390 @param[in] enum_field_type Enumeration field type of which to get
1391 the mapping at index \p index.
1392 @param[in] index Index of the mapping to get from
1393 \p enum_field_type.
1394 @param[out] name Returned name of the mapping at index
1395 \p index.
1396 @param[out] range_begin Returned beginning of the range
1397 (included) of the mapping at index \p
1398 index.
1399 @param[out] range_end Returned end of the range (included) of
1400 the mapping at index \p index.
1401 @returns 0 on success, or a negative value on error.
1402
1403 @prenotnull{enum_field_type}
1404 @prenotnull{name}
1405 @prenotnull{range_begin}
1406 @prenotnull{range_end}
1407 @preisenumft{enum_field_type}
1408 @pre The wrapped @intft of \p enum_field_type is unsigned.
1409 @pre \p index is lesser than the number of mappings contained in the
1410 enumeration field type \p enum_field_type (see
1411 bt_ctf_field_type_enumeration_get_mapping_count()).
1412 @postrefcountsame{enum_field_type}
1413
1414 @sa bt_ctf_field_type_enumeration_get_mapping_signed(): Returns the
1415 signed mapping contained by a given enumeration field type
1416 at a given index.
1417 */
1418 extern int bt_ctf_field_type_enumeration_get_mapping_unsigned(
1419 struct bt_ctf_field_type *enum_field_type, uint64_t index,
1420 const char **name, uint64_t *range_begin,
1421 uint64_t *range_end);
1422
1423 /**
1424 @brief Finds the mappings of the @enumft \p enum_field_type which
1425 are named \p name.
1426
1427 This function returns an iterator on the result set of this find
1428 operation. See \ref ctfirenumftmappingiter for more details.
1429
1430 @param[in] enum_field_type Enumeration field type of which to find
1431 the mappings named \p name.
1432 @param[in] name Name of the mappings to find in
1433 \p enum_field_type.
1434 @returns @enumftiter on the set of mappings named
1435 \p name in \p enum_field_type, or
1436 \c NULL if no mappings were found or
1437 on error.
1438
1439 @prenotnull{enum_field_type}
1440 @prenotnull{name}
1441 @preisenumft{enum_field_type}
1442 @postrefcountsame{enum_field_type}
1443 @postsuccessrefcountret1
1444 @post <strong>On success</strong>, the returned @enumftiter can iterate
1445 on at least one mapping.
1446
1447 @sa bt_ctf_field_type_enumeration_find_mappings_by_signed_value(): Finds
1448 the mappings of a given enumeration field type which contain
1449 a given signed value in their range.
1450 @sa bt_ctf_field_type_enumeration_find_mappings_by_unsigned_value(): Finds
1451 the mappings of a given enumeration field type which contain
1452 a given unsigned value in their range.
1453 */
1454 extern struct bt_ctf_field_type_enumeration_mapping_iterator *
1455 bt_ctf_field_type_enumeration_find_mappings_by_name(
1456 struct bt_ctf_field_type *enum_field_type,
1457 const char *name);
1458
1459 /**
1460 @brief Finds the mappings of the @enumft \p enum_field_type which
1461 contain the signed value \p value in their range.
1462
1463 This function returns an iterator on the result set of this find
1464 operation. See \ref ctfirenumftmappingiter for more details.
1465
1466 @param[in] enum_field_type Enumeration field type of which to find
1467 the mappings which contain \p value.
1468 @param[in] value Value to find in the ranges of the
1469 mappings of \p enum_field_type.
1470 @returns @enumftiter on the set of mappings of
1471 \p enum_field_type which contain
1472 \p value in their range, or \c NULL if
1473 no mappings were found or on error.
1474
1475 @prenotnull{enum_field_type}
1476 @preisenumft{enum_field_type}
1477 @postrefcountsame{enum_field_type}
1478 @postsuccessrefcountret1
1479 @post <strong>On success</strong>, the returned @enumftiter can iterate
1480 on at least one mapping.
1481
1482 @sa bt_ctf_field_type_enumeration_find_mappings_by_name(): Finds the
1483 mappings of a given enumeration field type which have a given
1484 name.
1485 @sa bt_ctf_field_type_enumeration_find_mappings_by_unsigned_value(): Finds
1486 the mappings of a given enumeration field type which contain
1487 a given unsigned value in their range.
1488 */
1489 extern struct bt_ctf_field_type_enumeration_mapping_iterator *
1490 bt_ctf_field_type_enumeration_find_mappings_by_signed_value(
1491 struct bt_ctf_field_type *enum_field_type,
1492 int64_t value);
1493
1494 /**
1495 @brief Finds the mappings of the @enumft \p enum_field_type which
1496 contain the unsigned value \p value in their range.
1497
1498 This function returns an iterator on the result set of this find
1499 operation. See \ref ctfirenumftmappingiter for more details.
1500
1501 @param[in] enum_field_type Enumeration field type of which to find
1502 the mappings which contain \p value.
1503 @param[in] value Value to find in the ranges of the
1504 mappings of \p enum_field_type.
1505 @returns @enumftiter on the set of mappings of
1506 \p enum_field_type which contain
1507 \p value in their range, or \c NULL
1508 if no mappings were found or
1509 on error.
1510
1511 @prenotnull{enum_field_type}
1512 @preisenumft{enum_field_type}
1513 @postrefcountsame{enum_field_type}
1514 @postsuccessrefcountret1
1515 @post <strong>On success</strong>, the returned @enumftiter can iterate
1516 on at least one mapping.
1517
1518 @sa bt_ctf_field_type_enumeration_find_mappings_by_name(): Finds the
1519 mappings of a given enumeration field type which have a given
1520 name.
1521 @sa bt_ctf_field_type_enumeration_find_mappings_by_signed_value(): Finds
1522 the mappings of a given enumeration field type which contain
1523 a given unsigned value in their range.
1524 */
1525 extern struct bt_ctf_field_type_enumeration_mapping_iterator *
1526 bt_ctf_field_type_enumeration_find_mappings_by_unsigned_value(
1527 struct bt_ctf_field_type *enum_field_type,
1528 uint64_t value);
1529
1530 /**
1531 @brief Adds a mapping to the @enumft \p enum_field_type which maps the
1532 name \p name to the signed range \p range_begin (included) to
1533 \p range_end (included).
1534
1535 Make \p range_begin and \p range_end the same value to add a mapping
1536 to a single value.
1537
1538 The @intft wrapped by \p enum_field_type, as returned by
1539 bt_ctf_field_type_enumeration_get_container_type(), must be
1540 \b signed to use this function.
1541
1542 A mapping in \p enum_field_type can exist with the name \p name.
1543
1544 @param[in] enum_field_type Enumeration field type to which to add
1545 a mapping.
1546 @param[in] name Name of the mapping to add (copied
1547 on success).
1548 @param[in] range_begin Beginning of the range of the mapping
1549 (included).
1550 @param[in] range_end End of the range of the mapping
1551 (included).
1552 @returns 0 on success, or a negative value on error.
1553
1554 @prenotnull{enum_field_type}
1555 @prenotnull{name}
1556 @prehot{enum_field_type}
1557 @preisenumft{enum_field_type}
1558 @pre The wrapped @intft of \p enum_field_type is signed.
1559 @pre \p range_end is greater than or equal to \p range_begin.
1560 @postrefcountsame{enum_field_type}
1561
1562 @sa bt_ctf_field_type_enumeration_add_mapping_unsigned(): Adds an
1563 unsigned mapping to a given enumeration field type.
1564 */
1565 extern int bt_ctf_field_type_enumeration_add_mapping(
1566 struct bt_ctf_field_type *enum_field_type, const char *name,
1567 int64_t range_begin, int64_t range_end);
1568
1569 /**
1570 @brief Adds a mapping to the @enumft \p enum_field_type which maps
1571 the name \p name to the unsigned
1572 range \p range_begin (included) to \p range_end (included).
1573
1574 Make \p range_begin and \p range_end the same value to add a mapping
1575 to a single value.
1576
1577 The @intft wrapped by \p enum_field_type, as returned by
1578 bt_ctf_field_type_enumeration_get_container_type(), must be
1579 \b unsigned to use this function.
1580
1581 A mapping in \p enum_field_type can exist with the name \p name.
1582
1583 @param[in] enum_field_type Enumeration field type to which to add
1584 a mapping.
1585 @param[in] name Name of the mapping to add (copied
1586 on success).
1587 @param[in] range_begin Beginning of the range of the mapping
1588 (included).
1589 @param[in] range_end End of the range of the mapping
1590 (included).
1591 @returns 0 on success, or a negative value on error.
1592
1593 @prenotnull{enum_field_type}
1594 @prenotnull{name}
1595 @prehot{enum_field_type}
1596 @preisenumft{enum_field_type}
1597 @pre The wrapped @intft of \p enum_field_type is unsigned.
1598 @pre \p range_end is greater than or equal to \p range_begin.
1599 @postrefcountsame{enum_field_type}
1600
1601 @sa bt_ctf_field_type_enumeration_add_mapping(): Adds a signed
1602 mapping to a given enumeration field type.
1603 */
1604 extern int bt_ctf_field_type_enumeration_add_mapping_unsigned(
1605 struct bt_ctf_field_type *enum_field_type, const char *name,
1606 uint64_t range_begin, uint64_t range_end);
1607
1608 /** @} */
1609
1610 /**
1611 @defgroup ctfirenumftmappingiter CTF IR enumeration field type mapping iterator
1612 @ingroup ctfirenumfieldtype
1613 @brief CTF IR enumeration field type mapping iterator.
1614
1615 @code
1616 #include <babeltrace/ctf-ir/field-types.h>
1617 @endcode
1618
1619 A CTF IR <strong><em>enumeration field type mapping
1620 iterator</em></strong> is an iterator on @enumft mappings.
1621
1622 You can get an enumeration mapping iterator from one of the following
1623 functions:
1624
1625 - Find operations of an @enumft object:
1626 - bt_ctf_field_type_enumeration_find_mappings_by_name(): Finds the
1627 mappings with a given name.
1628 - bt_ctf_field_type_enumeration_find_mappings_by_unsigned_value():
1629 Finds the mappings which contain a given unsigned value in their
1630 range.
1631 - bt_ctf_field_type_enumeration_find_mappings_by_signed_value():
1632 Finds the mappings which contain a given signed value in their range.
1633 - bt_ctf_field_enumeration_get_mappings(): Finds the mappings in the
1634 @enumft of an @enumfield containing its current integral value in
1635 their range.
1636
1637 Those functions guarantee that the returned iterator can iterate on
1638 at least one mapping. Otherwise, they return \c NULL.
1639
1640 You can get the name and the range of a mapping iterator's current
1641 mapping with
1642 bt_ctf_field_type_enumeration_mapping_iterator_get_signed()
1643 or
1644 bt_ctf_field_type_enumeration_mapping_iterator_get_unsigned(),
1645 depending on the signedness of the @intft wrapped by the
1646 @enumft. If you only need the name of the current mapping, you can
1647 use any of the two functions and set the \p range_begin and \p range_end
1648 parameters to \c NULL.
1649
1650 You can advance an enumeration field type mapping iterator to the next
1651 mapping with
1652 bt_ctf_field_type_enumeration_mapping_iterator_next(). This
1653 function returns a negative value when you reach the end of the
1654 result set.
1655
1656 As with any Babeltrace object, CTF IR enumeration field type mapping
1657 iterator objects have <a
1658 href="https://en.wikipedia.org/wiki/Reference_counting">reference
1659 counts</a>. See \ref refs to learn more about the reference counting
1660 management of Babeltrace objects.
1661
1662 @sa ctfirenumfieldtype
1663
1664 @addtogroup ctfirenumftmappingiter
1665 @{
1666 */
1667
1668 /**
1669 @struct bt_ctf_field_type_enumeration_mapping_iterator
1670 @brief A CTF IR enumeration field type mapping iterator.
1671 @sa ctfirenumftmappingiter
1672 */
1673
1674 /**
1675 @brief Returns the name and the range of the current (signed) mapping
1676 of the @enumftiter \p iter.
1677
1678 If one of \p range_begin or \p range_end is not \c NULL, the @intft
1679 wrapped by the @enumft from which \p iter was obtained, as returned by
1680 bt_ctf_field_type_enumeration_get_container_type(), must be
1681 \b signed to use this function. Otherwise, if you only need to get the
1682 name of the current mapping, set \p range_begin and \p range_end to
1683 \c NULL.
1684
1685 On success, if \p name is not \c NULL, \p *name remains valid as long
1686 as \p iter exists and
1687 bt_ctf_field_type_enumeration_mapping_iterator_next() is
1688 \em not called on \p iter.
1689
1690 @param[in] iter Enumeration field type mapping iterator
1691 of which to get the range of the current
1692 mapping.
1693 @param[out] name Returned name of the current mapping of
1694 \p iter (can be \c NULL to ignore).
1695 @param[out] range_begin Returned beginning of the range
1696 (included) of the current mapping of
1697 \p iter (can be \c NULL to ignore).
1698 @param[out] range_end Returned end of the range
1699 (included) of the current mapping of
1700 \p iter (can be \c NULL to ignore).
1701 @returns 0 on success, or a negative value on error.
1702
1703 @prenotnull{iter}
1704 @postrefcountsame{iter}
1705
1706 @sa bt_ctf_field_type_enumeration_mapping_iterator_get_unsigned():
1707 Returns the name and the unsigned range of the current mapping
1708 of a given enumeration field type mapping iterator.
1709 */
1710 extern int bt_ctf_field_type_enumeration_mapping_iterator_get_signed(
1711 struct bt_ctf_field_type_enumeration_mapping_iterator *iter,
1712 const char **name, int64_t *range_begin, int64_t *range_end);
1713
1714 /**
1715 @brief Returns the name and the range of the current (unsigned) mapping
1716 of the @enumftiter \p iter.
1717
1718 If one of \p range_begin or \p range_end is not \c NULL, the @intft
1719 wrapped by the @enumft from which \p iter was obtained, as returned by
1720 bt_ctf_field_type_enumeration_get_container_type(), must be
1721 \b unsigned to use this function. Otherwise, if you only need to get the
1722 name of the current mapping, set \p range_begin and \p range_end to
1723 \c NULL.
1724
1725 On success, if \p name is not \c NULL, \p *name remains valid as long
1726 as \p iter exists and
1727 bt_ctf_field_type_enumeration_mapping_iterator_next() is
1728 \em not called on \p iter.
1729
1730 @param[in] iter Enumeration field type mapping iterator
1731 of which to get the range of the current
1732 mapping.
1733 @param[out] name Returned name of the current mapping of
1734 \p iter (can be \c NULL to ignore).
1735 @param[out] range_begin Returned beginning of the range
1736 (included) of the current mapping of
1737 \p iter (can be \c NULL to ignore).
1738 @param[out] range_end Returned end of the range
1739 (included) of the current mapping of
1740 \p iter (can be \c NULL to ignore).
1741 @returns 0 on success, or a negative value on error.
1742
1743 @prenotnull{iter}
1744 @postrefcountsame{iter}
1745
1746 @sa
1747 bt_ctf_field_type_enumeration_mapping_iterator_get_signed():
1748 Returns the name and the signed range of the current mapping of
1749 a given enumeration field type mapping iterator.
1750 */
1751 extern int bt_ctf_field_type_enumeration_mapping_iterator_get_unsigned(
1752 struct bt_ctf_field_type_enumeration_mapping_iterator *iter,
1753 const char **name, uint64_t *range_begin, uint64_t *range_end);
1754
1755 /**
1756 @brief Advances the @enumftiter \p iter to the next mapping.
1757
1758 @param[in] iter Enumeration field type mapping iterator to
1759 advance.
1760 @returns 0 on success, or a negative value on error or
1761 when you reach the end of the set.
1762
1763 @prenotnull{iter}
1764 @postrefcountsame{iter}
1765 */
1766 extern int bt_ctf_field_type_enumeration_mapping_iterator_next(
1767 struct bt_ctf_field_type_enumeration_mapping_iterator *iter);
1768
1769 /** @} */
1770
1771 /**
1772 @defgroup ctfirstringfieldtype CTF IR string field type
1773 @ingroup ctfirfieldtypes
1774 @brief CTF IR string field type.
1775
1776 @code
1777 #include <babeltrace/ctf-ir/field-types.h>
1778 @endcode
1779
1780 A CTF IR <strong><em>string field type</em></strong> is a field type that
1781 you can use to create concrete @stringfields.
1782
1783 You can create a string field type
1784 with bt_ctf_field_type_string_create().
1785
1786 A string field type has only one property: the \b encoding of its
1787 described @stringfields. By default, the encoding of the string fields
1788 described by a string field type is #BT_CTF_STRING_ENCODING_UTF8. You
1789 can set the encoding of the string fields described by a string field
1790 type with bt_ctf_field_type_string_set_encoding().
1791
1792 @sa ctfirstringfield
1793 @sa ctfirfieldtypes
1794
1795 @addtogroup ctfirstringfieldtype
1796 @{
1797 */
1798
1799 /**
1800 @brief Creates a default @stringft.
1801
1802 @returns Created string field type, or \c NULL on error.
1803
1804 @postsuccessrefcountret1
1805 */
1806 extern struct bt_ctf_field_type *bt_ctf_field_type_string_create(void);
1807
1808 /**
1809 @brief Returns the encoding of the @stringfields described by
1810 the @stringft \p string_field_type.
1811
1812 @param[in] string_field_type String field type which describes the
1813 string fields of which to get the
1814 encoding.
1815 @returns Encoding of the string
1816 fields described by \p string_field_type,
1817 or #BT_CTF_STRING_ENCODING_UNKNOWN on
1818 error.
1819
1820 @prenotnull{string_field_type}
1821 @preisstringft{string_field_type}
1822 @postrefcountsame{string_field_type}
1823
1824 @sa bt_ctf_field_type_string_set_encoding(): Sets the encoding
1825 of the string fields described by a given string field type.
1826 */
1827 extern enum bt_ctf_string_encoding bt_ctf_field_type_string_get_encoding(
1828 struct bt_ctf_field_type *string_field_type);
1829
1830 /**
1831 @brief Sets the encoding of the @stringfields described by the
1832 @stringft \p string_field_type to \p encoding.
1833
1834 @param[in] string_field_type String field type which describes the
1835 string fields of which to set the
1836 encoding.
1837 @param[in] encoding Encoding of the string fields described
1838 by \p string_field_type.
1839 @returns 0 on success, or a negative value on error.
1840
1841 @prenotnull{string_field_type}
1842 @preisstringft{string_field_type}
1843 @prehot{string_field_type}
1844 @pre \p encoding is #BT_CTF_STRING_ENCODING_ASCII or
1845 #BT_CTF_STRING_ENCODING_UTF8.
1846 @postrefcountsame{string_field_type}
1847
1848 @sa bt_ctf_field_type_string_get_encoding(): Returns the encoding of
1849 the string fields described by a given string field type.
1850 */
1851 extern int bt_ctf_field_type_string_set_encoding(
1852 struct bt_ctf_field_type *string_field_type,
1853 enum bt_ctf_string_encoding encoding);
1854
1855 /** @} */
1856
1857 /**
1858 @defgroup ctfirstructfieldtype CTF IR structure field type
1859 @ingroup ctfirfieldtypes
1860 @brief CTF IR structure field type.
1861
1862 @code
1863 #include <babeltrace/ctf-ir/field-types.h>
1864 @endcode
1865
1866 A CTF IR <strong><em>structure field type</em></strong> is
1867 a field type that you can use to create concrete @structfields.
1868
1869 You can create a structure field type
1870 with bt_ctf_field_type_structure_create(). This function creates
1871 an empty structure field type, with no fields.
1872
1873 You can add a field to a structure field type with
1874 bt_ctf_field_type_structure_add_field(). Two fields in a structure
1875 field type cannot have the same name.
1876
1877 You can set the \em minimum alignment of the structure fields described
1878 by a structure field type with the common
1879 bt_ctf_field_type_set_alignment() function. The \em effective alignment
1880 of the structure fields described by a structure field type, as per
1881 <a href="http://diamon.org/ctf/">CTF</a>, is the \em maximum value amongst
1882 the effective alignments of all its fields. Note that the effective
1883 alignment of @varfields is always 1.
1884
1885 You can set the byte order of <em>all the contained fields</em>,
1886 recursively, of a structure field type with the common
1887 bt_ctf_field_type_set_byte_order() function.
1888
1889 @sa ctfirstructfield
1890 @sa ctfirfieldtypes
1891
1892 @addtogroup ctfirstructfieldtype
1893 @{
1894 */
1895
1896 /**
1897 @brief Creates a default, empty @structft.
1898
1899 @returns Created structure field type,
1900 or \c NULL on error.
1901
1902 @postsuccessrefcountret1
1903 */
1904 extern struct bt_ctf_field_type *bt_ctf_field_type_structure_create(void);
1905
1906 /**
1907 @brief Returns the number of fields contained in the
1908 @structft \p struct_field_type.
1909
1910 @param[in] struct_field_type Structure field type of which to get
1911 the number of contained fields.
1912 @returns Number of fields contained in
1913 \p struct_field_type, or a negative
1914 value on error.
1915
1916 @prenotnull{struct_field_type}
1917 @preisstructft{struct_field_type}
1918 @postrefcountsame{struct_field_type}
1919 */
1920 extern int64_t bt_ctf_field_type_structure_get_field_count(
1921 struct bt_ctf_field_type *struct_field_type);
1922
1923 /**
1924 @brief Returns the field of the @structft \p struct_field_type
1925 at index \p index.
1926
1927 On success, the field's type is placed in \p *field_type if
1928 \p field_type is not \c NULL. The field's name is placed in
1929 \p *field_name if \p field_name is not \c NULL.
1930 \p struct_field_type remains the sole owner of \p *field_name.
1931
1932 @param[in] struct_field_type Structure field type of which to get
1933 the field at index \p index.
1934 @param[out] field_name Returned name of the field at index
1935 \p index (can be \c NULL).
1936 @param[out] field_type Returned field type of the field
1937 at index \p index (can be \c NULL).
1938 ­@param[in] index Index of the field to get from
1939 \p struct_field_type.
1940 @returns 0 on success, or a negative value on error.
1941
1942 @prenotnull{struct_field_type}
1943 @preisstructft{struct_field_type}
1944 @pre \p index is lesser than the number of fields contained in the
1945 structure field type \p struct_field_type (see
1946 bt_ctf_field_type_structure_get_field_count()).
1947 @postrefcountsame{struct_field_type}
1948 @post <strong>On success</strong>, the returned field's type is placed
1949 in \p *field_type and its reference count is incremented.
1950
1951 @sa bt_ctf_field_type_structure_get_field_type_by_name(): Finds a
1952 structure field type's field by name.
1953 */
1954 extern int bt_ctf_field_type_structure_get_field_by_index(
1955 struct bt_ctf_field_type *struct_field_type,
1956 const char **field_name, struct bt_ctf_field_type **field_type,
1957 uint64_t index);
1958
1959 /* Pre-2.0 CTF writer compatibility */
1960 #define bt_ctf_field_type_structure_get_field bt_ctf_field_type_structure_get_field_by_index
1961
1962 /**
1963 @brief Returns the type of the field named \p field_name found in
1964 the @structft \p struct_field_type.
1965
1966 @param[in] struct_field_type Structure field type of which to get
1967 a field's type.
1968 @param[in] field_name Name of the field to find.
1969 @returns Type of the field named \p field_name in
1970 \p struct_field_type, or
1971 \c NULL on error.
1972
1973 @prenotnull{struct_field_type}
1974 @prenotnull{field_name}
1975 @preisstructft{struct_field_type}
1976 @postrefcountsame{struct_field_type}
1977 @postsuccessrefcountretinc
1978
1979 @sa bt_ctf_field_type_structure_get_field_by_index(): Finds a
1980 structure field type's field by index.
1981 */
1982 extern
1983 struct bt_ctf_field_type *bt_ctf_field_type_structure_get_field_type_by_name(
1984 struct bt_ctf_field_type *struct_field_type,
1985 const char *field_name);
1986
1987 /**
1988 @brief Adds a field named \p field_name with the @ft
1989 \p field_type to the @structft \p struct_field_type.
1990
1991 On success, \p field_type becomes the child of \p struct_field_type.
1992
1993 This function adds the new field after the current last field of
1994 \p struct_field_type (append mode).
1995
1996 You \em cannot add a field named \p field_name if there's already a
1997 field named \p field_name in \p struct_field_type.
1998
1999 @param[in] struct_field_type Structure field type to which to add
2000 a new field.
2001 @param[in] field_type Field type of the field to add to
2002 \p struct_field_type.
2003 @param[in] field_name Name of the field to add to
2004 \p struct_field_type
2005 (copied on success).
2006 @returns 0 on success, or a negative value on error.
2007
2008 @prenotnull{struct_field_type}
2009 @prenotnull{field_type}
2010 @prenotnull{field_name}
2011 @preisstructft{struct_field_type}
2012 @pre \p field_type is not and does not contain \p struct_field_type,
2013 recursively, as a field's type.
2014 @prehot{struct_field_type}
2015 @postrefcountsame{struct_field_type}
2016 @postsuccessrefcountinc{field_type}
2017 */
2018 extern int bt_ctf_field_type_structure_add_field(
2019 struct bt_ctf_field_type *struct_field_type,
2020 struct bt_ctf_field_type *field_type,
2021 const char *field_name);
2022
2023 /** @} */
2024
2025 /**
2026 @defgroup ctfirarrayfieldtype CTF IR array field type
2027 @ingroup ctfirfieldtypes
2028 @brief CTF IR array field type.
2029
2030 @code
2031 #include <babeltrace/ctf-ir/field-types.h>
2032 @endcode
2033
2034 A CTF IR <strong><em>array field type</em></strong> is a field type that
2035 you can use to create concrete @arrayfields.
2036
2037 You can create an array field type
2038 with bt_ctf_field_type_array_create(). This function needs
2039 the @ft of the fields contained by the array fields described by the
2040 array field type to create.
2041
2042 @sa ctfirarrayfield
2043 @sa ctfirfieldtypes
2044
2045 @addtogroup ctfirarrayfieldtype
2046 @{
2047 */
2048
2049 /**
2050 @brief Creates a default @arrayft with
2051 \p element_field_type as the field type of the fields contained
2052 in its described @arrayfields of length \p length.
2053
2054 @param[in] element_field_type Field type of the fields contained in
2055 the array fields described by the
2056 created array field type.
2057 @param[in] length Length of the array fields described by
2058 the created array field type.
2059 @returns Created array field type, or
2060 \c NULL on error.
2061
2062 @prenotnull{element_field_type}
2063 @postsuccessrefcountinc{element_field_type}
2064 @postsuccessrefcountret1
2065 */
2066 extern struct bt_ctf_field_type *bt_ctf_field_type_array_create(
2067 struct bt_ctf_field_type *element_field_type,
2068 unsigned int length);
2069
2070 /**
2071 @brief Returns the @ft of the @fields contained in
2072 the @arrayfields described by the @arrayft \p array_field_type.
2073
2074 @param[in] array_field_type Array field type of which to get
2075 the type of the fields contained in its
2076 described array fields.
2077 @returns Type of the fields contained in the
2078 array fields described by
2079 \p array_field_type, or \c NULL
2080 on error.
2081
2082 @prenotnull{array_field_type}
2083 @preisarrayft{array_field_type}
2084 @postrefcountsame{array_field_type}
2085 @postsuccessrefcountretinc
2086 */
2087 extern struct bt_ctf_field_type *bt_ctf_field_type_array_get_element_type(
2088 struct bt_ctf_field_type *array_field_type);
2089
2090 /**
2091 @brief Returns the number of @fields contained in the
2092 @arrayfields described by the @arrayft \p array_field_type.
2093
2094 @param[in] array_field_type Array field type of which to get
2095 the number of fields contained in its
2096 described array fields.
2097 @returns Number of fields contained in the
2098 array fields described by
2099 \p array_field_type, or a negative value
2100 on error.
2101
2102 @prenotnull{array_field_type}
2103 @preisarrayft{array_field_type}
2104 @postrefcountsame{array_field_type}
2105 */
2106 extern int64_t bt_ctf_field_type_array_get_length(
2107 struct bt_ctf_field_type *array_field_type);
2108
2109 /** @} */
2110
2111 /**
2112 @defgroup ctfirseqfieldtype CTF IR sequence field type
2113 @ingroup ctfirfieldtypes
2114 @brief CTF IR sequence field type.
2115
2116 @code
2117 #include <babeltrace/ctf-ir/field-types.h>
2118 @endcode
2119
2120 A CTF IR <strong><em>sequence field type</em></strong> is
2121 a field type that you can use to create concrete @seqfields.
2122
2123 You can create a sequence field type with
2124 bt_ctf_field_type_sequence_create(). This function needs the @ft
2125 of the fields contained by the sequence fields described by the created
2126 sequence field type. This function also needs the length name of the
2127 sequence field type to create. The length name is used to automatically
2128 resolve the length's field type. See \ref ctfirfieldtypes to learn more
2129 about the automatic resolving.
2130
2131 @sa ctfirseqfield
2132 @sa ctfirfieldtypes
2133
2134 @addtogroup ctfirseqfieldtype
2135 @{
2136 */
2137
2138 /**
2139 @brief Creates a default @seqft with \p element_field_type as the
2140 @ft of the @fields contained in its described @seqfields
2141 with the length name \p length_name.
2142
2143 \p length_name can be an absolute or relative reference. See
2144 <a href="http://diamon.org/ctf/">CTF</a> for more details.
2145
2146 @param[in] element_field_type Field type of the fields contained in
2147 the sequence fields described by the
2148 created sequence field type.
2149 @param[in] length_name Length name (copied on success).
2150 @returns Created array field type, or
2151 \c NULL on error.
2152
2153 @prenotnull{element_field_type}
2154 @prenotnull{length_name}
2155 @postsuccessrefcountinc{element_field_type}
2156 @postsuccessrefcountret1
2157 */
2158 extern struct bt_ctf_field_type *bt_ctf_field_type_sequence_create(
2159 struct bt_ctf_field_type *element_field_type,
2160 const char *length_name);
2161
2162 /**
2163 @brief Returns the @ft of the @fields contained in the @seqft
2164 described by the @seqft \p sequence_field_type.
2165
2166 @param[in] sequence_field_type Sequence field type of which to get
2167 the type of the fields contained in its
2168 described sequence fields.
2169 @returns Type of the fields contained in the
2170 sequence fields described by
2171 \p sequence_field_type, or \c NULL
2172 on error.
2173
2174 @prenotnull{sequence_field_type}
2175 @preisseqft{sequence_field_type}
2176 @postrefcountsame{sequence_field_type}
2177 @postsuccessrefcountretinc
2178 */
2179 extern struct bt_ctf_field_type *bt_ctf_field_type_sequence_get_element_type(
2180 struct bt_ctf_field_type *sequence_field_type);
2181
2182 /**
2183 @brief Returns the length name of the @seqft \p sequence_field_type.
2184
2185 On success, \p sequence_field_type remains the sole owner of
2186 the returned string.
2187
2188 @param[in] sequence_field_type Sequence field type of which to get the
2189 length name.
2190 @returns Length name of \p sequence_field_type,
2191 or \c NULL on error.
2192
2193 @prenotnull{sequence_field_type}
2194 @preisseqft{sequence_field_type}
2195
2196 @sa bt_ctf_field_type_sequence_get_length_field_path(): Returns the
2197 length's CTF IR field path of a given sequence field type.
2198 */
2199 extern const char *bt_ctf_field_type_sequence_get_length_field_name(
2200 struct bt_ctf_field_type *sequence_field_type);
2201
2202 /**
2203 @brief Returns the length's CTF IR field path of the @seqft
2204 \p sequence_field_type.
2205
2206 The length's field path of a sequence field type is set when automatic
2207 resolving is performed (see \ref ctfirfieldtypes).
2208
2209 @param[in] sequence_field_type Sequence field type of which to get the
2210 length's field path.
2211 @returns Length's field path of
2212 \p sequence_field_type, or
2213 \c NULL if the length's field path is
2214 not set yet is not set or on error.
2215
2216 @prenotnull{sequence_field_type}
2217 @preisseqft{sequence_field_type}
2218 @postsuccessrefcountretinc
2219
2220 @sa bt_ctf_field_type_sequence_get_length_field_name(): Returns the
2221 length's name of a given sequence field type.
2222 */
2223 extern struct bt_ctf_field_path *bt_ctf_field_type_sequence_get_length_field_path(
2224 struct bt_ctf_field_type *sequence_field_type);
2225
2226 /** @} */
2227
2228 /**
2229 @defgroup ctfirvarfieldtype CTF IR variant field type
2230 @ingroup ctfirfieldtypes
2231 @brief CTF IR variant field type.
2232
2233 @code
2234 #include <babeltrace/ctf-ir/field-types.h>
2235 @endcode
2236
2237 A CTF IR <strong><em>variant field type</em></strong> is
2238 a field type that you can use to create concrete @varfields.
2239
2240 You can create a variant field type with
2241 bt_ctf_field_type_variant_create(). This function expects you to pass
2242 both the tag's @enumft and the tag name of the variant field type to
2243 create. The tag's field type is optional, as the Babeltrace system can
2244 automatically resolve it using the tag name. You can leave the tag name
2245 to \c NULL initially, and set it later with
2246 bt_ctf_field_type_variant_set_tag_name(). The tag name must be set when
2247 the variant field type is frozen. See \ref ctfirfieldtypes to learn more
2248 about the automatic resolving and the conditions under which a field
2249 type can be frozen.
2250
2251 You can add a field to a variant field type with
2252 bt_ctf_field_type_variant_add_field(). All the field names of a
2253 variant field type \em must exist as mapping names in its tag's @enumft.
2254
2255 The effective alignment of the @varfields described by a
2256 variant field type is always 1, but the individual fields of a
2257 @varfield can have custom alignments.
2258
2259 You can set the byte order of <em>all the contained fields</em>,
2260 recursively, of a variant field type with the common
2261 bt_ctf_field_type_set_byte_order() function.
2262
2263 @sa ctfirvarfield
2264 @sa ctfirfieldtypes
2265
2266 @addtogroup ctfirvarfieldtype
2267 @{
2268 */
2269
2270 /**
2271 @brief Creates a default, empty @varft with the tag's @enumft
2272 \p tag_field_type and the tag name \p tag_name.
2273
2274 \p tag_field_type can be \c NULL; the tag's field type can be
2275 automatically resolved from the variant field type's tag name (see
2276 \ref ctfirfieldtypes). If \p tag_name is \c NULL, it \em must be set
2277 with bt_ctf_field_type_variant_set_tag_name() \em before the variant
2278 field type is frozen.
2279
2280 \p tag_name can be an absolute or relative reference. See
2281 <a href="http://diamon.org/ctf/">CTF</a> for more details.
2282
2283 @param[in] tag_field_type Tag's enumeration field type
2284 (can be \c NULL).
2285 @param[in] tag_name Tag name (copied on success,
2286 can be \c NULL).
2287 @returns Created variant field type, or
2288 \c NULL on error.
2289
2290 @pre \p tag_field_type is an enumeration field type or \c NULL.
2291 @post <strong>On success, if \p tag_field_type is not \c NULL</strong>,
2292 its reference count is incremented.
2293 @postsuccessrefcountret1
2294 */
2295 extern struct bt_ctf_field_type *bt_ctf_field_type_variant_create(
2296 struct bt_ctf_field_type *tag_field_type,
2297 const char *tag_name);
2298
2299 /**
2300 @brief Returns the tag's @enumft of the @varft \p variant_field_type.
2301
2302 @param[in] variant_field_type Variant field type of which to get
2303 the tag's enumeration field type.
2304 @returns Tag's enumeration field type of
2305 \p variant_field_type, or \c NULL if the
2306 tag's field type is not set or on
2307 error.
2308
2309 @prenotnull{variant_field_type}
2310 @preisvarft{variant_field_type}
2311 @postrefcountsame{variant_field_type}
2312 @postsuccessrefcountretinc
2313 */
2314 extern struct bt_ctf_field_type *bt_ctf_field_type_variant_get_tag_type(
2315 struct bt_ctf_field_type *variant_field_type);
2316
2317 /**
2318 @brief Returns the tag name of the @varft \p variant_field_type.
2319
2320 On success, \p variant_field_type remains the sole owner of
2321 the returned string.
2322
2323 @param[in] variant_field_type Variant field type of which to get the
2324 tag name.
2325 @returns Tag name of \p variant_field_type, or
2326 \c NULL if the tag name is not set or
2327 on error.
2328
2329 @prenotnull{variant_field_type}
2330 @preisvarft{variant_field_type}
2331
2332 @sa bt_ctf_field_type_variant_set_tag_name(): Sets the tag name of
2333 a given variant field type.
2334 @sa bt_ctf_field_type_variant_get_tag_field_path(): Returns the tag's
2335 CTF IR field path of a given variant field type.
2336 */
2337 extern const char *bt_ctf_field_type_variant_get_tag_name(
2338 struct bt_ctf_field_type *variant_field_type);
2339
2340 /**
2341 @brief Sets the tag name of the @varft \p variant_field_type.
2342
2343 \p tag_name can be an absolute or relative reference. See
2344 <a href="http://diamon.org/ctf/">CTF</a> for more details.
2345
2346 @param[in] variant_field_type Variant field type of which to set
2347 the tag name.
2348 @param[in] tag_name Tag name of \p variant_field_type
2349 (copied on success).
2350 @returns 0 on success, or a negative value on error.
2351
2352 @prenotnull{variant_field_type}
2353 @prenotnull{name}
2354 @prehot{variant_field_type}
2355 @postrefcountsame{variant_field_type}
2356
2357 @sa bt_ctf_field_type_variant_get_tag_name(): Returns the tag name of
2358 a given variant field type.
2359 */
2360 extern int bt_ctf_field_type_variant_set_tag_name(
2361 struct bt_ctf_field_type *variant_field_type,
2362 const char *tag_name);
2363
2364 /**
2365 @brief Returns the tag's CTF IR field path of the @varft
2366 \p variant_field_type.
2367
2368 The tag's field path of a variant field type is set when automatic
2369 resolving is performed (see \ref ctfirfieldtypes).
2370
2371 @param[in] variant_field_type Variant field type of which to get the
2372 tag's field path.
2373 @returns Tag's field path of
2374 \p variant_field_type, or
2375 \c NULL if the tag's field path is not
2376 set yet is not set or on error.
2377
2378 @prenotnull{variant_field_type}
2379 @preisvarft{variant_field_type}
2380 @postsuccessrefcountretinc
2381
2382 @sa bt_ctf_field_type_variant_get_tag_name(): Returns the tag's
2383 name of a given variant field type.
2384 */
2385 extern struct bt_ctf_field_path *bt_ctf_field_type_variant_get_tag_field_path(
2386 struct bt_ctf_field_type *variant_field_type);
2387
2388 /**
2389 @brief Returns the number of fields (choices) contained in the @varft
2390 \p variant_field_type.
2391
2392 @param[in] variant_field_type Variant field type of which to get
2393 the number of contained fields.
2394 @returns Number of fields contained in
2395 \p variant_field_type, or a negative
2396 value on error.
2397
2398 @prenotnull{variant_field_type}
2399 @preisvarft{variant_field_type}
2400 @postrefcountsame{variant_field_type}
2401 */
2402 extern int64_t bt_ctf_field_type_variant_get_field_count(
2403 struct bt_ctf_field_type *variant_field_type);
2404
2405 /**
2406 @brief Returns the field (choice) of the @varft \p variant_field_type
2407 at index \p index.
2408
2409 On success, the field's type is placed in \p *field_type if
2410 \p field_type is not \c NULL. The field's name is placed in
2411 \p *field_name if \p field_name is not \c NULL.
2412 \p variant_field_type remains the sole owner of \p *field_name.
2413
2414 @param[in] variant_field_type Variant field type of which to get
2415 the field at index \p index.
2416 @param[out] field_name Returned name of the field at index
2417 \p index (can be \c NULL).
2418 @param[out] field_type Returned field type of the field
2419 at index \p index (can be \c NULL).
2420 ­@param[in] index Index of the field to get from
2421 \p variant_field_type.
2422 @returns 0 on success, or a negative value on error.
2423
2424 @prenotnull{variant_field_type}
2425 @preisvarft{variant_field_type}
2426 @pre \p index is lesser than the number of fields contained in the
2427 variant field type \p variant_field_type (see
2428 bt_ctf_field_type_variant_get_field_count()).
2429 @postrefcountsame{variant_field_type}
2430 @post <strong>On success</strong>, the returned field's type is placed
2431 in \p *field_type and its reference count is incremented.
2432
2433 @sa bt_ctf_field_type_variant_get_field_type_by_name(): Finds a variant
2434 field type's field by name.
2435 @sa bt_ctf_field_type_variant_get_field_type_from_tag(): Finds a variant
2436 field type's field by current tag value.
2437 */
2438 extern int bt_ctf_field_type_variant_get_field_by_index(
2439 struct bt_ctf_field_type *variant_field_type,
2440 const char **field_name,
2441 struct bt_ctf_field_type **field_type, uint64_t index);
2442
2443 /* Pre-2.0 CTF writer compatibility */
2444 #define bt_ctf_field_type_variant_get_field bt_ctf_field_type_variant_get_field_by_index
2445
2446 /**
2447 @brief Returns the type of the field (choice) named \p field_name
2448 found in the @varft \p variant_field_type.
2449
2450 @param[in] variant_field_type Variant field type of which to get
2451 a field's type.
2452 @param[in] field_name Name of the field to find.
2453 @returns Type of the field named \p field_name in
2454 \p variant_field_type, or
2455 \c NULL on error.
2456
2457 @prenotnull{variant_field_type}
2458 @prenotnull{field_name}
2459 @preisvarft{variant_field_type}
2460 @postrefcountsame{variant_field_type}
2461 @postsuccessrefcountretinc
2462
2463 @sa bt_ctf_field_type_variant_get_field_by_index(): Finds a variant field type's
2464 field by index.
2465 @sa bt_ctf_field_type_variant_get_field_type_from_tag(): Finds a variant
2466 field type's field by current tag value.
2467 */
2468 extern
2469 struct bt_ctf_field_type *bt_ctf_field_type_variant_get_field_type_by_name(
2470 struct bt_ctf_field_type *variant_field_type,
2471 const char *field_name);
2472
2473 /**
2474 @brief Returns the type of the field (choice) selected by the value of
2475 the @enumfield \p tag_field in the @varft \p variant_field_type.
2476
2477 \p tag_field is the current tag value.
2478
2479 The field type of \p tag_field, as returned by bt_ctf_field_get_type(),
2480 \em must be equivalent to the field type returned by
2481 bt_ctf_field_type_variant_get_tag_type() for \p variant_field_type.
2482
2483 @param[in] variant_field_type Variant field type of which to get
2484 a field's type.
2485 @param[in] tag_field Current tag value (variant field type's
2486 selector).
2487 @returns Type of the field selected by
2488 \p tag_field in \p variant_field_type,
2489 or \c NULL on error.
2490
2491 @prenotnull{variant_field_type}
2492 @prenotnull{tag_field}
2493 @preisvarft{variant_field_type}
2494 @preisenumfield{tag_field}
2495 @postrefcountsame{variant_field_type}
2496 @postrefcountsame{tag_field}
2497 @postsuccessrefcountretinc
2498
2499 @sa bt_ctf_field_type_variant_get_field_by_index(): Finds a variant field type's
2500 field by index.
2501 @sa bt_ctf_field_type_variant_get_field_type_by_name(): Finds a variant
2502 field type's field by name.
2503 */
2504 extern
2505 struct bt_ctf_field_type *bt_ctf_field_type_variant_get_field_type_from_tag(
2506 struct bt_ctf_field_type *variant_field_type,
2507 struct bt_ctf_field *tag_field);
2508
2509 /**
2510 @brief Adds a field (a choice) named \p field_name with the @ft
2511 \p field_type to the @varft \p variant_field_type.
2512
2513 On success, \p field_type becomes the child of \p variant_field_type.
2514
2515 You \em cannot add a field named \p field_name if there's already a
2516 field named \p field_name in \p variant_field_type.
2517
2518 \p field_name \em must name an existing mapping in the tag's
2519 enumeration field type of \p variant_field_type.
2520
2521 @param[in] variant_field_type Variant field type to which to add
2522 a new field.
2523 @param[in] field_type Field type of the field to add to
2524 \p variant_field_type.
2525 @param[in] field_name Name of the field to add to
2526 \p variant_field_type
2527 (copied on success).
2528 @returns 0 on success, or a negative value on error.
2529
2530 @prenotnull{variant_field_type}
2531 @prenotnull{field_type}
2532 @prenotnull{field_name}
2533 @preisvarft{variant_field_type}
2534 @pre \p field_type is not and does not contain \p variant_field_type,
2535 recursively, as a field's type.
2536 @prehot{variant_field_type}
2537 @postrefcountsame{variant_field_type}
2538 @postsuccessrefcountinc{field_type}
2539 */
2540 extern int bt_ctf_field_type_variant_add_field(
2541 struct bt_ctf_field_type *variant_field_type,
2542 struct bt_ctf_field_type *field_type,
2543 const char *field_name);
2544
2545 /** @} */
2546
2547 #ifdef __cplusplus
2548 }
2549 #endif
2550
2551 #endif /* BABELTRACE_CTF_IR_FIELD_TYPES_H */
This page took 0.111077 seconds and 5 git commands to generate.