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