ir: add bt_ctf_field_type_structure_get_field_name_index()
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 11 May 2015 21:19:17 +0000 (17:19 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 11 May 2015 21:19:17 +0000 (17:19 -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 11ca0e9e0b44bf57e359c92d034a8a73aa66112a..195f935d521a11f86ed58dd2aecb6c03b985f957 100644 (file)
@@ -1955,6 +1955,39 @@ end:
        return copy;
 }
 
+
+BT_HIDDEN
+int bt_ctf_field_type_structure_get_field_name_index(
+               struct bt_ctf_field_type *type, const char *name)
+{
+       int ret;
+       size_t index;
+       GQuark name_quark;
+       struct bt_ctf_field_type_structure *structure;
+
+       if (!type || !name ||
+               bt_ctf_field_type_get_type_id(type) != CTF_TYPE_STRUCT) {
+               ret = -1;
+               goto end;
+       }
+
+       name_quark = g_quark_try_string(name);
+       if (!name_quark) {
+               ret = -1;
+               goto end;
+       }
+
+       structure = container_of(type, struct bt_ctf_field_type_structure,
+               parent);
+       if (!g_hash_table_lookup_extended(structure->field_name_to_index,
+               GUINT_TO_POINTER(name_quark), NULL, (gpointer *)&index)) {
+               ret = -1;
+               goto end;
+       }
+       ret = (int) index;
+end:
+       return ret;
+}
 static
 void bt_ctf_field_type_integer_destroy(struct bt_ctf_ref *ref)
 {
index e7569f6fa14c1492150cf26f3c1801c6dea5e103..a5057e207b5cab8583781814389e0156f0a0407d 100644 (file)
@@ -165,4 +165,8 @@ BT_HIDDEN
 struct bt_ctf_field_type *bt_ctf_field_type_copy(
                struct bt_ctf_field_type *type);
 
+
+BT_HIDDEN
+int bt_ctf_field_type_structure_get_field_name_index(
+               struct bt_ctf_field_type *structure, const char *name);
 #endif /* BABELTRACE_CTF_IR_EVENT_TYPES_INTERNAL_H */
This page took 0.026293 seconds and 4 git commands to generate.