Add bt_ctf_field_variant_get_tag
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 28 Oct 2016 15:49:46 +0000 (11:49 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sat, 27 May 2017 18:09:06 +0000 (14:09 -0400)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
formats/ctf/ir/fields.c
include/babeltrace/ctf-ir/fields.h

index 105dd7a1dbe737317a3114c08a9f617710c55c8a..2aeb71b53ba0880eeb05c1a20d7d69a90a165024 100644 (file)
@@ -788,6 +788,27 @@ end:
        return current_field;
 }
 
+struct bt_ctf_field *bt_ctf_field_variant_get_tag(
+               struct bt_ctf_field *variant_field)
+{
+       struct bt_ctf_field *tag = NULL;
+       struct bt_ctf_field_variant *variant;
+
+       if (!variant_field ||
+                       bt_ctf_field_type_get_type_id(variant_field->type) !=
+                       BT_CTF_TYPE_ID_VARIANT) {
+               goto end;
+       }
+
+       variant = container_of(variant_field, struct bt_ctf_field_variant,
+                       parent);
+       if (variant->tag) {
+               tag = bt_get(variant->tag);
+       }
+end:
+       return tag;
+}
+
 struct bt_ctf_field *bt_ctf_field_enumeration_get_container(
        struct bt_ctf_field *field)
 {
index cbed745a17d180b26868149ca6d08c5c07af8284..9ef06e281b007b2e559fbc75beb1c09226f007ed 100644 (file)
@@ -170,6 +170,22 @@ extern struct bt_ctf_field *bt_ctf_field_variant_get_field(
 extern struct bt_ctf_field *bt_ctf_field_variant_get_current_field(
                struct bt_ctf_field *variant);
 
+/*
+ * bt_ctf_field_variant_get_tag: get the tag field of a variant.
+ *
+ * Return the variant's associated tag field. This function, unlike
+ * bt_ctf_field_variant_get_field(), does not create any field; it
+ * returns NULL if there's no current selected field yet (and, thus, no
+ * associated tag).
+ *
+ * @param variant Variant field instance.
+ *
+ * Returns a field instance (enumeration) on success, NULL on error or when
+ * there is no currently selected field.
+ */
+extern struct bt_ctf_field *bt_ctf_field_variant_get_tag(
+               struct bt_ctf_field *variant);
+
 /*
  * bt_ctf_field_enumeration_get_container: get an enumeration field's container.
  *
This page took 0.026046 seconds and 4 git commands to generate.