lib: Reset libbabeltrace2 to SONANE 0
[babeltrace.git] / include / babeltrace / trace-ir / field-path-internal.h
index fd6ebc3c3cfb16039d9ae31e0cddf6345f82c02b..ffb8ad06f3ece7fbf57501324b30513fa250f70e 100644 (file)
@@ -2,9 +2,7 @@
 #define BABELTRACE_TRACE_IR_FIELD_PATH_INTERNAL
 
 /*
- * BabelTrace - Trace IR: Field path
- *
- * Copyright 2016 Philippe Proulx <pproulx@efficios.com>
+ * Copyright 2016-2018 Philippe Proulx <pproulx@efficios.com>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
  */
 
 #include <babeltrace/object-internal.h>
-#include <babeltrace/trace-ir/field-path.h>
+#include <babeltrace/trace-ir/field-path-const.h>
 #include <babeltrace/assert-internal.h>
 #include <glib.h>
 
+struct bt_field_path_item {
+       enum bt_field_path_item_type type;
+       uint64_t index;
+};
+
 struct bt_field_path {
        struct bt_object base;
        enum bt_scope root;
 
-       /* Array of `uint64_t` (indexes) */
-       GArray *indexes;
+       /* Array of `struct bt_field_path_item` (items) */
+       GArray *items;
 };
 
 BT_HIDDEN
 struct bt_field_path *bt_field_path_create(void);
 
 static inline
-uint64_t bt_field_path_get_index_by_index_inline(
-               struct bt_field_path *field_path, uint64_t index)
+struct bt_field_path_item *bt_field_path_borrow_item_by_index_inline(
+               const struct bt_field_path *field_path, uint64_t index)
 {
        BT_ASSERT(field_path);
-       BT_ASSERT(index < field_path->indexes->len);
-       return g_array_index(field_path->indexes, uint64_t, index);
+       BT_ASSERT(index < field_path->items->len);
+       return &g_array_index(field_path->items, struct bt_field_path_item,
+               index);
 }
 
+static inline
+void bt_field_path_append_item(struct bt_field_path *field_path,
+               struct bt_field_path_item *item)
+{
+       BT_ASSERT(field_path);
+       BT_ASSERT(item);
+       g_array_append_val(field_path->items, *item);
+}
+
+static inline
+void bt_field_path_remove_last_item(struct bt_field_path *field_path)
+{
+       BT_ASSERT(field_path);
+       BT_ASSERT(field_path->items->len > 0);
+       g_array_set_size(field_path->items, field_path->items->len - 1);
+}
+
+static inline
+const char *bt_field_path_item_type_string(enum bt_field_path_item_type type)
+{
+       switch (type) {
+       case BT_FIELD_PATH_ITEM_TYPE_INDEX:
+               return "BT_FIELD_PATH_ITEM_TYPE_INDEX";
+       case BT_FIELD_PATH_ITEM_TYPE_CURRENT_ARRAY_ELEMENT:
+               return "BT_FIELD_PATH_ITEM_TYPE_CURRENT_ARRAY_ELEMENT";
+       default:
+               return "(unknown)";
+       }
+};
+
 #endif /* BABELTRACE_TRACE_IR_FIELD_PATH_INTERNAL */
This page took 0.023571 seconds and 4 git commands to generate.