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