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