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