Implement bt_ctf_field_type_variant_set_tag_name()
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 9 Mar 2015 18:28:08 +0000 (14:28 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 16 Mar 2015 19:01:45 +0000 (15:01 -0400)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
formats/ctf/ir/event-types.c
include/babeltrace/ctf-ir/event-types.h

index a4dca127eb0c7c0b39280f3e2984cb4dd3928e52..11ca0e9e0b44bf57e359c92d034a8a73aa66112a 100644 (file)
@@ -1334,6 +1334,25 @@ end:
        return tag_name;
 }
 
+int bt_ctf_field_type_variant_set_tag_name(
+               struct bt_ctf_field_type *type, const char *name)
+{
+       int ret = 0;
+       struct bt_ctf_field_type_variant *variant;
+
+       if (!type || type->frozen ||
+               (type->declaration->id != CTF_TYPE_VARIANT) ||
+               bt_ctf_validate_identifier(name)) {
+               ret = -1;
+               goto end;
+       }
+
+       variant = container_of(type, struct bt_ctf_field_type_variant, parent);
+       g_string_assign(variant->tag_name, name);
+end:
+       return ret;
+}
+
 int bt_ctf_field_type_variant_add_field(struct bt_ctf_field_type *type,
                struct bt_ctf_field_type *field_type,
                const char *field_name)
index 19dd6a330b178f0f4b178a1a7952c4b76705275b..2006943536491b25e9f1b8731ade15e70328b2fe 100644 (file)
@@ -501,6 +501,17 @@ extern struct bt_ctf_field_type *bt_ctf_field_type_variant_get_tag_type(
 extern const char *bt_ctf_field_type_variant_get_tag_name(
                struct bt_ctf_field_type *variant);
 
+/*
+ * bt_ctf_field_type_variant_set_tag_name: set a variant's tag name.
+ *
+ * @param variant Variant type.
+ * @param name Tag field name.
+ *
+ * Returns 0 on success, a negative value on error.
+ */
+extern int bt_ctf_field_type_variant_set_tag_name(
+               struct bt_ctf_field_type *variant, const char *name);
+
 /*
  * bt_ctf_field_type_variant_add_field: add a field to a variant.
  *
This page took 0.027367 seconds and 4 git commands to generate.