Add bt_ctf_field_type_enumeration private search functions
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 21 May 2014 16:15:36 +0000 (12:15 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 27 Jun 2014 20:07:25 +0000 (16:07 -0400)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
formats/ctf/ir/event-types.c
include/babeltrace/ctf-ir/event-types-internal.h

index 0c8eddc000fb9d1db9debefd1065334a28ccb366..7c5047f92aba18b5a67831435d1abdf1f774f1a2 100644 (file)
@@ -436,6 +436,51 @@ end:
        return ret;
 }
 
+const char *bt_ctf_field_type_enumeration_get_mapping_name_unsigned(
+               struct bt_ctf_field_type_enumeration *enumeration_type,
+               uint64_t value)
+{
+       const char *name = NULL;
+       struct range_overlap_query query =
+               (struct range_overlap_query) {
+               /* FIXME: should not need a cast */
+               .range_start = (int64_t) value,
+               .range_end = (int64_t) value,
+               .overlaps = 0 };
+
+       g_ptr_array_foreach(enumeration_type->entries, check_ranges_overlap,
+               &query);
+       if (!query.overlaps) {
+               goto end;
+       }
+
+       name = g_quark_to_string(query.mapping_name);
+end:
+       return name;
+}
+
+const char *bt_ctf_field_type_enumeration_get_mapping_name_signed(
+               struct bt_ctf_field_type_enumeration *enumeration_type,
+               int64_t value)
+{
+       const char *name = NULL;
+       struct range_overlap_query query =
+               (struct range_overlap_query) {
+               .range_start = value,
+               .range_end = value,
+               .overlaps = 0 };
+
+       g_ptr_array_foreach(enumeration_type->entries, check_ranges_overlap,
+               &query);
+       if (!query.overlaps) {
+               goto end;
+       }
+
+       name = g_quark_to_string(query.mapping_name);
+end:
+       return name;
+}
+
 struct bt_ctf_field_type *bt_ctf_field_type_floating_point_create(void)
 {
        struct bt_ctf_field_type_floating_point *floating_point =
index 27e4a17503eef04700056a1f4f3a42473ea95813..a0a6f9c4cff369678fe3e24c018db88ccbf4292e 100644 (file)
@@ -150,4 +150,14 @@ int bt_ctf_field_type_serialize(struct bt_ctf_field_type *type,
 BT_HIDDEN
 int bt_ctf_field_type_validate(struct bt_ctf_field_type *type);
 
+BT_HIDDEN
+const char *bt_ctf_field_type_enumeration_get_mapping_name_unsigned(
+               struct bt_ctf_field_type_enumeration *enumeration_type,
+               uint64_t value);
+
+BT_HIDDEN
+const char *bt_ctf_field_type_enumeration_get_mapping_name_signed(
+               struct bt_ctf_field_type_enumeration *enumeration_type,
+               int64_t value);
+
 #endif /* BABELTRACE_CTF_IR_EVENT_TYPES_INTERNAL_H */
This page took 0.026574 seconds and 4 git commands to generate.