Commit | Line | Data |
---|---|---|
924dc299 PP |
1 | #ifndef BABELTRACE2_VALUE_H |
2 | #define BABELTRACE2_VALUE_H | |
dac5c838 PP |
3 | |
4 | /* | |
bbb7b5f0 | 5 | * Copyright (c) 2010-2019 EfficiOS Inc. and Linux Foundation |
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 | ||
4fa90f32 PP |
26 | #ifndef __BT_IN_BABELTRACE_H |
27 | # error "Please include <babeltrace2/babeltrace.h> instead." | |
28 | #endif | |
29 | ||
dac5c838 | 30 | #include <stdint.h> |
dac5c838 | 31 | #include <stddef.h> |
9d408fca | 32 | |
3fadfbc0 | 33 | #include <babeltrace2/types.h> |
3fadfbc0 | 34 | #include <babeltrace2/value-const.h> |
40f4ba76 | 35 | |
dac5c838 PP |
36 | #ifdef __cplusplus |
37 | extern "C" { | |
38 | #endif | |
39 | ||
211796dc | 40 | extern bt_value *const bt_value_null; |
dac5c838 | 41 | |
b19ff26f | 42 | extern bt_value *bt_value_bool_create(void); |
dac5c838 | 43 | |
b19ff26f | 44 | extern bt_value *bt_value_bool_create_init(bt_bool val); |
dac5c838 | 45 | |
b19ff26f | 46 | extern void bt_value_bool_set(bt_value *bool_obj, bt_bool val); |
dac5c838 | 47 | |
9c08c816 | 48 | extern bt_value *bt_value_integer_unsigned_create(void); |
dac5c838 | 49 | |
9c08c816 | 50 | extern bt_value *bt_value_integer_unsigned_create_init(uint64_t val); |
dac5c838 | 51 | |
9c08c816 | 52 | extern void bt_value_integer_unsigned_set(bt_value *integer_obj, uint64_t val); |
fdd3a2da | 53 | |
9c08c816 | 54 | extern bt_value *bt_value_integer_signed_create(void); |
fdd3a2da | 55 | |
9c08c816 | 56 | extern bt_value *bt_value_integer_signed_create_init(int64_t val); |
fdd3a2da | 57 | |
9c08c816 | 58 | extern void bt_value_integer_signed_set(bt_value *integer_obj, int64_t val); |
de079588 | 59 | |
b19ff26f | 60 | extern bt_value *bt_value_real_create(void); |
de079588 | 61 | |
b19ff26f | 62 | extern bt_value *bt_value_real_create_init(double val); |
dac5c838 | 63 | |
b19ff26f | 64 | extern void bt_value_real_set(bt_value *real_obj, double val); |
dac5c838 | 65 | |
b19ff26f | 66 | extern bt_value *bt_value_string_create(void); |
dac5c838 | 67 | |
b19ff26f | 68 | extern bt_value *bt_value_string_create_init(const char *val); |
dac5c838 | 69 | |
d24d5663 PP |
70 | typedef enum bt_value_string_set_status { |
71 | BT_VALUE_STRING_SET_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, | |
72 | BT_VALUE_STRING_SET_STATUS_OK = __BT_FUNC_STATUS_OK, | |
73 | } bt_value_string_set_status; | |
74 | ||
75 | extern bt_value_string_set_status bt_value_string_set(bt_value *string_obj, | |
05e21286 | 76 | const char *val); |
de079588 | 77 | |
b19ff26f | 78 | extern bt_value *bt_value_array_create(void); |
dac5c838 | 79 | |
d24d5663 PP |
80 | extern bt_value *bt_value_array_borrow_element_by_index(bt_value *array_obj, |
81 | uint64_t index); | |
dac5c838 | 82 | |
d24d5663 PP |
83 | typedef enum bt_value_array_append_element_status { |
84 | BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, | |
85 | BT_VALUE_ARRAY_APPEND_ELEMENT_STATUS_OK = __BT_FUNC_STATUS_OK, | |
86 | } bt_value_array_append_element_status; | |
dac5c838 | 87 | |
d24d5663 PP |
88 | extern bt_value_array_append_element_status bt_value_array_append_element( |
89 | bt_value *array_obj, bt_value *element_obj); | |
05e21286 | 90 | |
d24d5663 PP |
91 | extern bt_value_array_append_element_status |
92 | bt_value_array_append_bool_element(bt_value *array_obj, bt_bool val); | |
fdd3a2da | 93 | |
d24d5663 PP |
94 | extern bt_value_array_append_element_status |
95 | bt_value_array_append_unsigned_integer_element(bt_value *array_obj, | |
96 | uint64_t val); | |
05e21286 | 97 | |
d24d5663 PP |
98 | extern bt_value_array_append_element_status |
99 | bt_value_array_append_signed_integer_element(bt_value *array_obj, int64_t val); | |
05e21286 | 100 | |
d24d5663 PP |
101 | extern bt_value_array_append_element_status |
102 | bt_value_array_append_real_element(bt_value *array_obj, double val); | |
05e21286 | 103 | |
d24d5663 PP |
104 | extern bt_value_array_append_element_status |
105 | bt_value_array_append_string_element(bt_value *array_obj, const char *val); | |
05e21286 | 106 | |
d24d5663 PP |
107 | extern bt_value_array_append_element_status |
108 | bt_value_array_append_empty_array_element(bt_value *array_obj); | |
05e21286 | 109 | |
d24d5663 PP |
110 | extern bt_value_array_append_element_status |
111 | bt_value_array_append_empty_map_element(bt_value *array_obj); | |
112 | ||
113 | typedef enum bt_value_array_set_element_by_index_status { | |
114 | BT_VALUE_ARRAY_SET_ELEMENT_BY_INDEX_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, | |
115 | BT_VALUE_ARRAY_SET_ELEMENT_BY_INDEX_STATUS_OK = __BT_FUNC_STATUS_OK, | |
116 | } bt_value_array_set_element_by_index_status; | |
117 | ||
118 | extern bt_value_array_set_element_by_index_status | |
119 | bt_value_array_set_element_by_index(bt_value *array_obj, uint64_t index, | |
b19ff26f | 120 | bt_value *element_obj); |
05e21286 | 121 | |
b19ff26f | 122 | extern bt_value *bt_value_map_create(void); |
dac5c838 | 123 | |
b19ff26f PP |
124 | extern bt_value *bt_value_map_borrow_entry_value( |
125 | bt_value *map_obj, const char *key); | |
dac5c838 | 126 | |
40f4ba76 | 127 | typedef bt_bool (* bt_value_map_foreach_entry_func)(const char *key, |
b19ff26f | 128 | bt_value *object, void *data); |
de079588 | 129 | |
d24d5663 PP |
130 | typedef enum bt_value_map_foreach_entry_status { |
131 | BT_VALUE_MAP_FOREACH_ENTRY_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, | |
132 | BT_VALUE_MAP_FOREACH_ENTRY_STATUS_OK = __BT_FUNC_STATUS_OK, | |
9b4f9b42 | 133 | BT_VALUE_MAP_FOREACH_ENTRY_STATUS_INTERRUPTED = __BT_FUNC_STATUS_INTERRUPTED, |
d24d5663 | 134 | } bt_value_map_foreach_entry_status; |
dac5c838 | 135 | |
d24d5663 PP |
136 | extern bt_value_map_foreach_entry_status bt_value_map_foreach_entry( |
137 | bt_value *map_obj, bt_value_map_foreach_entry_func func, | |
138 | void *data); | |
05e21286 | 139 | |
d24d5663 PP |
140 | typedef enum bt_value_map_insert_entry_status { |
141 | BT_VALUE_MAP_INSERT_ENTRY_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR, | |
142 | BT_VALUE_MAP_INSERT_ENTRY_STATUS_OK = __BT_FUNC_STATUS_OK, | |
143 | } bt_value_map_insert_entry_status; | |
144 | ||
145 | extern bt_value_map_insert_entry_status bt_value_map_insert_entry( | |
146 | bt_value *map_obj, const char *key, bt_value *element_obj); | |
147 | ||
148 | extern bt_value_map_insert_entry_status bt_value_map_insert_bool_entry( | |
b19ff26f | 149 | bt_value *map_obj, const char *key, bt_bool val); |
05e21286 | 150 | |
d24d5663 PP |
151 | extern bt_value_map_insert_entry_status |
152 | bt_value_map_insert_unsigned_integer_entry(bt_value *map_obj, const char *key, | |
153 | uint64_t val); | |
fdd3a2da | 154 | |
d24d5663 PP |
155 | extern bt_value_map_insert_entry_status |
156 | bt_value_map_insert_signed_integer_entry(bt_value *map_obj, const char *key, | |
157 | int64_t val); | |
05e21286 | 158 | |
d24d5663 | 159 | extern bt_value_map_insert_entry_status bt_value_map_insert_real_entry( |
b19ff26f | 160 | bt_value *map_obj, const char *key, double val); |
05e21286 | 161 | |
d24d5663 PP |
162 | extern bt_value_map_insert_entry_status |
163 | bt_value_map_insert_string_entry(bt_value *map_obj, const char *key, | |
05e21286 PP |
164 | const char *val); |
165 | ||
d24d5663 PP |
166 | extern bt_value_map_insert_entry_status |
167 | bt_value_map_insert_empty_array_entry(bt_value *map_obj, const char *key); | |
dac5c838 | 168 | |
d24d5663 PP |
169 | extern bt_value_map_insert_entry_status |
170 | bt_value_map_insert_empty_map_entry(bt_value *map_obj, const char *key); | |
770750d3 | 171 | |
dac5c838 PP |
172 | #ifdef __cplusplus |
173 | } | |
174 | #endif | |
175 | ||
924dc299 | 176 | #endif /* BABELTRACE2_VALUE_H */ |