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