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