Rename bt_ctf_X -> bt_X, maintain backward compat. for pre-2.0 CTF writer
[babeltrace.git] / include / babeltrace / ctf-ir / field-path-internal.h
index b270094baaffd20691f3a7be7903d6dd7e70fa00..a65ffe101c1d1650c50ba7f0411e8c405fa76e97 100644 (file)
  */
 
 #include <babeltrace/object-internal.h>
+#include <assert.h>
 #include <glib.h>
 
-struct bt_ctf_field_path {
+struct bt_field_path {
        struct bt_object base;
-       enum bt_ctf_scope root;
+       enum bt_scope root;
 
        /*
         * Array of integers (int) indicating the index in either
@@ -45,16 +46,39 @@ struct bt_ctf_field_path {
 };
 
 BT_HIDDEN
-struct bt_ctf_field_path *bt_ctf_field_path_create(void);
+struct bt_field_path *bt_field_path_create(void);
 
 BT_HIDDEN
-void bt_ctf_field_path_clear(struct bt_ctf_field_path *field_path);
+void bt_field_path_clear(struct bt_field_path *field_path);
 
 BT_HIDDEN
-struct bt_ctf_field_path *bt_ctf_field_path_copy(
-               struct bt_ctf_field_path *path);
+struct bt_field_path *bt_field_path_copy(
+               struct bt_field_path *path);
 
-BT_HIDDEN
-GString *bt_ctf_field_path_string(struct bt_ctf_field_path *path);
+static inline
+GString *bt_field_path_string(struct bt_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_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;
+}
 
 #endif /* BABELTRACE_CTF_IR_FIELD_PATH_INTERNAL */
This page took 0.024481 seconds and 4 git commands to generate.