From: Philippe Proulx Date: Mon, 27 Jul 2015 12:56:02 +0000 (-0400) Subject: ir: add field type ID helpers X-Git-Tag: v2.0.0-pre1~1202 X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=56db8d7a1b50e9e83684eaf448d483e5f94ff795;p=babeltrace.git ir: add field type ID helpers Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau --- diff --git a/formats/ctf/ir/event-types.c b/formats/ctf/ir/event-types.c index 74fa3047..31cd2524 100644 --- a/formats/ctf/ir/event-types.c +++ b/formats/ctf/ir/event-types.c @@ -1906,6 +1906,46 @@ enum ctf_type_id bt_ctf_field_type_get_type_id( return type->declaration->id; } +int bt_ctf_field_type_is_integer(struct bt_ctf_field_type *type) +{ + return bt_ctf_field_type_get_type_id(type) == CTF_TYPE_INTEGER; +} + +int bt_ctf_field_type_is_floating_point(struct bt_ctf_field_type *type) +{ + return bt_ctf_field_type_get_type_id(type) == CTF_TYPE_FLOAT; +} + +int bt_ctf_field_type_is_enumeration(struct bt_ctf_field_type *type) +{ + return bt_ctf_field_type_get_type_id(type) == CTF_TYPE_ENUM; +} + +int bt_ctf_field_type_is_string(struct bt_ctf_field_type *type) +{ + return bt_ctf_field_type_get_type_id(type) == CTF_TYPE_STRING; +} + +int bt_ctf_field_type_is_structure(struct bt_ctf_field_type *type) +{ + return bt_ctf_field_type_get_type_id(type) == CTF_TYPE_STRUCT; +} + +int bt_ctf_field_type_is_array(struct bt_ctf_field_type *type) +{ + return bt_ctf_field_type_get_type_id(type) == CTF_TYPE_ARRAY; +} + +int bt_ctf_field_type_is_sequence(struct bt_ctf_field_type *type) +{ + return bt_ctf_field_type_get_type_id(type) == CTF_TYPE_SEQUENCE; +} + +int bt_ctf_field_type_is_variant(struct bt_ctf_field_type *type) +{ + return bt_ctf_field_type_get_type_id(type) == CTF_TYPE_VARIANT; +} + void bt_ctf_field_type_get(struct bt_ctf_field_type *type) { bt_get(type); diff --git a/include/babeltrace/ctf-ir/event-types.h b/include/babeltrace/ctf-ir/event-types.h index d777ce6b..059a5b84 100644 --- a/include/babeltrace/ctf-ir/event-types.h +++ b/include/babeltrace/ctf-ir/event-types.h @@ -751,6 +751,86 @@ extern int bt_ctf_field_type_set_byte_order(struct bt_ctf_field_type *type, extern enum ctf_type_id bt_ctf_field_type_get_type_id( struct bt_ctf_field_type *type); +/* + * bt_ctf_field_type_is_integer: returns whether or not a given field + * type is an integer type. + * + * @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 1 if the field type is a floating point number type, 0 otherwise. + */ +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.