4 * Babeltrace CTF IR - Field path
6 * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
7 * Copyright 2016 Philippe Proulx <pproulx@efficios.com>
9 * Permission is hereby granted, free of charge, to any person obtaining a copy
10 * of this software and associated documentation files (the "Software"), to deal
11 * in the Software without restriction, including without limitation the rights
12 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 * copies of the Software, and to permit persons to whom the Software is
14 * furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included in
17 * all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28 #include <babeltrace/ctf-ir/field-types.h>
29 #include <babeltrace/ctf-ir/field-path-internal.h>
30 #include <babeltrace/ctf-ir/field-path.h>
35 void field_path_destroy(struct bt_object
*obj
)
37 struct bt_ctf_field_path
*field_path
= (struct bt_ctf_field_path
*) obj
;
43 if (field_path
->indexes
) {
44 g_array_free(field_path
->indexes
, TRUE
);
50 struct bt_ctf_field_path
*bt_ctf_field_path_create(void)
52 struct bt_ctf_field_path
*field_path
= NULL
;
54 field_path
= g_new0(struct bt_ctf_field_path
, 1);
59 bt_object_init(field_path
, field_path_destroy
);
60 field_path
->root
= BT_CTF_SCOPE_UNKNOWN
;
61 field_path
->indexes
= g_array_new(TRUE
, FALSE
, sizeof(int));
62 if (!field_path
->indexes
) {
74 void bt_ctf_field_path_clear(struct bt_ctf_field_path
*field_path
)
76 if (field_path
->indexes
->len
> 0) {
77 g_array_remove_range(field_path
->indexes
, 0,
78 field_path
->indexes
->len
);
83 struct bt_ctf_field_path
*bt_ctf_field_path_copy(
84 struct bt_ctf_field_path
*path
)
86 struct bt_ctf_field_path
*new_path
= bt_ctf_field_path_create();
92 new_path
->root
= path
->root
;
93 g_array_insert_vals(new_path
->indexes
, 0,
94 path
->indexes
->data
, path
->indexes
->len
);
99 enum bt_ctf_scope
bt_ctf_field_path_get_root_scope(
100 const struct bt_ctf_field_path
*field_path
)
102 enum bt_ctf_scope scope
= BT_CTF_SCOPE_UNKNOWN
;
108 scope
= field_path
->root
;
114 int bt_ctf_field_path_get_index_count(
115 const struct bt_ctf_field_path
*field_path
)
123 ret
= field_path
->indexes
->len
;
129 int bt_ctf_field_path_get_index(const struct bt_ctf_field_path
*field_path
,
134 if (!field_path
|| index
< 0) {
138 if (index
>= field_path
->indexes
->len
) {
142 ret
= g_array_index(field_path
->indexes
, int, index
);
This page took 0.042582 seconds and 4 git commands to generate.