Fix: lib: pass down API function name to some helpers
[babeltrace.git] / src / lib / trace-ir / field-path.h
CommitLineData
b011f6b0 1/*
0235b0db 2 * SPDX-License-Identifier: MIT
b011f6b0 3 *
0235b0db 4 * Copyright 2016-2018 Philippe Proulx <pproulx@efficios.com>
b011f6b0
PP
5 *
6 * The Common Trace Format (CTF) Specification is available at
7 * http://www.efficios.com/ctf
8 */
9
0235b0db
MJ
10#ifndef BABELTRACE_TRACE_IR_FIELD_PATH_INTERNAL
11#define BABELTRACE_TRACE_IR_FIELD_PATH_INTERNAL
12
578e048b 13#include "lib/object.h"
43c59509 14#include <babeltrace2/trace-ir/field-path.h>
578e048b 15#include "common/assert.h"
91d81473 16#include "common/macros.h"
b011f6b0
PP
17#include <glib.h>
18
66ddcddf
PP
19struct bt_field_path_item {
20 enum bt_field_path_item_type type;
21 uint64_t index;
22};
23
50842bdc 24struct bt_field_path {
b011f6b0 25 struct bt_object base;
e7ceb9df 26 enum bt_field_path_scope root;
b011f6b0 27
66ddcddf
PP
28 /* Array of `struct bt_field_path_item` (items) */
29 GArray *items;
b011f6b0
PP
30};
31
32BT_HIDDEN
50842bdc 33struct bt_field_path *bt_field_path_create(void);
b011f6b0 34
44c440bc 35static inline
66ddcddf 36struct bt_field_path_item *bt_field_path_borrow_item_by_index_inline(
40f4ba76 37 const struct bt_field_path *field_path, uint64_t index)
44c440bc 38{
98b15851
PP
39 BT_ASSERT_DBG(field_path);
40 BT_ASSERT_DBG(index < field_path->items->len);
66ddcddf
PP
41 return &g_array_index(field_path->items, struct bt_field_path_item,
42 index);
43}
44
45static inline
46void bt_field_path_append_item(struct bt_field_path *field_path,
47 struct bt_field_path_item *item)
48{
49 BT_ASSERT(field_path);
50 BT_ASSERT(item);
51 g_array_append_val(field_path->items, *item);
52}
53
54static inline
55void bt_field_path_remove_last_item(struct bt_field_path *field_path)
56{
57 BT_ASSERT(field_path);
58 BT_ASSERT(field_path->items->len > 0);
59 g_array_set_size(field_path->items, field_path->items->len - 1);
44c440bc 60}
b011f6b0 61
66ddcddf
PP
62static inline
63const char *bt_field_path_item_type_string(enum bt_field_path_item_type type)
64{
65 switch (type) {
66 case BT_FIELD_PATH_ITEM_TYPE_INDEX:
8a432889 67 return "INDEX";
66ddcddf 68 case BT_FIELD_PATH_ITEM_TYPE_CURRENT_ARRAY_ELEMENT:
8a432889 69 return "CURRENT_ARRAY_ELEMENT";
66ddcddf
PP
70 default:
71 return "(unknown)";
72 }
73};
74
56e18c4c 75#endif /* BABELTRACE_TRACE_IR_FIELD_PATH_INTERNAL */
This page took 0.094496 seconds and 4 git commands to generate.