| 1 | #ifndef BABELTRACE_CTF_IR_EVENT_TYPES_H |
| 2 | #define BABELTRACE_CTF_IR_EVENT_TYPES_H |
| 3 | |
| 4 | /* |
| 5 | * BabelTrace - CTF IR: Event 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 <babeltrace/ctf/events.h> |
| 34 | #include <stdint.h> |
| 35 | |
| 36 | #ifdef __cplusplus |
| 37 | extern "C" { |
| 38 | #endif |
| 39 | |
| 40 | struct bt_ctf_event_class; |
| 41 | struct bt_ctf_event; |
| 42 | struct bt_ctf_field_type; |
| 43 | struct bt_ctf_field; |
| 44 | |
| 45 | enum bt_ctf_integer_base { |
| 46 | BT_CTF_INTEGER_BASE_UNKNOWN = -1, |
| 47 | BT_CTF_INTEGER_BASE_BINARY = 2, |
| 48 | BT_CTF_INTEGER_BASE_OCTAL = 8, |
| 49 | BT_CTF_INTEGER_BASE_DECIMAL = 10, |
| 50 | BT_CTF_INTEGER_BASE_HEXADECIMAL = 16, |
| 51 | }; |
| 52 | |
| 53 | enum bt_ctf_byte_order { |
| 54 | BT_CTF_BYTE_ORDER_UNKNOWN = -1, |
| 55 | BT_CTF_BYTE_ORDER_NATIVE = 0, |
| 56 | BT_CTF_BYTE_ORDER_LITTLE_ENDIAN, |
| 57 | BT_CTF_BYTE_ORDER_BIG_ENDIAN, |
| 58 | BT_CTF_BYTE_ORDER_NETWORK, |
| 59 | }; |
| 60 | |
| 61 | /* |
| 62 | * bt_ctf_field_type_integer_create: create an integer field type. |
| 63 | * |
| 64 | * Allocate a new integer field type of the given size. The creation of a field |
| 65 | * type sets its reference count to 1. |
| 66 | * |
| 67 | * @param size Integer field type size/length in bits. |
| 68 | * |
| 69 | * Returns an allocated field type on success, NULL on error. |
| 70 | */ |
| 71 | extern struct bt_ctf_field_type *bt_ctf_field_type_integer_create( |
| 72 | unsigned int size); |
| 73 | |
| 74 | /* |
| 75 | * bt_ctf_field_type_integer_get_size: get an integer type's size. |
| 76 | * |
| 77 | * Get an integer type's size. |
| 78 | * |
| 79 | * @param integer Integer type. |
| 80 | * |
| 81 | * Returns the integer type's size, a negative value on error. |
| 82 | */ |
| 83 | extern int bt_ctf_field_type_integer_get_size( |
| 84 | struct bt_ctf_field_type *integer); |
| 85 | |
| 86 | /* |
| 87 | * bt_ctf_field_type_integer_get_signed: get an integer type's signedness. |
| 88 | * |
| 89 | * Get an integer type's signedness attribute. |
| 90 | * |
| 91 | * @param integer Integer type. |
| 92 | * |
| 93 | * Returns the integer's signedness, a negative value on error. |
| 94 | */ |
| 95 | extern int bt_ctf_field_type_integer_get_signed( |
| 96 | struct bt_ctf_field_type *integer); |
| 97 | |
| 98 | /* |
| 99 | * bt_ctf_field_type_integer_set_signed: set an integer type's signedness. |
| 100 | * |
| 101 | * Set an integer type's signedness attribute. |
| 102 | * |
| 103 | * @param integer Integer type. |
| 104 | * @param is_signed Integer's signedness, defaults to FALSE. |
| 105 | * |
| 106 | * Returns 0 on success, a negative value on error. |
| 107 | */ |
| 108 | extern int bt_ctf_field_type_integer_set_signed( |
| 109 | struct bt_ctf_field_type *integer, int is_signed); |
| 110 | |
| 111 | /* |
| 112 | * bt_ctf_field_type_integer_get_base: get an integer type's base. |
| 113 | * |
| 114 | * Get an integer type's base used to pretty-print the resulting trace. |
| 115 | * |
| 116 | * @param integer Integer type. |
| 117 | * |
| 118 | * Returns the integer type's base on success, BT_CTF_INTEGER_BASE_UNKNOWN on |
| 119 | * error. |
| 120 | */ |
| 121 | extern enum bt_ctf_integer_base bt_ctf_field_type_integer_get_base( |
| 122 | struct bt_ctf_field_type *integer); |
| 123 | |
| 124 | /* |
| 125 | * bt_ctf_field_type_integer_set_base: set an integer type's base. |
| 126 | * |
| 127 | * Set an integer type's base used to pretty-print the resulting trace. |
| 128 | * |
| 129 | * @param integer Integer type. |
| 130 | * @param base Integer base, defaults to BT_CTF_INTEGER_BASE_DECIMAL. |
| 131 | * |
| 132 | * Returns 0 on success, a negative value on error. |
| 133 | */ |
| 134 | extern int bt_ctf_field_type_integer_set_base(struct bt_ctf_field_type *integer, |
| 135 | enum bt_ctf_integer_base base); |
| 136 | |
| 137 | /* |
| 138 | * bt_ctf_field_type_integer_get_encoding: get an integer type's encoding. |
| 139 | * |
| 140 | * @param integer Integer type. |
| 141 | * |
| 142 | * Returns the string field's encoding on success, CTF_STRING_UNKNOWN on error. |
| 143 | */ |
| 144 | extern enum ctf_string_encoding bt_ctf_field_type_integer_get_encoding( |
| 145 | struct bt_ctf_field_type *integer); |
| 146 | |
| 147 | /* |
| 148 | * bt_ctf_field_type_integer_set_encoding: set an integer type's encoding. |
| 149 | * |
| 150 | * An integer encoding may be set to signal that the integer must be printed as |
| 151 | * a text character. |
| 152 | * |
| 153 | * @param integer Integer type. |
| 154 | * @param encoding Integer output encoding, defaults to CTF_STRING_ENCODING_NONE |
| 155 | * |
| 156 | * Returns 0 on success, a negative value on error. |
| 157 | */ |
| 158 | extern int bt_ctf_field_type_integer_set_encoding( |
| 159 | struct bt_ctf_field_type *integer, |
| 160 | enum ctf_string_encoding encoding); |
| 161 | |
| 162 | /* |
| 163 | * bt_ctf_field_type_enumeration_create: create an enumeration field type. |
| 164 | * |
| 165 | * Allocate a new enumeration field type with the given underlying type. The |
| 166 | * creation of a field type sets its reference count to 1. |
| 167 | * The resulting enumeration will share the integer_container_type's ownership |
| 168 | * by increasing its reference count. |
| 169 | * |
| 170 | * @param integer_container_type Underlying integer type of the enumeration |
| 171 | * type. |
| 172 | * |
| 173 | * Returns an allocated field type on success, NULL on error. |
| 174 | */ |
| 175 | extern struct bt_ctf_field_type *bt_ctf_field_type_enumeration_create( |
| 176 | struct bt_ctf_field_type *integer_container_type); |
| 177 | |
| 178 | /* |
| 179 | * bt_ctf_field_type_enumeration_get_container_type: get underlying container. |
| 180 | * |
| 181 | * Get the enumeration type's underlying integer container type. |
| 182 | * |
| 183 | * @param enumeration Enumeration type. |
| 184 | * |
| 185 | * Returns an allocated field type on success, NULL on error. |
| 186 | */ |
| 187 | extern |
| 188 | struct bt_ctf_field_type *bt_ctf_field_type_enumeration_get_container_type( |
| 189 | struct bt_ctf_field_type *enumeration); |
| 190 | |
| 191 | /* |
| 192 | * bt_ctf_field_type_enumeration_add_mapping: add an enumeration mapping. |
| 193 | * |
| 194 | * Add a mapping to the enumeration. The range's values are inclusive. |
| 195 | * |
| 196 | * @param enumeration Enumeration type. |
| 197 | * @param name Enumeration mapping name (will be copied). |
| 198 | * @param range_start Enumeration mapping range start. |
| 199 | * @param range_end Enumeration mapping range end. |
| 200 | * |
| 201 | * Returns 0 on success, a negative value on error. |
| 202 | */ |
| 203 | extern int bt_ctf_field_type_enumeration_add_mapping( |
| 204 | struct bt_ctf_field_type *enumeration, const char *name, |
| 205 | int64_t range_start, int64_t range_end); |
| 206 | |
| 207 | /* |
| 208 | * bt_ctf_field_type_enumeration_add_mapping_unsigned: add an enumeration |
| 209 | * mapping. |
| 210 | * |
| 211 | * Add a mapping to the enumeration. The range's values are inclusive. |
| 212 | * |
| 213 | * @param enumeration Enumeration type. |
| 214 | * @param name Enumeration mapping name (will be copied). |
| 215 | * @param range_start Enumeration mapping range start. |
| 216 | * @param range_end Enumeration mapping range end. |
| 217 | * |
| 218 | * Returns 0 on success, a negative value on error. |
| 219 | */ |
| 220 | extern int bt_ctf_field_type_enumeration_add_mapping_unsigned( |
| 221 | struct bt_ctf_field_type *enumeration, const char *name, |
| 222 | uint64_t range_start, uint64_t range_end); |
| 223 | |
| 224 | /* |
| 225 | * bt_ctf_field_type_enumeration_get_mapping_count: Get the number of mappings |
| 226 | * defined in the enumeration. |
| 227 | * |
| 228 | * @param enumeration Enumeration type. |
| 229 | * |
| 230 | * Returns the mapping count on success, a negative value on error. |
| 231 | */ |
| 232 | extern int bt_ctf_field_type_enumeration_get_mapping_count( |
| 233 | struct bt_ctf_field_type *enumeration); |
| 234 | |
| 235 | /* |
| 236 | * bt_ctf_field_type_enumeration_get_mapping: get an enumeration mapping. |
| 237 | * |
| 238 | * @param enumeration Enumeration type. |
| 239 | * @param index Index of mapping. |
| 240 | * @param name Pointer where the mapping's name will be returned (valid for |
| 241 | * the lifetime of the enumeration). |
| 242 | * @param range_start Pointer where the enumeration mapping's range start will |
| 243 | * be returned. |
| 244 | * @param range_end Pointer where the enumeration mapping's range end will |
| 245 | * be returned. |
| 246 | * |
| 247 | * Returns 0 on success, a negative value on error. |
| 248 | */ |
| 249 | extern int bt_ctf_field_type_enumeration_get_mapping( |
| 250 | struct bt_ctf_field_type *enumeration, int index, |
| 251 | const char **name, int64_t *range_start, int64_t *range_end); |
| 252 | |
| 253 | /* |
| 254 | * bt_ctf_field_type_enumeration_get_mapping_unsigned: get a mapping. |
| 255 | * |
| 256 | * @param enumeration Enumeration type. |
| 257 | * @param index Index of mapping. |
| 258 | * @param name Pointer where the mapping's name will be returned (valid for |
| 259 | * the lifetime of the enumeration). |
| 260 | * @param range_start Pointer where the enumeration mapping's range start will |
| 261 | * be returned. |
| 262 | * @param range_end Pointer where the enumeration mapping's range end will |
| 263 | * be returned. |
| 264 | * |
| 265 | * Returns 0 on success, a negative value on error. |
| 266 | */ |
| 267 | extern int bt_ctf_field_type_enumeration_get_mapping_unsigned( |
| 268 | struct bt_ctf_field_type *enumeration, int index, |
| 269 | const char **name, uint64_t *range_start, |
| 270 | uint64_t *range_end); |
| 271 | |
| 272 | /* |
| 273 | * bt_ctf_field_type_enumeration_get_mapping_index_by_name: get an enumerations' |
| 274 | * mapping index by name. |
| 275 | * |
| 276 | * @param enumeration Enumeration type. |
| 277 | * @param name Mapping name. |
| 278 | * |
| 279 | * Returns mapping index on success, a negative value on error. |
| 280 | */ |
| 281 | extern int bt_ctf_field_type_enumeration_get_mapping_index_by_name( |
| 282 | struct bt_ctf_field_type *enumeration, const char *name); |
| 283 | |
| 284 | /* |
| 285 | * bt_ctf_field_type_enumeration_get_mapping_index_by_value: get an |
| 286 | * enumerations' mapping index by value. |
| 287 | * |
| 288 | * @param enumeration Enumeration type. |
| 289 | * @param value Value. |
| 290 | * |
| 291 | * Returns mapping index on success, a negative value on error. |
| 292 | */ |
| 293 | extern int bt_ctf_field_type_enumeration_get_mapping_index_by_value( |
| 294 | struct bt_ctf_field_type *enumeration, int64_t value); |
| 295 | |
| 296 | /* |
| 297 | * bt_ctf_field_type_enumeration_get_mapping_index_by_unsigned_value: get an |
| 298 | * enumerations' mapping index by value. |
| 299 | * |
| 300 | * @param enumeration Enumeration type. |
| 301 | * @param value Value. |
| 302 | * |
| 303 | * Returns 0 on success, a negative value on error. |
| 304 | */ |
| 305 | extern int bt_ctf_field_type_enumeration_get_mapping_index_by_unsigned_value( |
| 306 | struct bt_ctf_field_type *enumeration, uint64_t value); |
| 307 | |
| 308 | /* |
| 309 | * bt_ctf_field_type_floating_point_create: create a floating point field type. |
| 310 | * |
| 311 | * Allocate a new floating point field type. The creation of a field type sets |
| 312 | * its reference count to 1. |
| 313 | * |
| 314 | * Returns an allocated field type on success, NULL on error. |
| 315 | */ |
| 316 | extern struct bt_ctf_field_type *bt_ctf_field_type_floating_point_create(void); |
| 317 | |
| 318 | /* |
| 319 | * bt_ctf_field_type_floating_point_get_exponent_digits: get exponent digit |
| 320 | * count. |
| 321 | * |
| 322 | * @param floating_point Floating point type. |
| 323 | * |
| 324 | * Returns the exponent digit count on success, a negative value on error. |
| 325 | */ |
| 326 | extern int bt_ctf_field_type_floating_point_get_exponent_digits( |
| 327 | struct bt_ctf_field_type *floating_point); |
| 328 | |
| 329 | /* |
| 330 | * bt_ctf_field_type_floating_point_set_exponent_digits: set exponent digit |
| 331 | * count. |
| 332 | * |
| 333 | * Set the number of exponent digits to use to store the floating point field. |
| 334 | * The only values currently supported are FLT_EXP_DIG and DBL_EXP_DIG. |
| 335 | * |
| 336 | * @param floating_point Floating point type. |
| 337 | * @param exponent_digits Number of digits to allocate to the exponent (defaults |
| 338 | * to FLT_EXP_DIG). |
| 339 | * |
| 340 | * Returns 0 on success, a negative value on error. |
| 341 | */ |
| 342 | extern int bt_ctf_field_type_floating_point_set_exponent_digits( |
| 343 | struct bt_ctf_field_type *floating_point, |
| 344 | unsigned int exponent_digits); |
| 345 | |
| 346 | /* |
| 347 | * bt_ctf_field_type_floating_point_get_mantissa_digits: get mantissa digit |
| 348 | * count. |
| 349 | * |
| 350 | * @param floating_point Floating point type. |
| 351 | * |
| 352 | * Returns the mantissa digit count on success, a negative value on error. |
| 353 | */ |
| 354 | extern int bt_ctf_field_type_floating_point_get_mantissa_digits( |
| 355 | struct bt_ctf_field_type *floating_point); |
| 356 | |
| 357 | /* |
| 358 | * bt_ctf_field_type_floating_point_set_mantissa_digits: set mantissa digit |
| 359 | * count. |
| 360 | * |
| 361 | * Set the number of mantissa digits to use to store the floating point field. |
| 362 | * The only values currently supported are FLT_MANT_DIG and DBL_MANT_DIG. |
| 363 | * |
| 364 | * @param floating_point Floating point type. |
| 365 | * @param mantissa_digits Number of digits to allocate to the mantissa (defaults |
| 366 | * to FLT_MANT_DIG). |
| 367 | * |
| 368 | * Returns 0 on success, a negative value on error. |
| 369 | */ |
| 370 | extern int bt_ctf_field_type_floating_point_set_mantissa_digits( |
| 371 | struct bt_ctf_field_type *floating_point, |
| 372 | unsigned int mantissa_digits); |
| 373 | |
| 374 | /* |
| 375 | * bt_ctf_field_type_structure_create: create a structure field type. |
| 376 | * |
| 377 | * Allocate a new structure field type. The creation of a field type sets |
| 378 | * its reference count to 1. |
| 379 | * |
| 380 | * Returns an allocated field type on success, NULL on error. |
| 381 | */ |
| 382 | extern struct bt_ctf_field_type *bt_ctf_field_type_structure_create(void); |
| 383 | |
| 384 | /* |
| 385 | * bt_ctf_field_type_structure_add_field: add a field to a structure. |
| 386 | * |
| 387 | * Add a field of type "field_type" to the structure. The structure will share |
| 388 | * field_type's ownership by increasing its reference count. |
| 389 | * |
| 390 | * @param structure Structure type. |
| 391 | * @param field_type Type of the field to add to the structure type. |
| 392 | * @param field_name Name of the structure's new field (will be copied). |
| 393 | * |
| 394 | * Returns 0 on success, a negative value on error. |
| 395 | */ |
| 396 | extern int bt_ctf_field_type_structure_add_field( |
| 397 | struct bt_ctf_field_type *structure, |
| 398 | struct bt_ctf_field_type *field_type, |
| 399 | const char *field_name); |
| 400 | |
| 401 | /* |
| 402 | * bt_ctf_field_type_structure_get_field_count: Get the number of fields defined |
| 403 | * in the structure. |
| 404 | * |
| 405 | * @param structure Structure type. |
| 406 | * |
| 407 | * Returns the field count on success, a negative value on error. |
| 408 | */ |
| 409 | extern int bt_ctf_field_type_structure_get_field_count( |
| 410 | struct bt_ctf_field_type *structure); |
| 411 | |
| 412 | /* |
| 413 | * bt_ctf_field_type_structure_get_field: get a structure's field type and name. |
| 414 | * |
| 415 | * @param structure Structure type. |
| 416 | * @param field_type Pointer to a const char* where the field's name will |
| 417 | * be returned. |
| 418 | * @param field_type Pointer to a bt_ctf_field_type* where the field's type will |
| 419 | * be returned. |
| 420 | * @param index Index of field. |
| 421 | * |
| 422 | * Returns 0 on success, a negative value on error. |
| 423 | */ |
| 424 | extern int bt_ctf_field_type_structure_get_field( |
| 425 | struct bt_ctf_field_type *structure, |
| 426 | const char **field_name, struct bt_ctf_field_type **field_type, |
| 427 | int index); |
| 428 | |
| 429 | /* |
| 430 | * bt_ctf_field_type_structure_get_field_type_by_name: get a structure field's |
| 431 | * type by name. |
| 432 | * |
| 433 | * @param structure Structure type. |
| 434 | * @param field_name Name of the structure's field. |
| 435 | * |
| 436 | * Returns a field type instance on success, NULL on error. |
| 437 | */ |
| 438 | extern |
| 439 | struct bt_ctf_field_type *bt_ctf_field_type_structure_get_field_type_by_name( |
| 440 | struct bt_ctf_field_type *structure, const char *field_name); |
| 441 | |
| 442 | /* |
| 443 | * bt_ctf_field_type_variant_create: create a variant field type. |
| 444 | * |
| 445 | * Allocate a new variant field type. The creation of a field type sets |
| 446 | * its reference count to 1. tag_name must be the name of an enumeration |
| 447 | * field declared in the same scope as this variant. |
| 448 | * |
| 449 | * @param enum_tag Type of the variant's tag/selector (must be an enumeration). |
| 450 | * @param tag_name Name of the variant's tag/selector field (will be copied). |
| 451 | * |
| 452 | * Returns an allocated field type on success, NULL on error. |
| 453 | */ |
| 454 | extern struct bt_ctf_field_type *bt_ctf_field_type_variant_create( |
| 455 | struct bt_ctf_field_type *enum_tag, const char *tag_name); |
| 456 | |
| 457 | /* |
| 458 | * bt_ctf_field_type_variant_get_tag_type: get a variant's tag type. |
| 459 | * |
| 460 | * @param variant Variant type. |
| 461 | * |
| 462 | * Returns a field type instance on success, NULL on error. |
| 463 | */ |
| 464 | extern struct bt_ctf_field_type *bt_ctf_field_type_variant_get_tag_type( |
| 465 | struct bt_ctf_field_type *variant); |
| 466 | |
| 467 | /* |
| 468 | * bt_ctf_field_type_variant_get_tag_name: get a variant's tag name. |
| 469 | * |
| 470 | * @param variant Variant type. |
| 471 | * |
| 472 | * Returns the tag field's name, NULL on error. |
| 473 | */ |
| 474 | extern const char *bt_ctf_field_type_variant_get_tag_name( |
| 475 | struct bt_ctf_field_type *variant); |
| 476 | |
| 477 | /* |
| 478 | * bt_ctf_field_type_variant_add_field: add a field to a variant. |
| 479 | * |
| 480 | * Add a field of type "field_type" to the variant. The variant will share |
| 481 | * field_type's ownership by increasing its reference count. The "field_name" |
| 482 | * will be copied. field_name must match a mapping in the tag/selector |
| 483 | * enumeration. |
| 484 | * |
| 485 | * @param variant Variant type. |
| 486 | * @param field_type Type of the variant type's new field. |
| 487 | * @param field_name Name of the variant type's new field (will be copied). |
| 488 | * |
| 489 | * Returns 0 on success, a negative value on error. |
| 490 | */ |
| 491 | extern int bt_ctf_field_type_variant_add_field( |
| 492 | struct bt_ctf_field_type *variant, |
| 493 | struct bt_ctf_field_type *field_type, |
| 494 | const char *field_name); |
| 495 | |
| 496 | /* |
| 497 | * bt_ctf_field_type_variant_get_field_type_by_name: get variant field's type. |
| 498 | * |
| 499 | * @param structure Variant type. |
| 500 | * @param field_name Name of the variant's field. |
| 501 | * |
| 502 | * Returns a field type instance on success, NULL on error. |
| 503 | */ |
| 504 | extern |
| 505 | struct bt_ctf_field_type *bt_ctf_field_type_variant_get_field_type_by_name( |
| 506 | struct bt_ctf_field_type *variant, const char *field_name); |
| 507 | |
| 508 | /* |
| 509 | * bt_ctf_field_type_variant_get_field_type_from_tag: get variant field's type. |
| 510 | * |
| 511 | * @param variant Variant type. |
| 512 | * @param tag Type tag (enum). |
| 513 | * |
| 514 | * Returns a field type instance on success, NULL on error. |
| 515 | */ |
| 516 | extern |
| 517 | struct bt_ctf_field_type *bt_ctf_field_type_variant_get_field_type_from_tag( |
| 518 | struct bt_ctf_field_type *variant, struct bt_ctf_field *tag); |
| 519 | |
| 520 | /* |
| 521 | * bt_ctf_field_type_variant_get_field_count: Get the number of fields defined |
| 522 | * in the variant. |
| 523 | * |
| 524 | * @param variant Variant type. |
| 525 | * |
| 526 | * Returns the field count on success, a negative value on error. |
| 527 | */ |
| 528 | extern int bt_ctf_field_type_variant_get_field_count( |
| 529 | struct bt_ctf_field_type *variant); |
| 530 | |
| 531 | /* |
| 532 | * bt_ctf_field_type_variant_get_field: get a variant's field name and type. |
| 533 | * |
| 534 | * @param variant Variant type. |
| 535 | * @param field_type Pointer to a const char* where the field's name will |
| 536 | * be returned. |
| 537 | * @param field_type Pointer to a bt_ctf_field_type* where the field's type will |
| 538 | * be returned. |
| 539 | * @param index Index of field. |
| 540 | * |
| 541 | * Returns 0 on success, a negative value on error. |
| 542 | */ |
| 543 | extern int bt_ctf_field_type_variant_get_field( |
| 544 | struct bt_ctf_field_type *variant, const char **field_name, |
| 545 | struct bt_ctf_field_type **field_type, int index); |
| 546 | |
| 547 | /* |
| 548 | * bt_ctf_field_type_array_create: create an array field type. |
| 549 | * |
| 550 | * Allocate a new array field type. The creation of a field type sets |
| 551 | * its reference count to 1. |
| 552 | * |
| 553 | * @param element_type Array's element type. |
| 554 | * @oaram length Array type's length. |
| 555 | * |
| 556 | * Returns an allocated field type on success, NULL on error. |
| 557 | */ |
| 558 | extern struct bt_ctf_field_type *bt_ctf_field_type_array_create( |
| 559 | struct bt_ctf_field_type *element_type, unsigned int length); |
| 560 | |
| 561 | /* |
| 562 | * bt_ctf_field_type_array_get_element_type: get an array's element type. |
| 563 | * |
| 564 | * @param array Array type. |
| 565 | * |
| 566 | * Returns a field type instance on success, NULL on error. |
| 567 | */ |
| 568 | extern struct bt_ctf_field_type *bt_ctf_field_type_array_get_element_type( |
| 569 | struct bt_ctf_field_type *array); |
| 570 | |
| 571 | /* |
| 572 | * bt_ctf_field_type_array_get_length: get an array's length. |
| 573 | * |
| 574 | * @param array Array type. |
| 575 | * |
| 576 | * Returns the array's length on success, a negative value on error. |
| 577 | */ |
| 578 | extern int64_t bt_ctf_field_type_array_get_length( |
| 579 | struct bt_ctf_field_type *array); |
| 580 | |
| 581 | /* |
| 582 | * bt_ctf_field_type_sequence_create: create a sequence field type. |
| 583 | * |
| 584 | * Allocate a new sequence field type. The creation of a field type sets |
| 585 | * its reference count to 1. "length_field_name" must match an integer field |
| 586 | * declared in the same scope. |
| 587 | * |
| 588 | * @param element_type Sequence's element type. |
| 589 | * @param length_field_name Name of the sequence's length field (will be |
| 590 | * copied). |
| 591 | * |
| 592 | * Returns an allocated field type on success, NULL on error. |
| 593 | */ |
| 594 | extern struct bt_ctf_field_type *bt_ctf_field_type_sequence_create( |
| 595 | struct bt_ctf_field_type *element_type, |
| 596 | const char *length_field_name); |
| 597 | |
| 598 | /* |
| 599 | * bt_ctf_field_type_sequence_get_element_type: get a sequence's element type. |
| 600 | * |
| 601 | * @param sequence Sequence type. |
| 602 | * |
| 603 | * Returns a field type instance on success, NULL on error. |
| 604 | */ |
| 605 | extern struct bt_ctf_field_type *bt_ctf_field_type_sequence_get_element_type( |
| 606 | struct bt_ctf_field_type *sequence); |
| 607 | |
| 608 | /* |
| 609 | * bt_ctf_field_type_sequence_get_length_field_name: get length field name. |
| 610 | * |
| 611 | * @param sequence Sequence type. |
| 612 | * |
| 613 | * Returns the sequence's length field on success, NULL on error. |
| 614 | */ |
| 615 | extern const char *bt_ctf_field_type_sequence_get_length_field_name( |
| 616 | struct bt_ctf_field_type *sequence); |
| 617 | |
| 618 | /* |
| 619 | * bt_ctf_field_type_string_create: create a string field type. |
| 620 | * |
| 621 | * Allocate a new string field type. The creation of a field type sets |
| 622 | * its reference count to 1. |
| 623 | * |
| 624 | * Returns an allocated field type on success, NULL on error. |
| 625 | */ |
| 626 | extern struct bt_ctf_field_type *bt_ctf_field_type_string_create(void); |
| 627 | |
| 628 | /* |
| 629 | * bt_ctf_field_type_string_get_encoding: get a string type's encoding. |
| 630 | * |
| 631 | * Get the string type's encoding. |
| 632 | * |
| 633 | * @param string_type String type. |
| 634 | * |
| 635 | * Returns the string's encoding on success, a CTF_STRING_UNKNOWN on error. |
| 636 | */ |
| 637 | extern enum ctf_string_encoding bt_ctf_field_type_string_get_encoding( |
| 638 | struct bt_ctf_field_type *string_type); |
| 639 | |
| 640 | /* |
| 641 | * bt_ctf_field_type_string_set_encoding: set a string type's encoding. |
| 642 | * |
| 643 | * Set the string type's encoding. |
| 644 | * |
| 645 | * @param string_type String type. |
| 646 | * @param encoding String field encoding, default CTF_STRING_ENCODING_ASCII. |
| 647 | * Valid values are CTF_STRING_ENCODING_ASCII and CTF_STRING_ENCODING_UTF8. |
| 648 | * |
| 649 | * Returns 0 on success, a negative value on error. |
| 650 | */ |
| 651 | extern int bt_ctf_field_type_string_set_encoding( |
| 652 | struct bt_ctf_field_type *string_type, |
| 653 | enum ctf_string_encoding encoding); |
| 654 | |
| 655 | /* |
| 656 | * bt_ctf_field_type_get_alignment: get a field type's alignment. |
| 657 | * |
| 658 | * Get the field type's alignment. |
| 659 | * |
| 660 | * @param type Field type. |
| 661 | * |
| 662 | * Returns the field type's alignment on success, a negative value on error. |
| 663 | */ |
| 664 | extern int bt_ctf_field_type_get_alignment(struct bt_ctf_field_type *type); |
| 665 | |
| 666 | /* |
| 667 | * bt_ctf_field_type_set_alignment: set a field type's alignment. |
| 668 | * |
| 669 | * Set the field type's alignment. |
| 670 | * |
| 671 | * @param type Field type. |
| 672 | * @param alignment Type's alignment. Defaults to 1 (bit-aligned). However, |
| 673 | * some types, such as structures and string, may impose other alignment |
| 674 | * constraints. |
| 675 | * |
| 676 | * Returns 0 on success, a negative value on error. |
| 677 | */ |
| 678 | extern int bt_ctf_field_type_set_alignment(struct bt_ctf_field_type *type, |
| 679 | unsigned int alignment); |
| 680 | |
| 681 | /* |
| 682 | * bt_ctf_field_type_get_byte_order: get a field type's byte order. |
| 683 | * |
| 684 | * @param type Field type. |
| 685 | * |
| 686 | * Returns the field type's byte order on success, a negative value on error. |
| 687 | */ |
| 688 | extern enum bt_ctf_byte_order bt_ctf_field_type_get_byte_order( |
| 689 | struct bt_ctf_field_type *type); |
| 690 | |
| 691 | /* |
| 692 | * bt_ctf_field_type_set_byte_order: set a field type's byte order. |
| 693 | * |
| 694 | * Set the field type's byte order. |
| 695 | * |
| 696 | * @param type Field type. |
| 697 | * @param byte_order Field type's byte order. Defaults to |
| 698 | * BT_CTF_BYTE_ORDER_NATIVE, the host machine's endianness. |
| 699 | * |
| 700 | * Returns 0 on success, a negative value on error. |
| 701 | */ |
| 702 | extern int bt_ctf_field_type_set_byte_order(struct bt_ctf_field_type *type, |
| 703 | enum bt_ctf_byte_order byte_order); |
| 704 | |
| 705 | /* |
| 706 | * bt_ctf_field_type_get_type_id: get a field type's ctf_type_id. |
| 707 | * |
| 708 | * @param type Field type. |
| 709 | * |
| 710 | * Returns the field type's ctf_type_id, CTF_TYPE_UNKNOWN on error. |
| 711 | */ |
| 712 | extern enum ctf_type_id bt_ctf_field_type_get_type_id( |
| 713 | struct bt_ctf_field_type *type); |
| 714 | |
| 715 | /* |
| 716 | * bt_ctf_field_type_get_alias_nameL get a field type's alias name |
| 717 | * |
| 718 | * A type's alias name is set if it was resolved from a typedef or |
| 719 | * typealias. Note that types that are resolved from a ypealias or |
| 720 | * typedef are distinct from the underlying type and can't be compared |
| 721 | * pointer-wise. |
| 722 | * |
| 723 | * @param type Field type. |
| 724 | * |
| 725 | * Returns a field type's alias name, NULL on error. |
| 726 | */ |
| 727 | extern const char *bt_ctf_field_type_get_alias_name( |
| 728 | struct bt_ctf_field_type *type); |
| 729 | |
| 730 | /* |
| 731 | * bt_ctf_field_type_get and bt_ctf_field_type_put: increment and decrement |
| 732 | * the field type's reference count. |
| 733 | * |
| 734 | * These functions ensure that the field type won't be destroyed while it |
| 735 | * is in use. The same number of get and put (plus one extra put to |
| 736 | * release the initial reference done at creation) have to be done to |
| 737 | * destroy a field type. |
| 738 | * |
| 739 | * When the field type's reference count is decremented to 0 by a |
| 740 | * bt_ctf_field_type_put, the field type is freed. |
| 741 | * |
| 742 | * @param type Field type. |
| 743 | */ |
| 744 | extern void bt_ctf_field_type_get(struct bt_ctf_field_type *type); |
| 745 | extern void bt_ctf_field_type_put(struct bt_ctf_field_type *type); |
| 746 | |
| 747 | #ifdef __cplusplus |
| 748 | } |
| 749 | #endif |
| 750 | |
| 751 | #endif /* BABELTRACE_CTF_IR_EVENT_TYPES_H */ |