+ case BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR:
+ case BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR:
+ case BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR:
+ case BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR:
+ {
+ const bt_field_class *in_content_fc =
+ bt_field_class_option_borrow_field_class_const(
+ in_field_class);
+ bt_field_class *out_selector_fc = NULL;
+ bt_field_class *out_content_fc;
+ int ret;
+
+ out_content_fc = create_field_class_copy_internal(
+ md_maps, in_content_fc);
+ if (!out_content_fc) {
+ BT_COMP_LOGE_STR("Cannot copy option's content field class.");
+ goto error;
+ }
+
+ ret = copy_field_class_content_internal(md_maps,
+ in_content_fc, out_content_fc);
+ if (ret) {
+ BT_COMP_LOGE_STR("Error copying content of option's "
+ "content field class");
+ goto error;
+ }
+
+ if (fc_type == BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR) {
+ out_field_class =
+ bt_field_class_option_without_selector_create(
+ md_maps->output_trace_class,
+ out_content_fc);
+ } else {
+ const bt_field_path *in_selector_fp =
+ bt_field_class_option_with_selector_borrow_selector_field_path_const(
+ in_field_class);
+ const bt_field_class *in_selector_fc;
+
+ BT_ASSERT(in_selector_fp);
+ in_selector_fc = resolve_field_path_to_field_class(
+ in_selector_fp, md_maps);
+ BT_ASSERT(in_selector_fc);
+ out_selector_fc = g_hash_table_lookup(
+ md_maps->field_class_map, in_selector_fc);
+ BT_ASSERT(out_selector_fc);
+
+ if (fc_type == BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR) {
+ out_field_class =
+ bt_field_class_option_with_selector_bool_create(
+ md_maps->output_trace_class,
+ out_content_fc, out_selector_fc);
+ } else if (fc_type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR) {
+ const bt_integer_range_set_unsigned *ranges =
+ bt_field_class_option_with_selector_integer_unsigned_borrow_selector_ranges_const(
+ in_field_class);
+
+ BT_ASSERT(ranges);
+ out_field_class =
+ bt_field_class_option_with_selector_integer_unsigned_create(
+ md_maps->output_trace_class,
+ out_content_fc, out_selector_fc,
+ ranges);
+ } else if (fc_type == BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR) {
+ const bt_integer_range_set_signed *ranges =
+ bt_field_class_option_with_selector_integer_signed_borrow_selector_ranges_const(
+ in_field_class);
+
+ BT_ASSERT(ranges);
+ out_field_class =
+ bt_field_class_option_with_selector_integer_signed_create(
+ md_maps->output_trace_class,
+ out_content_fc, out_selector_fc,
+ ranges);
+ }
+ }
+
+ BT_ASSERT(out_field_class);
+ break;
+ }