Fix: add missing void param to bt_clock_class_priority_map_create
[babeltrace.git] / bindings / python / bt2 / native_btvalues.i
CommitLineData
81447b5b
PP
1/*
2 * The MIT License (MIT)
3 *
4 * Copyright (c) 2016 Philippe Proulx <pproulx@efficios.com>
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24
81447b5b
PP
25/* Remove prefix from `bt_value_null` */
26%rename(value_null) bt_value_null;
27
28/* Type and status */
29struct bt_value;
30
31enum bt_value_type {
32 BT_VALUE_TYPE_UNKNOWN = -1,
33 BT_VALUE_TYPE_NULL = 0,
34 BT_VALUE_TYPE_BOOL = 1,
35 BT_VALUE_TYPE_INTEGER = 2,
36 BT_VALUE_TYPE_FLOAT = 3,
37 BT_VALUE_TYPE_STRING = 4,
38 BT_VALUE_TYPE_ARRAY = 5,
39 BT_VALUE_TYPE_MAP = 6,
40};
41
42enum bt_value_type bt_value_get_type(const struct bt_value *object);
43
44enum bt_value_status {
45 BT_VALUE_STATUS_FROZEN = -4,
46 BT_VALUE_STATUS_CANCELLED = -3,
47 BT_VALUE_STATUS_INVAL = -22,
48 BT_VALUE_STATUS_ERROR = -1,
49 BT_VALUE_STATUS_OK = 0,
50};
51
52/* Null value object singleton */
53struct bt_value * const bt_value_null;
54
55/* Common functions */
56enum bt_value_status bt_value_freeze(struct bt_value *object);
811644b8 57int bt_value_is_frozen(const struct bt_value *object);
81447b5b 58struct bt_value *bt_value_copy(const struct bt_value *object);
811644b8 59int bt_value_compare(const struct bt_value *object_a,
81447b5b
PP
60 const struct bt_value *object_b);
61
62/* Boolean value object functions */
63struct bt_value *bt_value_bool_create(void);
811644b8 64struct bt_value *bt_value_bool_create_init(int val);
81447b5b 65enum bt_value_status bt_value_bool_get(
811644b8 66 const struct bt_value *bool_obj, int *OUTPUT);
81447b5b 67enum bt_value_status bt_value_bool_set(struct bt_value *bool_obj,
811644b8 68 int val);
81447b5b
PP
69
70/* Integer value object functions */
71struct bt_value *bt_value_integer_create(void);
72struct bt_value *bt_value_integer_create_init(int64_t val);
73enum bt_value_status bt_value_integer_get(
74 const struct bt_value *integer_obj, int64_t *OUTPUT);
75enum bt_value_status bt_value_integer_set(
76 struct bt_value *integer_obj, int64_t val);
77
78/* Floating point number value object functions */
79struct bt_value *bt_value_float_create(void);
80struct bt_value *bt_value_float_create_init(double val);
81enum bt_value_status bt_value_float_get(
82 const struct bt_value *float_obj, double *OUTPUT);
83enum bt_value_status bt_value_float_set(
84 struct bt_value *float_obj, double val);
85
86/* String value object functions */
87struct bt_value *bt_value_string_create(void);
88struct bt_value *bt_value_string_create_init(const char *val);
89enum bt_value_status bt_value_string_set(struct bt_value *string_obj,
90 const char *val);
91enum bt_value_status bt_value_string_get(
92 const struct bt_value *string_obj, const char **BTOUTSTR);
93
94/* Array value object functions */
95struct bt_value *bt_value_array_create(void);
96int bt_value_array_size(const struct bt_value *array_obj);
97struct bt_value *bt_value_array_get(const struct bt_value *array_obj,
98 size_t index);
99enum bt_value_status bt_value_array_append(struct bt_value *array_obj,
100 struct bt_value *element_obj);
101enum bt_value_status bt_value_array_set(struct bt_value *array_obj,
102 size_t index, struct bt_value *element_obj);
103
104/* Map value object functions */
105struct bt_value *bt_value_map_create(void);
106int bt_value_map_size(const struct bt_value *map_obj);
107struct bt_value *bt_value_map_get(const struct bt_value *map_obj,
108 const char *key);
811644b8 109int bt_value_map_has_key(const struct bt_value *map_obj,
81447b5b
PP
110 const char *key);
111enum bt_value_status bt_value_map_insert(
112 struct bt_value *map_obj, const char *key,
113 struct bt_value *element_obj);
811644b8
PP
114struct bt_value *bt_value_map_extend(struct bt_value *base_map_obj,
115 struct bt_value *extension_map_obj);
81447b5b
PP
116
117%{
118struct bt_value_map_get_keys_private_data {
119 struct bt_value *keys;
120};
121
811644b8 122static int bt_value_map_get_keys_private_cb(const char *key,
81447b5b
PP
123 struct bt_value *object, void *data)
124{
125 enum bt_value_status status;
126 struct bt_value_map_get_keys_private_data *priv_data = data;
127
128 status = bt_value_array_append_string(priv_data->keys, key);
129 if (status != BT_VALUE_STATUS_OK) {
811644b8 130 return BT_FALSE;
81447b5b
PP
131 }
132
811644b8 133 return BT_TRUE;
81447b5b
PP
134}
135
136static struct bt_value *bt_value_map_get_keys_private(
137 const struct bt_value *map_obj)
138{
139 enum bt_value_status status;
140 struct bt_value_map_get_keys_private_data data;
141
142 data.keys = bt_value_array_create();
143 if (!data.keys) {
144 return NULL;
145 }
146
147 status = bt_value_map_foreach(map_obj, bt_value_map_get_keys_private_cb,
148 &data);
149 if (status != BT_VALUE_STATUS_OK) {
150 goto error;
151 }
152
153 goto end;
154
155error:
156 if (data.keys) {
157 BT_PUT(data.keys);
158 }
159
160end:
161 return data.keys;
162}
163%}
164
165struct bt_value *bt_value_map_get_keys_private(const struct bt_value *map_obj);
This page took 0.034146 seconds and 4 git commands to generate.