From: Philippe Proulx Date: Wed, 14 Aug 2019 02:01:03 +0000 (-0400) Subject: lib: add bt_field_class_variant_borrow_option_by_{index,name}() X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=c6fe8c4012c19ba7ab7fc16853a464e0381d6290 lib: add bt_field_class_variant_borrow_option_by_{index,name}() Those are non-const versions of the existing bt_field_class_variant_borrow_option_by_index_const() and bt_field_class_variant_borrow_option_by_name_const(). Signed-off-by: Philippe Proulx Change-Id: I322c202c35d815012d2f6de494dce76a161692e4 Reviewed-on: https://review.lttng.org/c/babeltrace/+/1920 Tested-by: jenkins Reviewed-by: Francis Deslauriers --- diff --git a/include/babeltrace2/trace-ir/field-class.h b/include/babeltrace2/trace-ir/field-class.h index f4f722c3..083facbe 100644 --- a/include/babeltrace2/trace-ir/field-class.h +++ b/include/babeltrace2/trace-ir/field-class.h @@ -155,6 +155,14 @@ bt_field_class_variant_with_selector_signed_append_option( bt_field_class *field_class, const bt_integer_range_set_signed *range_set); +extern bt_field_class_variant_option * +bt_field_class_variant_borrow_option_by_index( + bt_field_class *field_class, uint64_t index); + +extern bt_field_class_variant_option * +bt_field_class_variant_borrow_option_by_name( + bt_field_class *field_class, const char *name); + #ifdef __cplusplus } #endif diff --git a/src/lib/trace-ir/field-class.c b/src/lib/trace-ir/field-class.c index 259a32fe..78e30f4d 100644 --- a/src/lib/trace-ir/field-class.c +++ b/src/lib/trace-ir/field-class.c @@ -1478,6 +1478,28 @@ bt_field_class_variant_borrow_option_by_index_const( (void *) fc, index); } +struct bt_field_class_variant_option * +bt_field_class_variant_borrow_option_by_name( + struct bt_field_class *fc, const char *name) +{ + BT_ASSERT_PRE_DEV_NON_NULL(fc, "Field class"); + BT_ASSERT_PRE_DEV_FC_IS_VARIANT(fc, "Field class"); + return (void *) + borrow_named_field_class_from_container_field_class_by_name( + (void *) fc, name); +} + +struct bt_field_class_variant_option * +bt_field_class_variant_borrow_option_by_index( + struct bt_field_class *fc, uint64_t index) +{ + BT_ASSERT_PRE_DEV_NON_NULL(fc, "Field class"); + BT_ASSERT_PRE_DEV_FC_IS_VARIANT(fc, "Field class"); + return (void *) + borrow_named_field_class_from_container_field_class_at_index( + (void *) fc, index); +} + const struct bt_field_class_variant_with_selector_unsigned_option * bt_field_class_variant_with_selector_unsigned_borrow_option_by_name_const( const struct bt_field_class *fc, const char *name)