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