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