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