Commit | Line | Data |
---|---|---|
924dc299 PP |
1 | #ifndef BABELTRACE2_VALUE_H |
2 | #define BABELTRACE2_VALUE_H | |
dac5c838 PP |
3 | |
4 | /* | |
05e21286 | 5 | * Copyright (c) 2015-2018 Philippe Proulx <pproulx@efficios.com> |
dac5c838 PP |
6 | * |
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy | |
8 | * of this software and associated documentation files (the "Software"), to deal | |
9 | * in the Software without restriction, including without limitation the rights | |
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
11 | * copies of the Software, and to permit persons to whom the Software is | |
12 | * furnished to do so, subject to the following conditions: | |
13 | * | |
14 | * The above copyright notice and this permission notice shall be included in | |
15 | * all copies or substantial portions of the Software. | |
16 | * | |
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
23 | * SOFTWARE. | |
24 | */ | |
25 | ||
dac5c838 | 26 | #include <stdint.h> |
dac5c838 | 27 | #include <stddef.h> |
9d408fca | 28 | |
b19ff26f | 29 | /* For bt_bool, bt_value */ |
3fadfbc0 | 30 | #include <babeltrace2/types.h> |
dac5c838 | 31 | |
d24d5663 | 32 | /* For bt_value_type */ |
3fadfbc0 | 33 | #include <babeltrace2/value-const.h> |
40f4ba76 | 34 | |
d24d5663 PP |
35 | /* For __BT_FUNC_STATUS_* */ |
36 | #define __BT_FUNC_STATUS_ENABLE | |
37 | #include <babeltrace2/func-status.h> | |
38 | #undef __BT_FUNC_STATUS_ENABLE | |
39 | ||
dac5c838 PP |
40 | #ifdef __cplusplus |
41 | extern "C" { | |
42 | #endif | |
43 | ||
211796dc | 44 | extern bt_value *const bt_value_null; |
dac5c838 | 45 | |
b19ff26f | 46 | extern bt_value *bt_value_bool_create(void); |
dac5c838 | 47 | |
b19ff26f | 48 | extern bt_value *bt_value_bool_create_init(bt_bool val); |
dac5c838 | 49 | |
b19ff26f | 50 | extern void bt_value_bool_set(bt_value *bool_obj, bt_bool val); |
dac5c838 | 51 | |
fdd3a2da | 52 | extern bt_value *bt_value_unsigned_integer_create(void); |
dac5c838 | 53 | |
fdd3a2da | 54 | extern bt_value *bt_value_unsigned_integer_create_init(uint64_t val); |
dac5c838 | 55 | |
fdd3a2da PP |
56 | extern void bt_value_unsigned_integer_set(bt_value *integer_obj, uint64_t val); |
57 | ||
58 | extern bt_value *bt_value_signed_integer_create(void); | |
59 | ||
60 | extern bt_value *bt_value_signed_integer_create_init(int64_t val); | |
61 | ||
62 | extern void bt_value_signed_integer_set(bt_value *integer_obj, int64_t val); | |
de079588 | 63 | |
b19ff26f | 64 | extern bt_value *bt_value_real_create(void); |
de079588 | 65 | |
b19ff26f | 66 | extern bt_value *bt_value_real_create_init(double val); |
dac5c838 | 67 | |
b19ff26f | 68 | extern void bt_value_real_set(bt_value *real_obj, double val); |
dac5c838 | 69 | |
b19ff26f | 70 | extern bt_value *bt_value_string_create(void); |
dac5c838 | 71 | |
b19ff26f | 72 | extern bt_value *bt_value_string_create_init(const char *val); |
dac5c838 | 73 | |
d24d5663 PP |
74 | typedef enum bt_value_string_set_status { |
75 | BT_VALUE_STRING_SET_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, | |
76 | BT_VALUE_STRING_SET_STATUS_OK = __BT_FUNC_STATUS_OK, | |
77 | } bt_value_string_set_status; | |
78 | ||
79 | extern bt_value_string_set_status bt_value_string_set(bt_value *string_obj, | |
05e21286 | 80 | const char *val); |
de079588 | 81 | |
b19ff26f | 82 | extern bt_value *bt_value_array_create(void); |
dac5c838 | 83 | |
d24d5663 PP |
84 | extern bt_value *bt_value_array_borrow_element_by_index(bt_value *array_obj, |
85 | uint64_t index); | |
dac5c838 | 86 | |
d24d5663 PP |
87 | typedef enum bt_value_array_append_element_status { |
88 | BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, | |
89 | BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OK = __BT_FUNC_STATUS_OK, | |
90 | } bt_value_array_append_element_status; | |
dac5c838 | 91 | |
d24d5663 PP |
92 | extern bt_value_array_append_element_status bt_value_array_append_element( |
93 | bt_value *array_obj, bt_value *element_obj); | |
05e21286 | 94 | |
d24d5663 PP |
95 | extern bt_value_array_append_element_status |
96 | bt_value_array_append_bool_element(bt_value *array_obj, bt_bool val); | |
fdd3a2da | 97 | |
d24d5663 PP |
98 | extern bt_value_array_append_element_status |
99 | bt_value_array_append_unsigned_integer_element(bt_value *array_obj, | |
100 | uint64_t val); | |
05e21286 | 101 | |
d24d5663 PP |
102 | extern bt_value_array_append_element_status |
103 | bt_value_array_append_signed_integer_element(bt_value *array_obj, int64_t val); | |
05e21286 | 104 | |
d24d5663 PP |
105 | extern bt_value_array_append_element_status |
106 | bt_value_array_append_real_element(bt_value *array_obj, double val); | |
05e21286 | 107 | |
d24d5663 PP |
108 | extern bt_value_array_append_element_status |
109 | bt_value_array_append_string_element(bt_value *array_obj, const char *val); | |
05e21286 | 110 | |
d24d5663 PP |
111 | extern bt_value_array_append_element_status |
112 | bt_value_array_append_empty_array_element(bt_value *array_obj); | |
05e21286 | 113 | |
d24d5663 PP |
114 | extern bt_value_array_append_element_status |
115 | bt_value_array_append_empty_map_element(bt_value *array_obj); | |
116 | ||
117 | typedef enum bt_value_array_set_element_by_index_status { | |
118 | BT_VALUE_ARRAY_SET_ELEMENT_BY_INDEX_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, | |
119 | BT_VALUE_ARRAY_SET_ELEMENT_BY_INDEX_STATUS_OK = __BT_FUNC_STATUS_OK, | |
120 | } bt_value_array_set_element_by_index_status; | |
121 | ||
122 | extern bt_value_array_set_element_by_index_status | |
123 | bt_value_array_set_element_by_index(bt_value *array_obj, uint64_t index, | |
b19ff26f | 124 | bt_value *element_obj); |
05e21286 | 125 | |
b19ff26f | 126 | extern bt_value *bt_value_map_create(void); |
dac5c838 | 127 | |
b19ff26f PP |
128 | extern bt_value *bt_value_map_borrow_entry_value( |
129 | bt_value *map_obj, const char *key); | |
dac5c838 | 130 | |
40f4ba76 | 131 | typedef bt_bool (* bt_value_map_foreach_entry_func)(const char *key, |
b19ff26f | 132 | bt_value *object, void *data); |
de079588 | 133 | |
d24d5663 PP |
134 | typedef enum bt_value_map_foreach_entry_status { |
135 | BT_VALUE_MAP_FOREACH_ENTRY_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, | |
136 | BT_VALUE_MAP_FOREACH_ENTRY_STATUS_OK = __BT_FUNC_STATUS_OK, | |
137 | BT_VALUE_MAP_FOREACH_ENTRY_STATUS_CANCELED = __BT_FUNC_STATUS_CANCELED, | |
138 | } bt_value_map_foreach_entry_status; | |
dac5c838 | 139 | |
d24d5663 PP |
140 | extern bt_value_map_foreach_entry_status bt_value_map_foreach_entry( |
141 | bt_value *map_obj, bt_value_map_foreach_entry_func func, | |
142 | void *data); | |
05e21286 | 143 | |
d24d5663 PP |
144 | typedef enum bt_value_map_insert_entry_status { |
145 | BT_VALUE_MAP_INSERT_ENTRY_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, | |
146 | BT_VALUE_MAP_INSERT_ENTRY_STATUS_OK = __BT_FUNC_STATUS_OK, | |
147 | } bt_value_map_insert_entry_status; | |
148 | ||
149 | extern bt_value_map_insert_entry_status bt_value_map_insert_entry( | |
150 | bt_value *map_obj, const char *key, bt_value *element_obj); | |
151 | ||
152 | extern bt_value_map_insert_entry_status bt_value_map_insert_bool_entry( | |
b19ff26f | 153 | bt_value *map_obj, const char *key, bt_bool val); |
05e21286 | 154 | |
d24d5663 PP |
155 | extern bt_value_map_insert_entry_status |
156 | bt_value_map_insert_unsigned_integer_entry(bt_value *map_obj, const char *key, | |
157 | uint64_t val); | |
fdd3a2da | 158 | |
d24d5663 PP |
159 | extern bt_value_map_insert_entry_status |
160 | bt_value_map_insert_signed_integer_entry(bt_value *map_obj, const char *key, | |
161 | int64_t val); | |
05e21286 | 162 | |
d24d5663 | 163 | extern bt_value_map_insert_entry_status bt_value_map_insert_real_entry( |
b19ff26f | 164 | bt_value *map_obj, const char *key, double val); |
05e21286 | 165 | |
d24d5663 PP |
166 | extern bt_value_map_insert_entry_status |
167 | bt_value_map_insert_string_entry(bt_value *map_obj, const char *key, | |
05e21286 PP |
168 | const char *val); |
169 | ||
d24d5663 PP |
170 | extern bt_value_map_insert_entry_status |
171 | bt_value_map_insert_empty_array_entry(bt_value *map_obj, const char *key); | |
dac5c838 | 172 | |
d24d5663 PP |
173 | extern bt_value_map_insert_entry_status |
174 | bt_value_map_insert_empty_map_entry(bt_value *map_obj, const char *key); | |
770750d3 | 175 | |
dac5c838 PP |
176 | #ifdef __cplusplus |
177 | } | |
178 | #endif | |
179 | ||
d24d5663 PP |
180 | #include <babeltrace2/undef-func-status.h> |
181 | ||
924dc299 | 182 | #endif /* BABELTRACE2_VALUE_H */ |