field-path.c: add internal function to stringify a field path
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 24 May 2017 21:59:03 +0000 (17:59 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sun, 28 May 2017 16:57:44 +0000 (12:57 -0400)
This is to be used by logging statements.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
include/babeltrace/ctf-ir/field-path-internal.h
lib/ctf-ir/field-path.c

index de08a87e9c2696881c79586d2338d02f17bdc77e..b270094baaffd20691f3a7be7903d6dd7e70fa00 100644 (file)
@@ -54,4 +54,7 @@ BT_HIDDEN
 struct bt_ctf_field_path *bt_ctf_field_path_copy(
                struct bt_ctf_field_path *path);
 
+BT_HIDDEN
+GString *bt_ctf_field_path_string(struct bt_ctf_field_path *path);
+
 #endif /* BABELTRACE_CTF_IR_FIELD_PATH_INTERNAL */
index 9b991dedcf970d54240aa40d93539fbefe9f7570..ac42ef5cc481de6d61dd98e689cdc6c10dc26d0e 100644 (file)
@@ -29,6 +29,7 @@
 #include <babeltrace/lib-logging-internal.h>
 
 #include <babeltrace/ctf-ir/field-types.h>
+#include <babeltrace/ctf-ir/field-types-internal.h>
 #include <babeltrace/ctf-ir/field-path-internal.h>
 #include <babeltrace/ctf-ir/field-path.h>
 #include <limits.h>
@@ -169,3 +170,29 @@ int bt_ctf_field_path_get_index(const struct bt_ctf_field_path *field_path,
 end:
        return ret;
 }
+
+BT_HIDDEN
+GString *bt_ctf_field_path_string(struct bt_ctf_field_path *path)
+{
+       GString *str = g_string_new(NULL);
+       size_t i;
+
+       assert(path);
+
+       if (!str) {
+               goto end;
+       }
+
+       g_string_append_printf(str, "[%s", bt_ctf_scope_string(path->root));
+
+       for (i = 0; i < path->indexes->len; i++) {
+               int index = g_array_index(path->indexes, int, i);
+
+               g_string_append_printf(str, ", %d", index);
+       }
+
+       g_string_append(str, "]");
+
+end:
+       return str;
+}
This page took 0.025448 seconds and 4 git commands to generate.