Add bt_ctf_field_type_compare(): field type deep comparison
[babeltrace.git] / include / babeltrace / ctf-ir / event-types.h
index 9562318172103ba14e1ad961af80a02b80f8b0b7..fbef87c8e08818886a9f3607f18f35bb2445d37e 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.
  *
@@ -686,7 +697,8 @@ extern int bt_ctf_field_type_string_set_encoding(
  *
  * @param type Field type.
  *
- * Returns the field type's alignment on success, a negative value on error.
+ * Returns the field type's alignment on success, a negative value on error and
+ * 0 if the alignment is undefined (as in the case of a variant).
  */
 extern int bt_ctf_field_type_get_alignment(struct bt_ctf_field_type *type);
 
@@ -729,6 +741,23 @@ extern enum bt_ctf_byte_order bt_ctf_field_type_get_byte_order(
 extern int bt_ctf_field_type_set_byte_order(struct bt_ctf_field_type *type,
                enum bt_ctf_byte_order byte_order);
 
+/*
+ * bt_ctf_field_type_compare: compare two field types recursively
+ *
+ * Compare two field types recursively.
+ *
+ * The registered tag field type of a variant field type is ignored:
+ * only the tag strings are compared.
+ *
+ * @param type_a Field type A.
+ * @param type_b Field type B.
+ *
+ * Returns 0 if both field types are semantically equivalent, or a
+ * negative value when they are not equivalent or on error.
+ */
+extern int bt_ctf_field_type_compare(struct bt_ctf_field_type *type_a,
+               struct bt_ctf_field_type *type_b);
+
 /*
  * bt_ctf_field_type_get_type_id: get a field type's ctf_type_id.
  *
@@ -740,24 +769,91 @@ extern enum ctf_type_id bt_ctf_field_type_get_type_id(
                struct bt_ctf_field_type *type);
 
 /*
- * bt_ctf_field_type_get_alias_nameL get a field type's alias name
+ * bt_ctf_field_type_is_integer: returns whether or not a given field
+ *     type is an integer type.
  *
- * A type's alias name is set if it was resolved from a typedef or
- * typealias. Note that types that are resolved from a ypealias or
- * typedef are distinct from the underlying type and can't be compared
- * pointer-wise.
+ * @param type Field type.
+ *
+ * Returns 1 if the field type is an integer type, 0 otherwise.
+ */
+extern int bt_ctf_field_type_is_integer(struct bt_ctf_field_type *type);
+
+/*
+ * bt_ctf_field_type_is_floating_point: returns whether or not a given field
+ *     type is a floating point number type.
  *
  * @param type Field type.
  *
- * Returns a field type's alias name, NULL on error.
+ * Returns 1 if the field type is a floating point number type, 0 otherwise.
  */
-extern const char *bt_ctf_field_type_get_alias_name(
-               struct bt_ctf_field_type *type);
+extern int bt_ctf_field_type_is_floating_point(struct bt_ctf_field_type *type);
+
+/*
+ * bt_ctf_field_type_is_enumeration: returns whether or not a given field
+ *     type is an enumeration type.
+ *
+ * @param type Field type.
+ *
+ * Returns 1 if the field type is an enumeration type, 0 otherwise.
+ */
+extern int bt_ctf_field_type_is_enumeration(struct bt_ctf_field_type *type);
+
+/*
+ * bt_ctf_field_type_is_string: returns whether or not a given field
+ *     type is a string type.
+ *
+ * @param type Field type.
+ *
+ * Returns 1 if the field type is a string type, 0 otherwise.
+ */
+extern int bt_ctf_field_type_is_string(struct bt_ctf_field_type *type);
+
+/*
+ * bt_ctf_field_type_is_structure: returns whether or not a given field
+ *     type is a structure type.
+ *
+ * @param type Field type.
+ *
+ * Returns 1 if the field type is a structure type, 0 otherwise.
+ */
+extern int bt_ctf_field_type_is_structure(struct bt_ctf_field_type *type);
+
+/*
+ * bt_ctf_field_type_is_array: returns whether or not a given field
+ *     type is an array type.
+ *
+ * @param type Field type.
+ *
+ * Returns 1 if the field type is an array type, 0 otherwise.
+ */
+extern int bt_ctf_field_type_is_array(struct bt_ctf_field_type *type);
+
+/*
+ * bt_ctf_field_type_is_sequence: returns whether or not a given field
+ *     type is a sequence type.
+ *
+ * @param type Field type.
+ *
+ * Returns 1 if the field type is a sequence type, 0 otherwise.
+ */
+extern int bt_ctf_field_type_is_sequence(struct bt_ctf_field_type *type);
+
+/*
+ * bt_ctf_field_type_is_variant: returns whether or not a given field
+ *     type is a variant type.
+ *
+ * @param type Field type.
+ *
+ * Returns 1 if the field type is a variant type, 0 otherwise.
+ */
+extern int bt_ctf_field_type_is_variant(struct bt_ctf_field_type *type);
 
 /*
  * bt_ctf_field_type_get and bt_ctf_field_type_put: increment and decrement
  * the field type's reference count.
  *
+ * You may also use bt_ctf_get() and bt_ctf_put() with field type objects.
+ *
  * These functions ensure that the field type won't be destroyed while it
  * is in use. The same number of get and put (plus one extra put to
  * release the initial reference done at creation) have to be done to
This page took 0.024581 seconds and 4 git commands to generate.