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