From 8f3553be160b8643ba18c1bfda89d8ef6311ee11 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Mon, 27 Jul 2015 09:02:25 -0400 Subject: [PATCH] ir: add field instance type ID helpers MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau --- formats/ctf/ir/event-fields.c | 40 ++++++++++++ include/babeltrace/ctf-ir/event-fields.h | 80 ++++++++++++++++++++++++ 2 files changed, 120 insertions(+) diff --git a/formats/ctf/ir/event-fields.c b/formats/ctf/ir/event-fields.c index 4538d8e0..829a4475 100644 --- a/formats/ctf/ir/event-fields.c +++ b/formats/ctf/ir/event-fields.c @@ -295,6 +295,46 @@ end: return ret; } +int bt_ctf_field_is_integer(struct bt_ctf_field *field) +{ + return bt_ctf_field_get_type_id(field) == CTF_TYPE_INTEGER; +} + +int bt_ctf_field_is_floating_point(struct bt_ctf_field *field) +{ + return bt_ctf_field_get_type_id(field) == CTF_TYPE_FLOAT; +} + +int bt_ctf_field_is_enumeration(struct bt_ctf_field *field) +{ + return bt_ctf_field_get_type_id(field) == CTF_TYPE_ENUM; +} + +int bt_ctf_field_is_string(struct bt_ctf_field *field) +{ + return bt_ctf_field_get_type_id(field) == CTF_TYPE_STRING; +} + +int bt_ctf_field_is_structure(struct bt_ctf_field *field) +{ + return bt_ctf_field_get_type_id(field) == CTF_TYPE_STRUCT; +} + +int bt_ctf_field_is_array(struct bt_ctf_field *field) +{ + return bt_ctf_field_get_type_id(field) == CTF_TYPE_ARRAY; +} + +int bt_ctf_field_is_sequence(struct bt_ctf_field *field) +{ + return bt_ctf_field_get_type_id(field) == CTF_TYPE_SEQUENCE; +} + +int bt_ctf_field_is_variant(struct bt_ctf_field *field) +{ + return bt_ctf_field_get_type_id(field) == CTF_TYPE_VARIANT; +} + struct bt_ctf_field *bt_ctf_field_sequence_get_length( struct bt_ctf_field *field) { diff --git a/include/babeltrace/ctf-ir/event-fields.h b/include/babeltrace/ctf-ir/event-fields.h index a1e1351a..898fee98 100644 --- a/include/babeltrace/ctf-ir/event-fields.h +++ b/include/babeltrace/ctf-ir/event-fields.h @@ -366,6 +366,86 @@ extern struct bt_ctf_field_type *bt_ctf_field_get_type( */ extern enum ctf_type_id bt_ctf_field_get_type_id(struct bt_ctf_field *field); +/* + * bt_ctf_field_is_integer: returns whether or not a given field + * is an integer type. + * + * @param field Field instance. + * + * Returns 1 if the field instance is an integer type, 0 otherwise. + */ +extern int bt_ctf_field_is_integer(struct bt_ctf_field *field); + +/* + * bt_ctf_field_is_floating_point: returns whether or not a given field + * is a floating point number type. + * + * @param field Field instance. + * + * Returns 1 if the field instance is a floating point number type, 0 otherwise. + */ +extern int bt_ctf_field_is_floating_point(struct bt_ctf_field *field); + +/* + * bt_ctf_field_is_enumeration: returns whether or not a given field + * is an enumeration type. + * + * @param field Field instance. + * + * Returns 1 if the field instance is an enumeration type, 0 otherwise. + */ +extern int bt_ctf_field_is_enumeration(struct bt_ctf_field *field); + +/* + * bt_ctf_field_is_string: returns whether or not a given field + * is a string type. + * + * @param field Field instance. + * + * Returns 1 if the field instance is a string type, 0 otherwise. + */ +extern int bt_ctf_field_is_string(struct bt_ctf_field *field); + +/* + * bt_ctf_field_is_structure: returns whether or not a given field + * is a structure type. + * + * @param field Field instance. + * + * Returns 1 if the field instance is a structure type, 0 otherwise. + */ +extern int bt_ctf_field_is_structure(struct bt_ctf_field *field); + +/* + * bt_ctf_field_is_array: returns whether or not a given field + * is an array type. + * + * @param field Field instance. + * + * Returns 1 if the field instance is an array type, 0 otherwise. + */ +extern int bt_ctf_field_is_array(struct bt_ctf_field *field); + +/* + * bt_ctf_field_is_sequence: returns whether or not a given field + * is a sequence type. + * + * @param field Field instance. + * + * Returns 1 if the field instance is a sequence type, 0 otherwise. + */ +extern int bt_ctf_field_is_sequence(struct bt_ctf_field *field); + +/* + * bt_ctf_field_is_variant: returns whether or not a given field + * is a variant type. + * + * @param field Field instance. + * + * Returns 1 if the field instance is a variant type, 0 otherwise. + */ +extern int bt_ctf_field_is_variant(struct bt_ctf_field *field); + /* * bt_ctf_field_copy: get a field's deep copy. * -- 2.34.1