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