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