Commit | Line | Data |
---|---|---|
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 | |
36 | extern "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 | ||
48 | A CTF IR <strong><em>field type</em></strong> is a field type that you | |
4089d5a6 | 49 | can use to create concrete @fields. |
78c8ab4f | 50 | |
4089d5a6 | 51 | You can create a @field object from a CTF IR field type object |
78c8ab4f PP |
52 | with bt_ctf_field_create(). |
53 | ||
54 | In the CTF IR hierarchy, you can set the root field types of three | |
55 | objects: | |
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 | ||
70 | As of Babeltrace \btversion, those six previous "root" field types | |
4089d5a6 | 71 | \em must be @structft objects. |
78c8ab4f | 72 | |
4089d5a6 PP |
73 | If, 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 | 75 | or tag field type: the length or tag string is enough for the Babeltrace |
4089d5a6 | 76 | system to resolve the needed field type depending on where this |
78c8ab4f PP |
77 | dynamic field type is located within the whole hierarchy. It is |
78 | guaranteed that this automatic resolving is performed for all the field | |
79 | types contained in a given | |
80 | \link ctfirstreamclass CTF IR stream class\endlink (and in its | |
81 | children \link ctfireventclass CTF IR event classes\endlink) once you | |
82 | add it to a \link ctfirtraceclass CTF IR trace class\endlink with | |
83 | bt_ctf_trace_add_stream_class(). Once a stream class is the child of | |
84 | a trace class, this automatic resolving is performed for the field | |
85 | types of an event class when you add it with | |
86 | bt_ctf_stream_class_add_event_class(). If the system cannot find a path | |
87 | to a field in the hierarchy for a dynamic field type, the adding | |
88 | function fails. | |
89 | ||
90 | The 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 | ||
140 | Each 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 | |
142 | with bt_ctf_field_type_get_type_id(). | |
143 | ||
144 | You can get a deep copy of a field type with bt_ctf_field_type_copy(). | |
145 | This function resets, in the field type copy, the resolved field type | |
146 | of the dynamic field types. The automatic resolving can be done again | |
147 | when you eventually call bt_ctf_event_create(), | |
148 | bt_ctf_stream_class_add_event_class(), or | |
149 | bt_ctf_trace_add_stream_class(). | |
150 | ||
151 | You \em must always use bt_ctf_field_type_compare() to compare two | |
152 | field types. Since some parts of the Babeltrace system can copy field | |
153 | types behind the scenes, you \em cannot rely on a simple field type | |
154 | pointer comparison. | |
155 | ||
156 | As with any Babeltrace object, CTF IR field type objects have | |
157 | <a href="https://en.wikipedia.org/wiki/Reference_counting">reference | |
158 | counts</a>. See \ref refs to learn more about the reference counting | |
159 | management of Babeltrace objects. | |
160 | ||
161 | The 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 |
177 | You cannot modify a frozen field type object: it is considered |
178 | immutable, 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 | */ | |
196 | struct bt_ctf_field_type; | |
adc315b8 JG |
197 | struct bt_ctf_event_class; |
198 | struct bt_ctf_event; | |
b92ddaaa | 199 | struct bt_ctf_field; |
b011f6b0 | 200 | struct bt_ctf_field_path; |
23320c3b | 201 | struct 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 | */ | |
212 | enum 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 | */ | |
229 | enum 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 | */ | |
241 | enum 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 | 277 | enum 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 | */ |
341 | extern 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 | */ | |
358 | extern 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 | */ | |
374 | extern 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 | */ | |
389 | extern 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 | */ | |
404 | extern 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 | */ | |
419 | extern 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 | */ | |
434 | extern 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 | */ | |
449 | extern 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 | */ | |
464 | extern 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 | 477 | enum 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 | 502 | enum 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 | */ | |
531 | extern 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 | */ | |
554 | extern 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 |
561 | You 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 | */ | |
577 | extern 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 | |
584 | If \p field_type is a compound field type, this function also | |
585 | recursively 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 | */ | |
603 | extern 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 | ||
618 | You \em must use this function to compare two field types: it is not | |
619 | safe to compare two pointer values directly, because, for internal | |
620 | reasons, some parts of the Babeltrace system can copy user field types | |
621 | and 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 | */ | |
634 | extern 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 | |
640 | You can copy a frozen field type: the resulting copy is | |
641 | <em>not frozen</em>. | |
642 | ||
4089d5a6 | 643 | This function resets the tag field type of a copied @varft. The |
78c8ab4f PP |
644 | automatic field resolving which some functions of the API perform |
645 | can set it again when the returned field type is used (learn more | |
646 | in 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 | */ |
657 | extern 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 | ||
673 | A CTF IR <strong><em>integer field type</em></strong> is a field type that | |
4089d5a6 | 674 | you can use to create concrete @intfield objects. |
78c8ab4f PP |
675 | |
676 | You can create an integer field type | |
677 | with bt_ctf_field_type_integer_create(). | |
678 | ||
679 | An 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 | */ |
746 | enum 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 |
773 | extern 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 | 791 | extern 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 | 813 | extern 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 | 837 | extern 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 | 860 | extern 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 | */ | |
886 | extern 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 | 909 | extern 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 |
916 | You 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 |
918 | 8-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 | 938 | extern 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 | |
946 | The mapped clock class, if any, indicates the class of the clock which | |
4089d5a6 | 947 | an @intfield described by \p int_field_type should sample or update. |
78c8ab4f PP |
948 | This 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 | 964 | extern 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 | |
971 | The mapped clock class, if any, indicates the class of the clock which | |
972 | an integer field described by \p int_field_type should sample or update. | |
973 | This 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 | 990 | extern 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 | ||
1005 | A CTF IR <strong><em>floating point number field type</em></strong> is | |
4089d5a6 | 1006 | a field type that you can use to create concrete @floatfields. |
78c8ab4f PP |
1007 | |
1008 | You can create a floating point number field type | |
1009 | with bt_ctf_field_type_floating_point_create(). | |
1010 | ||
1011 | A 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 | */ | |
1066 | extern 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 | */ | |
1089 | extern 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 | |
1096 | As 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 | */ | |
1117 | extern 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 | |
1125 | On success, the returned value is the sum of the mantissa \em and | |
1126 | sign 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 | */ | |
1145 | extern 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 | |
1153 | As 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 | */ | |
1174 | extern 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 | ||
1189 | A CTF IR <strong><em>enumeration field type</em></strong> is | |
4089d5a6 | 1190 | a field type that you can use to create concrete @enumfields. |
78c8ab4f | 1191 | |
4089d5a6 PP |
1192 | You can create an enumeration field type with |
1193 | bt_ctf_field_type_enumeration_create(). This function needs a @intft | |
1194 | which represents the storage field type of the created enumeration field | |
1195 | type. In other words, an enumeration field type wraps an integer field | |
1196 | type and adds label-value mappings to it. | |
78c8ab4f PP |
1197 | |
1198 | An 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 | ||
1204 | You can add a mapping to an enumeration field type with | |
1205 | bt_ctf_field_type_enumeration_add_mapping() or | |
1206 | bt_ctf_field_type_enumeration_add_mapping_unsigned(), depending on the | |
4089d5a6 | 1207 | signedness of the wrapped @intft. |
78c8ab4f | 1208 | |
5c3f3b7e PP |
1209 | You can find mappings by name or by value with the following find |
1210 | operations: | |
1211 | ||
1212 | - bt_ctf_field_type_enumeration_find_mappings_by_name(): Finds the | |
1213 | mappings with a given name. | |
1214 | - bt_ctf_field_type_enumeration_find_mappings_by_unsigned_value(): | |
1215 | Finds the mappings which contain a given unsigned value in their | |
1216 | range. | |
1217 | - bt_ctf_field_type_enumeration_find_mappings_by_signed_value(): | |
1218 | Finds the mappings which contain a given signed value in their range. | |
1219 | ||
1220 | Those functions return a @enumftiter on the result set of the find | |
1221 | operation. | |
1222 | ||
96e8f959 MD |
1223 | Many mappings can share the same name, and the ranges of a given |
1224 | enumeration field type are allowed to overlap. For example, | |
78c8ab4f PP |
1225 | this is a valid set of mappings: |
1226 | ||
1227 | @verbatim | |
1228 | APPLE -> [ 3, 19] | |
1229 | BANANA -> [-15, 1] | |
1230 | CHERRY -> [ 25, 34] | |
1231 | APPLE -> [ 55, 55] | |
1232 | @endverbatim | |
1233 | ||
96e8f959 | 1234 | The following set of mappings is also valid: |
78c8ab4f PP |
1235 | |
1236 | @verbatim | |
1237 | APPLE -> [ 3, 19] | |
1238 | BANANA -> [-15, 1] | |
1239 | CHERRY -> [ 25, 34] | |
1240 | APPLE -> [ 30, 55] | |
1241 | @endverbatim | |
1242 | ||
1243 | Here, the range of the second \c APPLE mapping overlaps the range of | |
1244 | the \c CHERRY mapping. | |
1245 | ||
5c3f3b7e | 1246 | @sa ctfirenumftmappingiter |
78c8ab4f PP |
1247 | @sa ctfirenumfield |
1248 | @sa ctfirfieldtypes | |
1249 | ||
1250 | @addtogroup ctfirenumfieldtype | |
1251 | @{ | |
1252 | */ | |
1253 | ||
1254 | /** | |
4089d5a6 | 1255 | @brief Creates a default @enumft wrapping the @intft \p int_field_type. |
78c8ab4f PP |
1256 | |
1257 | @param[in] int_field_type Integer field type wrapped by the | |
1258 | created enumeration field type. | |
1259 | @returns Created enumeration field type, | |
1260 | or \c NULL on error. | |
1261 | ||
1262 | @prenotnull{int_field_type} | |
1263 | @preisintft{int_field_type} | |
1264 | @postsuccessrefcountinc{int_field_type} | |
1265 | @postsuccessrefcountret1 | |
1266 | */ | |
1267 | extern struct bt_ctf_field_type *bt_ctf_field_type_enumeration_create( | |
1268 | struct bt_ctf_field_type *int_field_type); | |
1269 | ||
1270 | /** | |
4089d5a6 | 1271 | @brief Returns the @intft wrapped by the @enumft \p enum_field_type. |
78c8ab4f PP |
1272 | |
1273 | @param[in] enum_field_type Enumeration field type of which to get | |
1274 | the wrapped integer field type. | |
1275 | @returns Integer field type wrapped by | |
1276 | \p enum_field_type, or \c NULL on | |
1277 | error. | |
1278 | ||
1279 | @prenotnull{enum_field_type} | |
1280 | @preisenumft{enum_field_type} | |
1281 | @postrefcountsame{enum_field_type} | |
1282 | @postsuccessrefcountretinc | |
1283 | */ | |
1284 | extern | |
1285 | struct bt_ctf_field_type *bt_ctf_field_type_enumeration_get_container_type( | |
1286 | struct bt_ctf_field_type *enum_field_type); | |
1287 | ||
1288 | /** | |
4089d5a6 PP |
1289 | @brief Returns the number of mappings contained in the |
1290 | @enumft \p enum_field_type. | |
78c8ab4f PP |
1291 | |
1292 | @param[in] enum_field_type Enumeration field type of which to get | |
1293 | the number of contained mappings. | |
1294 | @returns Number of mappings contained in | |
1295 | \p enum_field_type, or a negative | |
1296 | value on error. | |
1297 | ||
1298 | @prenotnull{enum_field_type} | |
1299 | @preisenumft{enum_field_type} | |
1300 | @postrefcountsame{enum_field_type} | |
1301 | */ | |
1302 | extern int bt_ctf_field_type_enumeration_get_mapping_count( | |
1303 | struct bt_ctf_field_type *enum_field_type); | |
1304 | ||
1305 | /** | |
4089d5a6 | 1306 | @brief Returns the signed mapping of the @enumft |
78c8ab4f PP |
1307 | \p enum_field_type at index \p index. |
1308 | ||
4089d5a6 PP |
1309 | The @intft wrapped by \p enum_field_type, as returned by |
1310 | bt_ctf_field_type_enumeration_get_container_type(), must be \b signed | |
1311 | to use this function. | |
78c8ab4f PP |
1312 | |
1313 | On success, \p enum_field_type remains the sole owner of \p *name. | |
1314 | ||
1315 | @param[in] enum_field_type Enumeration field type of which to get | |
1316 | the mapping at index \p index. | |
8dc7eb94 | 1317 | @param[in] index Index of the mapping to get from |
78c8ab4f PP |
1318 | \p enum_field_type. |
1319 | @param[out] name Returned name of the mapping at index | |
1320 | \p index. | |
1321 | @param[out] range_begin Returned beginning of the range | |
1322 | (included) of the mapping at index \p | |
1323 | index. | |
1324 | @param[out] range_end Returned end of the range (included) of | |
1325 | the mapping at index \p index. | |
1326 | @returns 0 on success, or a negative value on error. | |
1327 | ||
1328 | @prenotnull{enum_field_type} | |
1329 | @prenotnull{name} | |
1330 | @prenotnull{range_begin} | |
1331 | @prenotnull{range_end} | |
1332 | @preisenumft{enum_field_type} | |
4089d5a6 | 1333 | @pre The wrapped @intft of \p enum_field_type is signed. |
78c8ab4f PP |
1334 | @pre \p index is lesser than the number of mappings contained in the |
1335 | enumeration field type \p enum_field_type (see | |
1336 | bt_ctf_field_type_enumeration_get_mapping_count()). | |
1337 | @postrefcountsame{enum_field_type} | |
1338 | ||
cfb61c11 JG |
1339 | @sa bt_ctf_field_type_enumeration_get_mapping_unsigned(): Returns the |
1340 | unsigned mapping contained by a given enumeration field type | |
78c8ab4f PP |
1341 | at a given index. |
1342 | */ | |
96e8f959 | 1343 | extern int bt_ctf_field_type_enumeration_get_mapping_signed( |
78c8ab4f PP |
1344 | struct bt_ctf_field_type *enum_field_type, int index, |
1345 | const char **name, int64_t *range_begin, int64_t *range_end); | |
1346 | ||
1347 | /** | |
4089d5a6 PP |
1348 | @brief Returns the unsigned mapping of the @enumft |
1349 | \p enum_field_type at index \p index. | |
78c8ab4f | 1350 | |
4089d5a6 | 1351 | The @intft wrapped by \p enum_field_type, as returned by |
78c8ab4f PP |
1352 | bt_ctf_field_type_enumeration_get_container_type(), must be |
1353 | \b unsigned to use this function. | |
1354 | ||
1355 | On success, \p enum_field_type remains the sole owner of \p *name. | |
1356 | ||
1357 | @param[in] enum_field_type Enumeration field type of which to get | |
1358 | the mapping at index \p index. | |
8dc7eb94 | 1359 | @param[in] index Index of the mapping to get from |
78c8ab4f PP |
1360 | \p enum_field_type. |
1361 | @param[out] name Returned name of the mapping at index | |
1362 | \p index. | |
1363 | @param[out] range_begin Returned beginning of the range | |
1364 | (included) of the mapping at index \p | |
1365 | index. | |
1366 | @param[out] range_end Returned end of the range (included) of | |
1367 | the mapping at index \p index. | |
1368 | @returns 0 on success, or a negative value on error. | |
1369 | ||
1370 | @prenotnull{enum_field_type} | |
1371 | @prenotnull{name} | |
1372 | @prenotnull{range_begin} | |
1373 | @prenotnull{range_end} | |
1374 | @preisenumft{enum_field_type} | |
4089d5a6 | 1375 | @pre The wrapped @intft of \p enum_field_type is unsigned. |
78c8ab4f PP |
1376 | @pre \p index is lesser than the number of mappings contained in the |
1377 | enumeration field type \p enum_field_type (see | |
1378 | bt_ctf_field_type_enumeration_get_mapping_count()). | |
1379 | @postrefcountsame{enum_field_type} | |
1380 | ||
cfb61c11 JG |
1381 | @sa bt_ctf_field_type_enumeration_get_mapping_signed(): Returns the |
1382 | signed mapping contained by a given enumeration field type | |
78c8ab4f PP |
1383 | at a given index. |
1384 | */ | |
1385 | extern int bt_ctf_field_type_enumeration_get_mapping_unsigned( | |
1386 | struct bt_ctf_field_type *enum_field_type, int index, | |
1387 | const char **name, uint64_t *range_begin, | |
1388 | uint64_t *range_end); | |
1389 | ||
8dc7eb94 | 1390 | /** |
5c3f3b7e PP |
1391 | @brief Finds the mappings of the @enumft \p enum_field_type which |
1392 | are named \p name. | |
8dc7eb94 | 1393 | |
5c3f3b7e PP |
1394 | This function returns an iterator on the result set of this find |
1395 | operation. See \ref ctfirenumftmappingiter for more details. | |
1396 | ||
1397 | @param[in] enum_field_type Enumeration field type of which to find | |
1398 | the mappings named \p name. | |
1399 | @param[in] name Name of the mappings to find in | |
1400 | \p enum_field_type. | |
1401 | @returns @enumftiter on the set of mappings named | |
1402 | \p name in \p enum_field_type, or | |
1403 | \c NULL if no mappings were found or | |
1404 | on error. | |
8dc7eb94 JG |
1405 | |
1406 | @prenotnull{enum_field_type} | |
1407 | @prenotnull{name} | |
1408 | @preisenumft{enum_field_type} | |
1409 | @postrefcountsame{enum_field_type} | |
1410 | @postsuccessrefcountret1 | |
5c3f3b7e PP |
1411 | @post <strong>On success</strong>, the returned @enumftiter can iterate |
1412 | on at least one mapping. | |
1413 | ||
1414 | @sa bt_ctf_field_type_enumeration_find_mappings_by_signed_value(): Finds | |
1415 | the mappings of a given enumeration field type which contain | |
1416 | a given signed value in their range. | |
1417 | @sa bt_ctf_field_type_enumeration_find_mappings_by_unsigned_value(): Finds | |
1418 | the mappings of a given enumeration field type which contain | |
1419 | a given unsigned value in their range. | |
8dc7eb94 JG |
1420 | */ |
1421 | extern struct bt_ctf_field_type_enumeration_mapping_iterator * | |
1422 | bt_ctf_field_type_enumeration_find_mappings_by_name( | |
1423 | struct bt_ctf_field_type *enum_field_type, | |
1424 | const char *name); | |
1425 | ||
1426 | /** | |
5c3f3b7e PP |
1427 | @brief Finds the mappings of the @enumft \p enum_field_type which |
1428 | contain the signed value \p value in their range. | |
8dc7eb94 | 1429 | |
5c3f3b7e PP |
1430 | This function returns an iterator on the result set of this find |
1431 | operation. See \ref ctfirenumftmappingiter for more details. | |
1432 | ||
1433 | @param[in] enum_field_type Enumeration field type of which to find | |
1434 | the mappings which contain \p value. | |
1435 | @param[in] value Value to find in the ranges of the | |
1436 | mappings of \p enum_field_type. | |
1437 | @returns @enumftiter on the set of mappings of | |
1438 | \p enum_field_type which contain | |
1439 | \p value in their range, or \c NULL if | |
1440 | no mappings were found or on error. | |
8dc7eb94 JG |
1441 | |
1442 | @prenotnull{enum_field_type} | |
8dc7eb94 JG |
1443 | @preisenumft{enum_field_type} |
1444 | @postrefcountsame{enum_field_type} | |
1445 | @postsuccessrefcountret1 | |
5c3f3b7e PP |
1446 | @post <strong>On success</strong>, the returned @enumftiter can iterate |
1447 | on at least one mapping. | |
1448 | ||
1449 | @sa bt_ctf_field_type_enumeration_find_mappings_by_name(): Finds the | |
1450 | mappings of a given enumeration field type which have a given | |
1451 | name. | |
1452 | @sa bt_ctf_field_type_enumeration_find_mappings_by_unsigned_value(): Finds | |
1453 | the mappings of a given enumeration field type which contain | |
1454 | a given unsigned value in their range. | |
8dc7eb94 JG |
1455 | */ |
1456 | extern struct bt_ctf_field_type_enumeration_mapping_iterator * | |
1457 | bt_ctf_field_type_enumeration_find_mappings_by_signed_value( | |
1458 | struct bt_ctf_field_type *enum_field_type, | |
1459 | int64_t value); | |
1460 | ||
1461 | /** | |
5c3f3b7e PP |
1462 | @brief Finds the mappings of the @enumft \p enum_field_type which |
1463 | contain the unsigned value \p value in their range. | |
1464 | ||
1465 | This function returns an iterator on the result set of this find | |
1466 | operation. See \ref ctfirenumftmappingiter for more details. | |
1467 | ||
1468 | @param[in] enum_field_type Enumeration field type of which to find | |
1469 | the mappings which contain \p value. | |
1470 | @param[in] value Value to find in the ranges of the | |
1471 | mappings of \p enum_field_type. | |
1472 | @returns @enumftiter on the set of mappings of | |
1473 | \p enum_field_type which contain | |
1474 | \p value in their range, or \c NULL | |
1475 | if no mappings were found or | |
1476 | on error. | |
8dc7eb94 JG |
1477 | |
1478 | @prenotnull{enum_field_type} | |
8dc7eb94 JG |
1479 | @preisenumft{enum_field_type} |
1480 | @postrefcountsame{enum_field_type} | |
1481 | @postsuccessrefcountret1 | |
5c3f3b7e PP |
1482 | @post <strong>On success</strong>, the returned @enumftiter can iterate |
1483 | on at least one mapping. | |
1484 | ||
1485 | @sa bt_ctf_field_type_enumeration_find_mappings_by_name(): Finds the | |
1486 | mappings of a given enumeration field type which have a given | |
1487 | name. | |
1488 | @sa bt_ctf_field_type_enumeration_find_mappings_by_signed_value(): Finds | |
1489 | the mappings of a given enumeration field type which contain | |
1490 | a given unsigned value in their range. | |
8dc7eb94 JG |
1491 | */ |
1492 | extern struct bt_ctf_field_type_enumeration_mapping_iterator * | |
1493 | bt_ctf_field_type_enumeration_find_mappings_by_unsigned_value( | |
1494 | struct bt_ctf_field_type *enum_field_type, | |
1495 | uint64_t value); | |
1496 | ||
78c8ab4f | 1497 | /** |
4089d5a6 PP |
1498 | @brief Adds a mapping to the @enumft \p enum_field_type which maps the |
1499 | name \p name to the signed range \p range_begin (included) to | |
1500 | \p range_end (included). | |
78c8ab4f PP |
1501 | |
1502 | Make \p range_begin and \p range_end the same value to add a mapping | |
1503 | to a single value. | |
1504 | ||
4089d5a6 | 1505 | The @intft wrapped by \p enum_field_type, as returned by |
78c8ab4f PP |
1506 | bt_ctf_field_type_enumeration_get_container_type(), must be |
1507 | \b signed to use this function. | |
1508 | ||
96e8f959 | 1509 | A mapping in \p enum_field_type can exist with the name \p name. |
78c8ab4f PP |
1510 | |
1511 | @param[in] enum_field_type Enumeration field type to which to add | |
1512 | a mapping. | |
1513 | @param[in] name Name of the mapping to add (copied | |
1514 | on success). | |
1515 | @param[in] range_begin Beginning of the range of the mapping | |
1516 | (included). | |
1517 | @param[in] range_end End of the range of the mapping | |
1518 | (included). | |
1519 | @returns 0 on success, or a negative value on error. | |
1520 | ||
1521 | @prenotnull{enum_field_type} | |
1522 | @prenotnull{name} | |
1523 | @preisenumft{enum_field_type} | |
4089d5a6 | 1524 | @pre The wrapped @intft of \p enum_field_type is signed. |
78c8ab4f PP |
1525 | @pre \p range_end is greater than or equal to \p range_begin. |
1526 | @postrefcountsame{enum_field_type} | |
1527 | ||
1528 | @sa bt_ctf_field_type_enumeration_add_mapping_unsigned(): Adds an | |
1529 | unsigned mapping to a given enumeration field type. | |
1530 | */ | |
1531 | extern int bt_ctf_field_type_enumeration_add_mapping( | |
1532 | struct bt_ctf_field_type *enum_field_type, const char *name, | |
1533 | int64_t range_begin, int64_t range_end); | |
adc315b8 | 1534 | |
78c8ab4f | 1535 | /** |
4089d5a6 PP |
1536 | @brief Adds a mapping to the @enumft \p enum_field_type which maps |
1537 | the name \p name to the unsigned | |
78c8ab4f PP |
1538 | range \p range_begin (included) to \p range_end (included). |
1539 | ||
1540 | Make \p range_begin and \p range_end the same value to add a mapping | |
1541 | to a single value. | |
1542 | ||
4089d5a6 | 1543 | The @intft wrapped by \p enum_field_type, as returned by |
78c8ab4f PP |
1544 | bt_ctf_field_type_enumeration_get_container_type(), must be |
1545 | \b unsigned to use this function. | |
1546 | ||
96e8f959 | 1547 | A mapping in \p enum_field_type can exist with the name \p name. |
78c8ab4f PP |
1548 | |
1549 | @param[in] enum_field_type Enumeration field type to which to add | |
1550 | a mapping. | |
1551 | @param[in] name Name of the mapping to add (copied | |
1552 | on success). | |
1553 | @param[in] range_begin Beginning of the range of the mapping | |
1554 | (included). | |
1555 | @param[in] range_end End of the range of the mapping | |
1556 | (included). | |
1557 | @returns 0 on success, or a negative value on error. | |
1558 | ||
1559 | @prenotnull{enum_field_type} | |
1560 | @prenotnull{name} | |
1561 | @preisenumft{enum_field_type} | |
4089d5a6 | 1562 | @pre The wrapped @intft of \p enum_field_type is unsigned. |
78c8ab4f PP |
1563 | @pre \p range_end is greater than or equal to \p range_begin. |
1564 | @postrefcountsame{enum_field_type} | |
1565 | ||
1566 | @sa bt_ctf_field_type_enumeration_add_mapping(): Adds a signed | |
1567 | mapping to a given enumeration field type. | |
1568 | */ | |
1569 | extern int bt_ctf_field_type_enumeration_add_mapping_unsigned( | |
1570 | struct bt_ctf_field_type *enum_field_type, const char *name, | |
1571 | uint64_t range_begin, uint64_t range_end); | |
b92ddaaa | 1572 | |
78c8ab4f | 1573 | /** @} */ |
adc315b8 | 1574 | |
cfb61c11 | 1575 | /** |
5c3f3b7e PP |
1576 | @defgroup ctfirenumftmappingiter CTF IR enumeration field type mapping iterator |
1577 | @ingroup ctfirenumfieldtype | |
1578 | @brief CTF IR enumeration field type mapping iterator. | |
cfb61c11 JG |
1579 | |
1580 | @code | |
1581 | #include <babeltrace/ctf-ir/field-types.h> | |
1582 | @endcode | |
1583 | ||
5c3f3b7e PP |
1584 | A CTF IR <strong><em>enumeration field type mapping |
1585 | iterator</em></strong> is an iterator on @enumft mappings. | |
1586 | ||
1587 | You can get an enumeration mapping iterator from one of the following | |
1588 | functions: | |
1589 | ||
1590 | - Find operations of an @enumft object: | |
1591 | - bt_ctf_field_type_enumeration_find_mappings_by_name(): Finds the | |
1592 | mappings with a given name. | |
1593 | - bt_ctf_field_type_enumeration_find_mappings_by_unsigned_value(): | |
1594 | Finds the mappings which contain a given unsigned value in their | |
1595 | range. | |
1596 | - bt_ctf_field_type_enumeration_find_mappings_by_signed_value(): | |
1597 | Finds the mappings which contain a given signed value in their range. | |
1598 | - bt_ctf_field_enumeration_get_mappings(): Finds the mappings in the | |
1599 | @enumft of an @enumfield containing its current integral value in | |
1600 | their range. | |
1601 | ||
1602 | Those functions guarantee that the returned iterator can iterate on | |
1603 | at least one mapping. Otherwise, they return \c NULL. | |
1604 | ||
1605 | You can get the name and the range of a mapping iterator's current | |
1606 | mapping with | |
1607 | bt_ctf_field_type_enumeration_mapping_iterator_get_signed() | |
1608 | or | |
1609 | bt_ctf_field_type_enumeration_mapping_iterator_get_unsigned(), | |
1610 | depending on the signedness of the @intft wrapped by the | |
1611 | @enumft. If you only need the name of the current mapping, you can | |
1612 | use any of the two functions and set the \p range_begin and \p range_end | |
1613 | parameters to \c NULL. | |
1614 | ||
1615 | You can advance an enumeration field type mapping iterator to the next | |
1616 | mapping with | |
1617 | bt_ctf_field_type_enumeration_mapping_iterator_next(). This | |
1618 | function returns a negative value when you reach the end of the | |
1619 | result set. | |
1620 | ||
1621 | As with any Babeltrace object, CTF IR enumeration field type mapping | |
1622 | iterator objects have <a | |
1623 | href="https://en.wikipedia.org/wiki/Reference_counting">reference | |
1624 | counts</a>. See \ref refs to learn more about the reference counting | |
1625 | management of Babeltrace objects. | |
cfb61c11 JG |
1626 | |
1627 | @sa ctfirenumfieldtype | |
cfb61c11 | 1628 | |
5c3f3b7e | 1629 | @addtogroup ctfirenumftmappingiter |
cfb61c11 JG |
1630 | @{ |
1631 | */ | |
1632 | ||
1633 | /** | |
5c3f3b7e PP |
1634 | @struct bt_ctf_field_type_enumeration_mapping_iterator |
1635 | @brief A CTF IR enumeration field type mapping iterator. | |
1636 | @sa ctfirenumftmappingiter | |
cfb61c11 | 1637 | */ |
cfb61c11 JG |
1638 | |
1639 | /** | |
5c3f3b7e PP |
1640 | @brief Returns the name and the range of the current (signed) mapping |
1641 | of the @enumftiter \p iter. | |
cfb61c11 | 1642 | |
5c3f3b7e PP |
1643 | If one of \p range_begin or \p range_end is not \c NULL, the @intft |
1644 | wrapped by the @enumft from which \p iter was obtained, as returned by | |
cfb61c11 | 1645 | bt_ctf_field_type_enumeration_get_container_type(), must be |
5c3f3b7e PP |
1646 | \b signed to use this function. Otherwise, if you only need to get the |
1647 | name of the current mapping, set \p range_begin and \p range_end to | |
1648 | \c NULL. | |
1649 | ||
1650 | On success, if \p name is not \c NULL, \p *name remains valid as long | |
1651 | as \p iter exists and | |
1652 | bt_ctf_field_type_enumeration_mapping_iterator_next() is | |
1653 | \em not called on \p iter. | |
1654 | ||
1655 | @param[in] iter Enumeration field type mapping iterator | |
1656 | of which to get the range of the current | |
1657 | mapping. | |
1658 | @param[out] name Returned name of the current mapping of | |
1659 | \p iter (can be \c NULL to ignore). | |
cfb61c11 | 1660 | @param[out] range_begin Returned beginning of the range |
5c3f3b7e PP |
1661 | (included) of the current mapping of |
1662 | \p iter (can be \c NULL to ignore). | |
1663 | @param[out] range_end Returned end of the range | |
1664 | (included) of the current mapping of | |
1665 | \p iter (can be \c NULL to ignore). | |
cfb61c11 JG |
1666 | @returns 0 on success, or a negative value on error. |
1667 | ||
1668 | @prenotnull{iter} | |
cfb61c11 JG |
1669 | @postrefcountsame{iter} |
1670 | ||
5c3f3b7e PP |
1671 | @sa bt_ctf_field_type_enumeration_mapping_iterator_get_unsigned(): |
1672 | Returns the name and the unsigned range of the current mapping | |
1673 | of a given enumeration field type mapping iterator. | |
cfb61c11 JG |
1674 | */ |
1675 | extern int bt_ctf_field_type_enumeration_mapping_iterator_get_signed( | |
1676 | struct bt_ctf_field_type_enumeration_mapping_iterator *iter, | |
5c3f3b7e | 1677 | const char **name, int64_t *range_begin, int64_t *range_end); |
cfb61c11 JG |
1678 | |
1679 | /** | |
5c3f3b7e PP |
1680 | @brief Returns the name and the range of the current (unsigned) mapping |
1681 | of the @enumftiter \p iter. | |
cfb61c11 | 1682 | |
5c3f3b7e PP |
1683 | If one of \p range_begin or \p range_end is not \c NULL, the @intft |
1684 | wrapped by the @enumft from which \p iter was obtained, as returned by | |
cfb61c11 | 1685 | bt_ctf_field_type_enumeration_get_container_type(), must be |
5c3f3b7e PP |
1686 | \b unsigned to use this function. Otherwise, if you only need to get the |
1687 | name of the current mapping, set \p range_begin and \p range_end to | |
1688 | \c NULL. | |
1689 | ||
1690 | On success, if \p name is not \c NULL, \p *name remains valid as long | |
1691 | as \p iter exists and | |
1692 | bt_ctf_field_type_enumeration_mapping_iterator_next() is | |
1693 | \em not called on \p iter. | |
1694 | ||
1695 | @param[in] iter Enumeration field type mapping iterator | |
1696 | of which to get the range of the current | |
1697 | mapping. | |
1698 | @param[out] name Returned name of the current mapping of | |
1699 | \p iter (can be \c NULL to ignore). | |
cfb61c11 | 1700 | @param[out] range_begin Returned beginning of the range |
5c3f3b7e PP |
1701 | (included) of the current mapping of |
1702 | \p iter (can be \c NULL to ignore). | |
1703 | @param[out] range_end Returned end of the range | |
1704 | (included) of the current mapping of | |
1705 | \p iter (can be \c NULL to ignore). | |
cfb61c11 JG |
1706 | @returns 0 on success, or a negative value on error. |
1707 | ||
1708 | @prenotnull{iter} | |
cfb61c11 JG |
1709 | @postrefcountsame{iter} |
1710 | ||
5c3f3b7e PP |
1711 | @sa |
1712 | bt_ctf_field_type_enumeration_mapping_iterator_get_signed(): | |
1713 | Returns the name and the signed range of the current mapping of | |
1714 | a given enumeration field type mapping iterator. | |
cfb61c11 JG |
1715 | */ |
1716 | extern int bt_ctf_field_type_enumeration_mapping_iterator_get_unsigned( | |
1717 | struct bt_ctf_field_type_enumeration_mapping_iterator *iter, | |
5c3f3b7e | 1718 | const char **name, uint64_t *range_begin, uint64_t *range_end); |
cfb61c11 JG |
1719 | |
1720 | /** | |
5c3f3b7e | 1721 | @brief Advances the @enumftiter \p iter to the next mapping. |
cfb61c11 | 1722 | |
5c3f3b7e PP |
1723 | @param[in] iter Enumeration field type mapping iterator to |
1724 | advance. | |
1725 | @returns 0 on success, or a negative value on error or | |
1726 | when you reach the end of the set. | |
cfb61c11 JG |
1727 | |
1728 | @prenotnull{iter} | |
1729 | @postrefcountsame{iter} | |
1730 | */ | |
1731 | extern int bt_ctf_field_type_enumeration_mapping_iterator_next( | |
1732 | struct bt_ctf_field_type_enumeration_mapping_iterator *iter); | |
1733 | ||
1734 | /** @} */ | |
1735 | ||
78c8ab4f PP |
1736 | /** |
1737 | @defgroup ctfirstringfieldtype CTF IR string field type | |
1738 | @ingroup ctfirfieldtypes | |
1739 | @brief CTF IR string field type. | |
b92ddaaa | 1740 | |
78c8ab4f PP |
1741 | @code |
1742 | #include <babeltrace/ctf-ir/field-types.h> | |
1743 | @endcode | |
adc315b8 | 1744 | |
78c8ab4f | 1745 | A CTF IR <strong><em>string field type</em></strong> is a field type that |
4089d5a6 | 1746 | you can use to create concrete @stringfields. |
adc315b8 | 1747 | |
78c8ab4f PP |
1748 | You can create a string field type |
1749 | with bt_ctf_field_type_string_create(). | |
adc315b8 | 1750 | |
78c8ab4f | 1751 | A string field type has only one property: the \b encoding of its |
4089d5a6 | 1752 | described @stringfields. By default, the encoding of the string fields |
78c8ab4f PP |
1753 | described by a string field type is #BT_CTF_STRING_ENCODING_UTF8. You |
1754 | can set the encoding of the string fields described by a string field | |
1755 | type with bt_ctf_field_type_string_set_encoding(). | |
1756 | ||
1757 | @sa ctfirstringfield | |
1758 | @sa ctfirfieldtypes | |
1759 | ||
1760 | @addtogroup ctfirstringfieldtype | |
1761 | @{ | |
1762 | */ | |
1763 | ||
1764 | /** | |
4089d5a6 | 1765 | @brief Creates a default @stringft. |
78c8ab4f PP |
1766 | |
1767 | @returns Created string field type, or \c NULL on error. | |
1768 | ||
1769 | @postsuccessrefcountret1 | |
1770 | */ | |
1771 | extern struct bt_ctf_field_type *bt_ctf_field_type_string_create(void); | |
1772 | ||
1773 | /** | |
4089d5a6 PP |
1774 | @brief Returns the encoding of the @stringfields described by |
1775 | the @stringft \p string_field_type. | |
78c8ab4f PP |
1776 | |
1777 | @param[in] string_field_type String field type which describes the | |
1778 | string fields of which to get the | |
1779 | encoding. | |
1780 | @returns Encoding of the string | |
1781 | fields described by \p string_field_type, | |
1782 | or #BT_CTF_STRING_ENCODING_UNKNOWN on | |
1783 | error. | |
1784 | ||
1785 | @prenotnull{string_field_type} | |
1786 | @preisstringft{string_field_type} | |
1787 | @postrefcountsame{string_field_type} | |
1788 | ||
1789 | @sa bt_ctf_field_type_string_set_encoding(): Sets the encoding | |
1790 | of the string fields described by a given string field type. | |
1791 | */ | |
1792 | extern enum bt_ctf_string_encoding bt_ctf_field_type_string_get_encoding( | |
1793 | struct bt_ctf_field_type *string_field_type); | |
1794 | ||
1795 | /** | |
4089d5a6 PP |
1796 | @brief Sets the encoding of the @stringfields described by the |
1797 | @stringft \p string_field_type to \p encoding. | |
78c8ab4f PP |
1798 | |
1799 | @param[in] string_field_type String field type which describes the | |
1800 | string fields of which to set the | |
1801 | encoding. | |
1802 | @param[in] encoding Encoding of the string fields described | |
1803 | by \p string_field_type. | |
1804 | @returns 0 on success, or a negative value on error. | |
1805 | ||
1806 | @prenotnull{string_field_type} | |
1807 | @preisstringft{string_field_type} | |
1808 | @prehot{string_field_type} | |
1809 | @pre \p encoding is #BT_CTF_STRING_ENCODING_ASCII or | |
1810 | #BT_CTF_STRING_ENCODING_UTF8. | |
1811 | @postrefcountsame{string_field_type} | |
1812 | ||
1813 | @sa bt_ctf_field_type_string_get_encoding(): Returns the encoding of | |
1814 | the string fields described by a given string field type. | |
1815 | */ | |
1816 | extern int bt_ctf_field_type_string_set_encoding( | |
1817 | struct bt_ctf_field_type *string_field_type, | |
1818 | enum bt_ctf_string_encoding encoding); | |
1819 | ||
1820 | /** @} */ | |
1821 | ||
1822 | /** | |
1823 | @defgroup ctfirstructfieldtype CTF IR structure field type | |
1824 | @ingroup ctfirfieldtypes | |
1825 | @brief CTF IR structure field type. | |
1826 | ||
1827 | @code | |
1828 | #include <babeltrace/ctf-ir/field-types.h> | |
1829 | @endcode | |
1830 | ||
1831 | A CTF IR <strong><em>structure field type</em></strong> is | |
4089d5a6 | 1832 | a field type that you can use to create concrete @structfields. |
78c8ab4f PP |
1833 | |
1834 | You can create a structure field type | |
1835 | with bt_ctf_field_type_structure_create(). This function creates | |
1836 | an empty structure field type, with no fields. | |
1837 | ||
1838 | You can add a field to a structure field type with | |
1839 | bt_ctf_field_type_structure_add_field(). Two fields in a structure | |
1840 | field type cannot have the same name. | |
1841 | ||
1842 | You can set the \em minimum alignment of the structure fields described | |
1843 | by a structure field type with the common | |
1844 | bt_ctf_field_type_set_alignment() function. The \em effective alignment | |
1845 | of the structure fields described by a structure field type, as per | |
1846 | <a href="http://diamon.org/ctf/">CTF</a>, is the \em maximum value amongst | |
1847 | the effective alignments of all its fields. Note that the effective | |
4089d5a6 | 1848 | alignment of @varfields is always 1. |
78c8ab4f PP |
1849 | |
1850 | You can set the byte order of <em>all the contained fields</em>, | |
1851 | recursively, of a structure field type with the common | |
1852 | bt_ctf_field_type_set_byte_order() function. | |
1853 | ||
1854 | @sa ctfirstructfield | |
1855 | @sa ctfirfieldtypes | |
1856 | ||
1857 | @addtogroup ctfirstructfieldtype | |
1858 | @{ | |
1859 | */ | |
1860 | ||
1861 | /** | |
4089d5a6 | 1862 | @brief Creates a default, empty @structft. |
78c8ab4f PP |
1863 | |
1864 | @returns Created structure field type, | |
1865 | or \c NULL on error. | |
1866 | ||
1867 | @postsuccessrefcountret1 | |
1868 | */ | |
1869 | extern struct bt_ctf_field_type *bt_ctf_field_type_structure_create(void); | |
1870 | ||
1871 | /** | |
4089d5a6 PP |
1872 | @brief Returns the number of fields contained in the |
1873 | @structft \p struct_field_type. | |
78c8ab4f PP |
1874 | |
1875 | @param[in] struct_field_type Structure field type of which to get | |
1876 | the number of contained fields. | |
1877 | @returns Number of fields contained in | |
1878 | \p struct_field_type, or a negative | |
1879 | value on error. | |
1880 | ||
1881 | @prenotnull{struct_field_type} | |
1882 | @preisstructft{struct_field_type} | |
1883 | @postrefcountsame{struct_field_type} | |
1884 | */ | |
074ee56d | 1885 | extern int bt_ctf_field_type_structure_get_field_count( |
78c8ab4f | 1886 | struct bt_ctf_field_type *struct_field_type); |
b92ddaaa | 1887 | |
78c8ab4f | 1888 | /** |
4089d5a6 PP |
1889 | @brief Returns the field of the @structft \p struct_field_type |
1890 | at index \p index. | |
78c8ab4f PP |
1891 | |
1892 | On success, the field's type is placed in \p *field_type if | |
1893 | \p field_type is not \c NULL. The field's name is placed in | |
1894 | \p *field_name if \p field_name is not \c NULL. | |
1895 | \p struct_field_type remains the sole owner of \p *field_name. | |
1896 | ||
1897 | @param[in] struct_field_type Structure field type of which to get | |
1898 | the field at index \p index. | |
1899 | @param[out] field_name Returned name of the field at index | |
1900 | \p index (can be \c NULL). | |
1901 | @param[out] field_type Returned field type of the field | |
1902 | at index \p index (can be \c NULL). | |
1903 | @param[in] index Index of the field to get from | |
1904 | \p struct_field_type. | |
1905 | @returns 0 on success, or a negative value on error. | |
1906 | ||
1907 | @prenotnull{struct_field_type} | |
1908 | @preisstructft{struct_field_type} | |
1909 | @pre \p index is lesser than the number of fields contained in the | |
1910 | structure field type \p struct_field_type (see | |
1911 | bt_ctf_field_type_structure_get_field_count()). | |
1912 | @postrefcountsame{struct_field_type} | |
1913 | @post <strong>On success</strong>, the returned field's type is placed | |
1914 | in \p *field_type and its reference count is incremented. | |
1915 | ||
1916 | @sa bt_ctf_field_type_structure_get_field_type_by_name(): Finds a | |
1917 | structure field type's field by name. | |
1918 | */ | |
b92ddaaa | 1919 | extern int bt_ctf_field_type_structure_get_field( |
78c8ab4f | 1920 | struct bt_ctf_field_type *struct_field_type, |
b92ddaaa | 1921 | const char **field_name, struct bt_ctf_field_type **field_type, |
074ee56d | 1922 | int index); |
b92ddaaa | 1923 | |
78c8ab4f PP |
1924 | /** |
1925 | @brief Returns the type of the field named \p field_name found in | |
4089d5a6 | 1926 | the @structft \p struct_field_type. |
78c8ab4f PP |
1927 | |
1928 | @param[in] struct_field_type Structure field type of which to get | |
1929 | a field's type. | |
1930 | @param[in] field_name Name of the field to find. | |
1931 | @returns Type of the field named \p field_name in | |
1932 | \p struct_field_type, or | |
1933 | \c NULL on error. | |
1934 | ||
1935 | @prenotnull{struct_field_type} | |
1936 | @prenotnull{field_name} | |
1937 | @preisstructft{struct_field_type} | |
1938 | @postrefcountsame{struct_field_type} | |
1939 | @postsuccessrefcountretinc | |
1940 | ||
1941 | @sa bt_ctf_field_type_structure_get_field(): Finds a | |
1942 | structure field type's field by index. | |
1943 | */ | |
b92ddaaa JG |
1944 | extern |
1945 | struct bt_ctf_field_type *bt_ctf_field_type_structure_get_field_type_by_name( | |
78c8ab4f PP |
1946 | struct bt_ctf_field_type *struct_field_type, |
1947 | const char *field_name); | |
b92ddaaa | 1948 | |
78c8ab4f | 1949 | /** |
4089d5a6 PP |
1950 | @brief Adds a field named \p field_name with the @ft |
1951 | \p field_type to the @structft \p struct_field_type. | |
78c8ab4f PP |
1952 | |
1953 | On success, \p field_type becomes the child of \p struct_field_type. | |
1954 | ||
1955 | This function adds the new field after the current last field of | |
1956 | \p struct_field_type (append mode). | |
1957 | ||
1958 | You \em cannot add a field named \p field_name if there's already a | |
1959 | field named \p field_name in \p struct_field_type. | |
1960 | ||
1961 | @param[in] struct_field_type Structure field type to which to add | |
1962 | a new field. | |
1963 | @param[in] field_type Field type of the field to add to | |
1964 | \p struct_field_type. | |
1965 | @param[in] field_name Name of the field to add to | |
1966 | \p struct_field_type | |
1967 | (copied on success). | |
1968 | @returns 0 on success, or a negative value on error. | |
1969 | ||
1970 | @prenotnull{struct_field_type} | |
1971 | @prenotnull{field_type} | |
1972 | @prenotnull{field_name} | |
1973 | @preisstructft{struct_field_type} | |
1974 | @pre \p field_type is not and does not contain \p struct_field_type, | |
1975 | recursively, as a field's type. | |
1976 | @prehot{struct_field_type} | |
1977 | @postrefcountsame{struct_field_type} | |
1978 | @postsuccessrefcountinc{field_type} | |
1979 | */ | |
1980 | extern int bt_ctf_field_type_structure_add_field( | |
1981 | struct bt_ctf_field_type *struct_field_type, | |
1982 | struct bt_ctf_field_type *field_type, | |
1983 | const char *field_name); | |
b92ddaaa | 1984 | |
78c8ab4f | 1985 | /** @} */ |
b92ddaaa | 1986 | |
78c8ab4f PP |
1987 | /** |
1988 | @defgroup ctfirarrayfieldtype CTF IR array field type | |
1989 | @ingroup ctfirfieldtypes | |
1990 | @brief CTF IR array field type. | |
adc315b8 | 1991 | |
78c8ab4f PP |
1992 | @code |
1993 | #include <babeltrace/ctf-ir/field-types.h> | |
1994 | @endcode | |
d9b1ab6d | 1995 | |
78c8ab4f | 1996 | A CTF IR <strong><em>array field type</em></strong> is a field type that |
4089d5a6 | 1997 | you can use to create concrete @arrayfields. |
adc315b8 | 1998 | |
78c8ab4f PP |
1999 | You can create an array field type |
2000 | with bt_ctf_field_type_array_create(). This function needs | |
4089d5a6 PP |
2001 | the @ft of the fields contained by the array fields described by the |
2002 | array field type to create. | |
b92ddaaa | 2003 | |
78c8ab4f PP |
2004 | @sa ctfirarrayfield |
2005 | @sa ctfirfieldtypes | |
b92ddaaa | 2006 | |
78c8ab4f PP |
2007 | @addtogroup ctfirarrayfieldtype |
2008 | @{ | |
2009 | */ | |
b92ddaaa | 2010 | |
78c8ab4f | 2011 | /** |
4089d5a6 | 2012 | @brief Creates a default @arrayft with |
78c8ab4f | 2013 | \p element_field_type as the field type of the fields contained |
4089d5a6 | 2014 | in its described @arrayfields of length \p length. |
78c8ab4f PP |
2015 | |
2016 | @param[in] element_field_type Field type of the fields contained in | |
2017 | the array fields described by the | |
2018 | created array field type. | |
2019 | @param[in] length Length of the array fields described by | |
2020 | the created array field type. | |
2021 | @returns Created array field type, or | |
2022 | \c NULL on error. | |
2023 | ||
2024 | @prenotnull{element_field_type} | |
2025 | @postsuccessrefcountinc{element_field_type} | |
2026 | @postsuccessrefcountret1 | |
2027 | */ | |
adc315b8 | 2028 | extern struct bt_ctf_field_type *bt_ctf_field_type_array_create( |
78c8ab4f PP |
2029 | struct bt_ctf_field_type *element_field_type, |
2030 | unsigned int length); | |
b92ddaaa | 2031 | |
78c8ab4f | 2032 | /** |
4089d5a6 PP |
2033 | @brief Returns the @ft of the @fields contained in |
2034 | the @arrayfields described by the @arrayft \p array_field_type. | |
78c8ab4f PP |
2035 | |
2036 | @param[in] array_field_type Array field type of which to get | |
2037 | the type of the fields contained in its | |
2038 | described array fields. | |
2039 | @returns Type of the fields contained in the | |
2040 | array fields described by | |
2041 | \p array_field_type, or \c NULL | |
2042 | on error. | |
2043 | ||
2044 | @prenotnull{array_field_type} | |
2045 | @preisarrayft{array_field_type} | |
2046 | @postrefcountsame{array_field_type} | |
2047 | @postsuccessrefcountretinc | |
2048 | */ | |
b92ddaaa | 2049 | extern struct bt_ctf_field_type *bt_ctf_field_type_array_get_element_type( |
78c8ab4f | 2050 | struct bt_ctf_field_type *array_field_type); |
b92ddaaa | 2051 | |
78c8ab4f | 2052 | /** |
4089d5a6 PP |
2053 | @brief Returns the number of @fields contained in the |
2054 | @arrayfields described by the @arrayft \p array_field_type. | |
78c8ab4f PP |
2055 | |
2056 | @param[in] array_field_type Array field type of which to get | |
2057 | the number of fields contained in its | |
2058 | described array fields. | |
2059 | @returns Number of fields contained in the | |
2060 | array fields described by | |
2061 | \p array_field_type, or a negative value | |
2062 | on error. | |
2063 | ||
2064 | @prenotnull{array_field_type} | |
2065 | @preisarrayft{array_field_type} | |
2066 | @postrefcountsame{array_field_type} | |
2067 | */ | |
b92ddaaa | 2068 | extern int64_t bt_ctf_field_type_array_get_length( |
78c8ab4f | 2069 | struct bt_ctf_field_type *array_field_type); |
adc315b8 | 2070 | |
78c8ab4f | 2071 | /** @} */ |
adc315b8 | 2072 | |
78c8ab4f PP |
2073 | /** |
2074 | @defgroup ctfirseqfieldtype CTF IR sequence field type | |
2075 | @ingroup ctfirfieldtypes | |
2076 | @brief CTF IR sequence field type. | |
b92ddaaa | 2077 | |
78c8ab4f PP |
2078 | @code |
2079 | #include <babeltrace/ctf-ir/field-types.h> | |
2080 | @endcode | |
b92ddaaa | 2081 | |
78c8ab4f | 2082 | A CTF IR <strong><em>sequence field type</em></strong> is |
4089d5a6 | 2083 | a field type that you can use to create concrete @seqfields. |
adc315b8 | 2084 | |
78c8ab4f | 2085 | You can create a sequence field type with |
4089d5a6 | 2086 | bt_ctf_field_type_sequence_create(). This function needs the @ft |
78c8ab4f PP |
2087 | of the fields contained by the sequence fields described by the created |
2088 | sequence field type. This function also needs the length name of the | |
2089 | sequence field type to create. The length name is used to automatically | |
2090 | resolve the length's field type. See \ref ctfirfieldtypes to learn more | |
2091 | about the automatic resolving. | |
b92ddaaa | 2092 | |
78c8ab4f PP |
2093 | @sa ctfirseqfield |
2094 | @sa ctfirfieldtypes | |
adc315b8 | 2095 | |
78c8ab4f PP |
2096 | @addtogroup ctfirseqfieldtype |
2097 | @{ | |
2098 | */ | |
b92ddaaa | 2099 | |
78c8ab4f | 2100 | /** |
4089d5a6 PP |
2101 | @brief Creates a default @seqft with \p element_field_type as the |
2102 | @ft of the @fields contained in its described @seqfields | |
2103 | with the length name \p length_name. | |
78c8ab4f PP |
2104 | |
2105 | \p length_name can be an absolute or relative reference. See | |
2106 | <a href="http://diamon.org/ctf/">CTF</a> for more details. | |
2107 | ||
2108 | @param[in] element_field_type Field type of the fields contained in | |
2109 | the sequence fields described by the | |
2110 | created sequence field type. | |
2111 | @param[in] length_name Length name (copied on success). | |
2112 | @returns Created array field type, or | |
2113 | \c NULL on error. | |
2114 | ||
2115 | @prenotnull{element_field_type} | |
2116 | @prenotnull{length_name} | |
2117 | @postsuccessrefcountinc{element_field_type} | |
2118 | @postsuccessrefcountret1 | |
2119 | */ | |
2120 | extern struct bt_ctf_field_type *bt_ctf_field_type_sequence_create( | |
2121 | struct bt_ctf_field_type *element_field_type, | |
2122 | const char *length_name); | |
adc315b8 | 2123 | |
78c8ab4f | 2124 | /** |
4089d5a6 PP |
2125 | @brief Returns the @ft of the @fields contained in the @seqft |
2126 | described by the @seqft \p sequence_field_type. | |
78c8ab4f PP |
2127 | |
2128 | @param[in] sequence_field_type Sequence field type of which to get | |
2129 | the type of the fields contained in its | |
2130 | described sequence fields. | |
2131 | @returns Type of the fields contained in the | |
2132 | sequence fields described by | |
2133 | \p sequence_field_type, or \c NULL | |
2134 | on error. | |
2135 | ||
2136 | @prenotnull{sequence_field_type} | |
2137 | @preisseqft{sequence_field_type} | |
2138 | @postrefcountsame{sequence_field_type} | |
2139 | @postsuccessrefcountretinc | |
2140 | */ | |
2141 | extern struct bt_ctf_field_type *bt_ctf_field_type_sequence_get_element_type( | |
2142 | struct bt_ctf_field_type *sequence_field_type); | |
b92ddaaa | 2143 | |
78c8ab4f | 2144 | /** |
4089d5a6 | 2145 | @brief Returns the length name of the @seqft \p sequence_field_type. |
adc315b8 | 2146 | |
78c8ab4f PP |
2147 | On success, \p sequence_field_type remains the sole owner of |
2148 | the returned string. | |
b011f6b0 | 2149 | |
78c8ab4f PP |
2150 | @param[in] sequence_field_type Sequence field type of which to get the |
2151 | length name. | |
2152 | @returns Length name of \p sequence_field_type, | |
2153 | or \c NULL on error. | |
2154 | ||
2155 | @prenotnull{sequence_field_type} | |
2156 | @preisseqft{sequence_field_type} | |
2157 | ||
2158 | @sa bt_ctf_field_type_sequence_get_length_field_path(): Returns the | |
2159 | length's CTF IR field path of a given sequence field type. | |
2160 | */ | |
2161 | extern const char *bt_ctf_field_type_sequence_get_length_field_name( | |
2162 | struct bt_ctf_field_type *sequence_field_type); | |
2163 | ||
2164 | /** | |
4089d5a6 PP |
2165 | @brief Returns the length's CTF IR field path of the @seqft |
2166 | \p sequence_field_type. | |
78c8ab4f PP |
2167 | |
2168 | The length's field path of a sequence field type is set when automatic | |
2169 | resolving is performed (see \ref ctfirfieldtypes). | |
2170 | ||
2171 | @param[in] sequence_field_type Sequence field type of which to get the | |
2172 | length's field path. | |
2173 | @returns Length's field path of | |
2174 | \p sequence_field_type, or | |
2175 | \c NULL if the length's field path is | |
2176 | not set yet is not set or on error. | |
2177 | ||
2178 | @prenotnull{sequence_field_type} | |
2179 | @preisseqft{sequence_field_type} | |
2180 | @postsuccessrefcountretinc | |
2181 | ||
2182 | @sa bt_ctf_field_type_sequence_get_length_field_name(): Returns the | |
2183 | length's name of a given sequence field type. | |
2184 | */ | |
b011f6b0 | 2185 | extern struct bt_ctf_field_path *bt_ctf_field_type_sequence_get_length_field_path( |
78c8ab4f | 2186 | struct bt_ctf_field_type *sequence_field_type); |
b011f6b0 | 2187 | |
78c8ab4f | 2188 | /** @} */ |
265e809c | 2189 | |
78c8ab4f PP |
2190 | /** |
2191 | @defgroup ctfirvarfieldtype CTF IR variant field type | |
2192 | @ingroup ctfirfieldtypes | |
2193 | @brief CTF IR variant field type. | |
2194 | ||
2195 | @code | |
2196 | #include <babeltrace/ctf-ir/field-types.h> | |
2197 | @endcode | |
2198 | ||
2199 | A CTF IR <strong><em>variant field type</em></strong> is | |
4089d5a6 PP |
2200 | a field type that you can use to create concrete @varfields. |
2201 | ||
2202 | You can create a variant field type with | |
2203 | bt_ctf_field_type_variant_create(). This function expects you to pass | |
2204 | both the tag's @enumft and the tag name of the variant field type to | |
2205 | create. The tag's field type is optional, as the Babeltrace system can | |
2206 | automatically resolve it using the tag name. You can leave the tag name | |
2207 | to \c NULL initially, and set it later with | |
2208 | bt_ctf_field_type_variant_set_tag_name(). The tag name must be set when | |
2209 | the variant field type is frozen. See \ref ctfirfieldtypes to learn more | |
2210 | about the automatic resolving and the conditions under which a field | |
2211 | type can be frozen. | |
78c8ab4f PP |
2212 | |
2213 | You can add a field to a variant field type with | |
2214 | bt_ctf_field_type_variant_add_field(). All the field names of a | |
4089d5a6 | 2215 | variant field type \em must exist as mapping names in its tag's @enumft. |
78c8ab4f | 2216 | |
4089d5a6 | 2217 | The effective alignment of the @varfields described by a |
78c8ab4f | 2218 | variant field type is always 1, but the individual fields of a |
4089d5a6 | 2219 | @varfield can have custom alignments. |
78c8ab4f PP |
2220 | |
2221 | You can set the byte order of <em>all the contained fields</em>, | |
2222 | recursively, of a variant field type with the common | |
2223 | bt_ctf_field_type_set_byte_order() function. | |
2224 | ||
2225 | @sa ctfirvarfield | |
2226 | @sa ctfirfieldtypes | |
2227 | ||
2228 | @addtogroup ctfirvarfieldtype | |
2229 | @{ | |
2230 | */ | |
06629ab3 | 2231 | |
78c8ab4f | 2232 | /** |
4089d5a6 | 2233 | @brief Creates a default, empty @varft with the tag's @enumft |
78c8ab4f PP |
2234 | \p tag_field_type and the tag name \p tag_name. |
2235 | ||
2236 | \p tag_field_type can be \c NULL; the tag's field type can be | |
2237 | automatically resolved from the variant field type's tag name (see | |
2238 | \ref ctfirfieldtypes). If \p tag_name is \c NULL, it \em must be set | |
2239 | with bt_ctf_field_type_variant_set_tag_name() \em before the variant | |
2240 | field type is frozen. | |
2241 | ||
2242 | \p tag_name can be an absolute or relative reference. See | |
2243 | <a href="http://diamon.org/ctf/">CTF</a> for more details. | |
2244 | ||
2245 | @param[in] tag_field_type Tag's enumeration field type | |
2246 | (can be \c NULL). | |
2247 | @param[in] tag_name Tag name (copied on success, | |
2248 | can be \c NULL). | |
2249 | @returns Created variant field type, or | |
2250 | \c NULL on error. | |
2251 | ||
2252 | @pre \p tag_field_type is an enumeration field type or \c NULL. | |
2253 | @post <strong>On success, if \p tag_field_type is not \c NULL</strong>, | |
2254 | its reference count is incremented. | |
2255 | @postsuccessrefcountret1 | |
2256 | */ | |
2257 | extern struct bt_ctf_field_type *bt_ctf_field_type_variant_create( | |
2258 | struct bt_ctf_field_type *tag_field_type, | |
2259 | const char *tag_name); | |
b92ddaaa | 2260 | |
78c8ab4f | 2261 | /** |
4089d5a6 | 2262 | @brief Returns the tag's @enumft of the @varft \p variant_field_type. |
78c8ab4f PP |
2263 | |
2264 | @param[in] variant_field_type Variant field type of which to get | |
2265 | the tag's enumeration field type. | |
2266 | @returns Tag's enumeration field type of | |
2267 | \p variant_field_type, or \c NULL if the | |
2268 | tag's field type is not set or on | |
2269 | error. | |
2270 | ||
2271 | @prenotnull{variant_field_type} | |
2272 | @preisvarft{variant_field_type} | |
2273 | @postrefcountsame{variant_field_type} | |
2274 | @postsuccessrefcountretinc | |
2275 | */ | |
2276 | extern struct bt_ctf_field_type *bt_ctf_field_type_variant_get_tag_type( | |
2277 | struct bt_ctf_field_type *variant_field_type); | |
56db8d7a | 2278 | |
78c8ab4f | 2279 | /** |
4089d5a6 | 2280 | @brief Returns the tag name of the @varft \p variant_field_type. |
78c8ab4f PP |
2281 | |
2282 | On success, \p variant_field_type remains the sole owner of | |
2283 | the returned string. | |
2284 | ||
2285 | @param[in] variant_field_type Variant field type of which to get the | |
2286 | tag name. | |
2287 | @returns Tag name of \p variant_field_type, or | |
2288 | \c NULL if the tag name is not set or | |
2289 | on error. | |
2290 | ||
2291 | @prenotnull{variant_field_type} | |
2292 | @preisvarft{variant_field_type} | |
2293 | ||
2294 | @sa bt_ctf_field_type_variant_set_tag_name(): Sets the tag name of | |
2295 | a given variant field type. | |
2296 | @sa bt_ctf_field_type_variant_get_tag_field_path(): Returns the tag's | |
2297 | CTF IR field path of a given variant field type. | |
2298 | */ | |
2299 | extern const char *bt_ctf_field_type_variant_get_tag_name( | |
2300 | struct bt_ctf_field_type *variant_field_type); | |
56db8d7a | 2301 | |
78c8ab4f | 2302 | /** |
4089d5a6 | 2303 | @brief Sets the tag name of the @varft \p variant_field_type. |
78c8ab4f PP |
2304 | |
2305 | \p tag_name can be an absolute or relative reference. See | |
2306 | <a href="http://diamon.org/ctf/">CTF</a> for more details. | |
2307 | ||
2308 | @param[in] variant_field_type Variant field type of which to set | |
2309 | the tag name. | |
2310 | @param[in] tag_name Tag name of \p variant_field_type | |
2311 | (copied on success). | |
2312 | @returns 0 on success, or a negative value on error. | |
2313 | ||
2314 | @prenotnull{variant_field_type} | |
2315 | @prenotnull{name} | |
2316 | @prehot{variant_field_type} | |
2317 | @postrefcountsame{variant_field_type} | |
2318 | ||
2319 | @sa bt_ctf_field_type_variant_get_tag_name(): Returns the tag name of | |
2320 | a given variant field type. | |
2321 | */ | |
2322 | extern int bt_ctf_field_type_variant_set_tag_name( | |
2323 | struct bt_ctf_field_type *variant_field_type, | |
2324 | const char *tag_name); | |
56db8d7a | 2325 | |
78c8ab4f | 2326 | /** |
4089d5a6 PP |
2327 | @brief Returns the tag's CTF IR field path of the @varft |
2328 | \p variant_field_type. | |
78c8ab4f PP |
2329 | |
2330 | The tag's field path of a variant field type is set when automatic | |
2331 | resolving is performed (see \ref ctfirfieldtypes). | |
2332 | ||
2333 | @param[in] variant_field_type Variant field type of which to get the | |
2334 | tag's field path. | |
2335 | @returns Tag's field path of | |
2336 | \p variant_field_type, or | |
2337 | \c NULL if the tag's field path is not | |
2338 | set yet is not set or on error. | |
2339 | ||
2340 | @prenotnull{variant_field_type} | |
2341 | @preisvarft{variant_field_type} | |
2342 | @postsuccessrefcountretinc | |
2343 | ||
2344 | @sa bt_ctf_field_type_variant_get_tag_name(): Returns the tag's | |
2345 | name of a given variant field type. | |
2346 | */ | |
2347 | extern struct bt_ctf_field_path *bt_ctf_field_type_variant_get_tag_field_path( | |
2348 | struct bt_ctf_field_type *variant_field_type); | |
56db8d7a | 2349 | |
78c8ab4f | 2350 | /** |
4089d5a6 PP |
2351 | @brief Returns the number of fields (choices) contained in the @varft |
2352 | \p variant_field_type. | |
78c8ab4f PP |
2353 | |
2354 | @param[in] variant_field_type Variant field type of which to get | |
2355 | the number of contained fields. | |
2356 | @returns Number of fields contained in | |
2357 | \p variant_field_type, or a negative | |
2358 | value on error. | |
2359 | ||
2360 | @prenotnull{variant_field_type} | |
2361 | @preisvarft{variant_field_type} | |
2362 | @postrefcountsame{variant_field_type} | |
2363 | */ | |
2364 | extern int bt_ctf_field_type_variant_get_field_count( | |
2365 | struct bt_ctf_field_type *variant_field_type); | |
56db8d7a | 2366 | |
78c8ab4f | 2367 | /** |
4089d5a6 PP |
2368 | @brief Returns the field (choice) of the @varft \p variant_field_type |
2369 | at index \p index. | |
78c8ab4f PP |
2370 | |
2371 | On success, the field's type is placed in \p *field_type if | |
2372 | \p field_type is not \c NULL. The field's name is placed in | |
2373 | \p *field_name if \p field_name is not \c NULL. | |
2374 | \p variant_field_type remains the sole owner of \p *field_name. | |
2375 | ||
2376 | @param[in] variant_field_type Variant field type of which to get | |
2377 | the field at index \p index. | |
2378 | @param[out] field_name Returned name of the field at index | |
2379 | \p index (can be \c NULL). | |
2380 | @param[out] field_type Returned field type of the field | |
2381 | at index \p index (can be \c NULL). | |
2382 | @param[in] index Index of the field to get from | |
2383 | \p variant_field_type. | |
2384 | @returns 0 on success, or a negative value on error. | |
2385 | ||
2386 | @prenotnull{variant_field_type} | |
2387 | @preisvarft{variant_field_type} | |
2388 | @pre \p index is lesser than the number of fields contained in the | |
2389 | variant field type \p variant_field_type (see | |
2390 | bt_ctf_field_type_variant_get_field_count()). | |
2391 | @postrefcountsame{variant_field_type} | |
2392 | @post <strong>On success</strong>, the returned field's type is placed | |
2393 | in \p *field_type and its reference count is incremented. | |
2394 | ||
2395 | @sa bt_ctf_field_type_variant_get_field_type_by_name(): Finds a variant | |
2396 | field type's field by name. | |
2397 | @sa bt_ctf_field_type_variant_get_field_type_from_tag(): Finds a variant | |
2398 | field type's field by current tag value. | |
2399 | */ | |
2400 | extern int bt_ctf_field_type_variant_get_field( | |
2401 | struct bt_ctf_field_type *variant_field_type, | |
2402 | const char **field_name, | |
2403 | struct bt_ctf_field_type **field_type, int index); | |
56db8d7a | 2404 | |
78c8ab4f PP |
2405 | /** |
2406 | @brief Returns the type of the field (choice) named \p field_name | |
4089d5a6 | 2407 | found in the @varft \p variant_field_type. |
78c8ab4f PP |
2408 | |
2409 | @param[in] variant_field_type Variant field type of which to get | |
2410 | a field's type. | |
2411 | @param[in] field_name Name of the field to find. | |
2412 | @returns Type of the field named \p field_name in | |
2413 | \p variant_field_type, or | |
2414 | \c NULL on error. | |
2415 | ||
2416 | @prenotnull{variant_field_type} | |
2417 | @prenotnull{field_name} | |
2418 | @preisvarft{variant_field_type} | |
2419 | @postrefcountsame{variant_field_type} | |
2420 | @postsuccessrefcountretinc | |
2421 | ||
2422 | @sa bt_ctf_field_type_variant_get_field(): Finds a variant field type's | |
2423 | field by index. | |
2424 | @sa bt_ctf_field_type_variant_get_field_type_from_tag(): Finds a variant | |
2425 | field type's field by current tag value. | |
2426 | */ | |
2427 | extern | |
2428 | struct bt_ctf_field_type *bt_ctf_field_type_variant_get_field_type_by_name( | |
2429 | struct bt_ctf_field_type *variant_field_type, | |
2430 | const char *field_name); | |
56db8d7a | 2431 | |
78c8ab4f PP |
2432 | /** |
2433 | @brief Returns the type of the field (choice) selected by the value of | |
4089d5a6 | 2434 | the @enumfield \p tag_field in the @varft \p variant_field_type. |
78c8ab4f PP |
2435 | |
2436 | \p tag_field is the current tag value. | |
2437 | ||
2438 | The field type of \p tag_field, as returned by bt_ctf_field_get_type(), | |
2439 | \em must be equivalent to the field type returned by | |
2440 | bt_ctf_field_type_variant_get_tag_type() for \p variant_field_type. | |
2441 | ||
2442 | @param[in] variant_field_type Variant field type of which to get | |
2443 | a field's type. | |
2444 | @param[in] tag_field Current tag value (variant field type's | |
2445 | selector). | |
2446 | @returns Type of the field selected by | |
2447 | \p tag_field in \p variant_field_type, | |
2448 | or \c NULL on error. | |
2449 | ||
2450 | @prenotnull{variant_field_type} | |
2451 | @prenotnull{tag_field} | |
2452 | @preisvarft{variant_field_type} | |
2453 | @preisenumfield{tag_field} | |
2454 | @postrefcountsame{variant_field_type} | |
2455 | @postrefcountsame{tag_field} | |
2456 | @postsuccessrefcountretinc | |
2457 | ||
2458 | @sa bt_ctf_field_type_variant_get_field(): Finds a variant field type's | |
2459 | field by index. | |
2460 | @sa bt_ctf_field_type_variant_get_field_type_by_name(): Finds a variant | |
2461 | field type's field by name. | |
2462 | */ | |
2463 | extern | |
2464 | struct bt_ctf_field_type *bt_ctf_field_type_variant_get_field_type_from_tag( | |
2465 | struct bt_ctf_field_type *variant_field_type, | |
2466 | struct bt_ctf_field *tag_field); | |
2467 | ||
2468 | /** | |
4089d5a6 PP |
2469 | @brief Adds a field (a choice) named \p field_name with the @ft |
2470 | \p field_type to the @varft \p variant_field_type. | |
78c8ab4f PP |
2471 | |
2472 | On success, \p field_type becomes the child of \p variant_field_type. | |
2473 | ||
2474 | You \em cannot add a field named \p field_name if there's already a | |
2475 | field named \p field_name in \p variant_field_type. | |
2476 | ||
2477 | \p field_name \em must name an existing mapping in the tag's | |
2478 | enumeration field type of \p variant_field_type. | |
2479 | ||
2480 | @param[in] variant_field_type Variant field type to which to add | |
2481 | a new field. | |
2482 | @param[in] field_type Field type of the field to add to | |
2483 | \p variant_field_type. | |
2484 | @param[in] field_name Name of the field to add to | |
2485 | \p variant_field_type | |
2486 | (copied on success). | |
2487 | @returns 0 on success, or a negative value on error. | |
2488 | ||
2489 | @prenotnull{variant_field_type} | |
2490 | @prenotnull{field_type} | |
2491 | @prenotnull{field_name} | |
2492 | @preisvarft{variant_field_type} | |
2493 | @pre \p field_type is not and does not contain \p variant_field_type, | |
2494 | recursively, as a field's type. | |
2495 | @prehot{variant_field_type} | |
2496 | @postrefcountsame{variant_field_type} | |
2497 | @postsuccessrefcountinc{field_type} | |
2498 | */ | |
2499 | extern int bt_ctf_field_type_variant_add_field( | |
2500 | struct bt_ctf_field_type *variant_field_type, | |
2501 | struct bt_ctf_field_type *field_type, | |
2502 | const char *field_name); | |
2503 | ||
2504 | /** @} */ | |
56db8d7a | 2505 | |
adc315b8 JG |
2506 | #ifdef __cplusplus |
2507 | } | |
2508 | #endif | |
2509 | ||
2e33ac5a | 2510 | #endif /* BABELTRACE_CTF_IR_FIELD_TYPES_H */ |