lib: make message iterator creation functions return a status
[babeltrace.git] / include / babeltrace2 / value.h
1 #ifndef BABELTRACE2_VALUE_H
2 #define BABELTRACE2_VALUE_H
3
4 /*
5 * Copyright (c) 2010-2019 EfficiOS Inc. and Linux Foundation
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
26 #ifndef __BT_IN_BABELTRACE_H
27 # error "Please include <babeltrace2/babeltrace.h> instead."
28 #endif
29
30 #include <stdint.h>
31 #include <stddef.h>
32
33 #include <babeltrace2/types.h>
34 #include <babeltrace2/value-const.h>
35
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39
40 extern bt_value *const bt_value_null;
41
42 extern bt_value *bt_value_bool_create(void);
43
44 extern bt_value *bt_value_bool_create_init(bt_bool val);
45
46 extern void bt_value_bool_set(bt_value *bool_obj, bt_bool val);
47
48 extern bt_value *bt_value_integer_unsigned_create(void);
49
50 extern bt_value *bt_value_integer_unsigned_create_init(uint64_t val);
51
52 extern void bt_value_integer_unsigned_set(bt_value *integer_obj, uint64_t val);
53
54 extern bt_value *bt_value_integer_signed_create(void);
55
56 extern bt_value *bt_value_integer_signed_create_init(int64_t val);
57
58 extern void bt_value_integer_signed_set(bt_value *integer_obj, int64_t val);
59
60 extern bt_value *bt_value_real_create(void);
61
62 extern bt_value *bt_value_real_create_init(double val);
63
64 extern void bt_value_real_set(bt_value *real_obj, double val);
65
66 extern bt_value *bt_value_string_create(void);
67
68 extern bt_value *bt_value_string_create_init(const char *val);
69
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,
76 const char *val);
77
78 extern bt_value *bt_value_array_create(void);
79
80 extern bt_value *bt_value_array_borrow_element_by_index(bt_value *array_obj,
81 uint64_t index);
82
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;
87
88 extern bt_value_array_append_element_status bt_value_array_append_element(
89 bt_value *array_obj, bt_value *element_obj);
90
91 extern bt_value_array_append_element_status
92 bt_value_array_append_bool_element(bt_value *array_obj, bt_bool val);
93
94 extern bt_value_array_append_element_status
95 bt_value_array_append_unsigned_integer_element(bt_value *array_obj,
96 uint64_t val);
97
98 extern bt_value_array_append_element_status
99 bt_value_array_append_signed_integer_element(bt_value *array_obj, int64_t val);
100
101 extern bt_value_array_append_element_status
102 bt_value_array_append_real_element(bt_value *array_obj, double val);
103
104 extern bt_value_array_append_element_status
105 bt_value_array_append_string_element(bt_value *array_obj, const char *val);
106
107 extern bt_value_array_append_element_status
108 bt_value_array_append_empty_array_element(bt_value *array_obj,
109 bt_value **element_obj);
110
111 extern bt_value_array_append_element_status
112 bt_value_array_append_empty_map_element(bt_value *array_obj,
113 bt_value **element_obj);
114
115 typedef enum bt_value_array_set_element_by_index_status {
116 BT_VALUE_ARRAY_SET_ELEMENT_BY_INDEX_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR,
117 BT_VALUE_ARRAY_SET_ELEMENT_BY_INDEX_STATUS_OK = __BT_FUNC_STATUS_OK,
118 } bt_value_array_set_element_by_index_status;
119
120 extern bt_value_array_set_element_by_index_status
121 bt_value_array_set_element_by_index(bt_value *array_obj, uint64_t index,
122 bt_value *element_obj);
123
124 extern bt_value *bt_value_map_create(void);
125
126 extern bt_value *bt_value_map_borrow_entry_value(
127 bt_value *map_obj, const char *key);
128
129 typedef bt_bool (* bt_value_map_foreach_entry_func)(const char *key,
130 bt_value *object, void *data);
131
132 typedef enum bt_value_map_foreach_entry_status {
133 BT_VALUE_MAP_FOREACH_ENTRY_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR,
134 BT_VALUE_MAP_FOREACH_ENTRY_STATUS_OK = __BT_FUNC_STATUS_OK,
135 BT_VALUE_MAP_FOREACH_ENTRY_STATUS_INTERRUPTED = __BT_FUNC_STATUS_INTERRUPTED,
136 } bt_value_map_foreach_entry_status;
137
138 extern bt_value_map_foreach_entry_status bt_value_map_foreach_entry(
139 bt_value *map_obj, bt_value_map_foreach_entry_func func,
140 void *data);
141
142 typedef enum bt_value_map_insert_entry_status {
143 BT_VALUE_MAP_INSERT_ENTRY_STATUS_MEMORY_ERROR = __BT_FUNC_STATUS_MEMORY_ERROR,
144 BT_VALUE_MAP_INSERT_ENTRY_STATUS_OK = __BT_FUNC_STATUS_OK,
145 } bt_value_map_insert_entry_status;
146
147 extern bt_value_map_insert_entry_status bt_value_map_insert_entry(
148 bt_value *map_obj, const char *key, bt_value *element_obj);
149
150 extern bt_value_map_insert_entry_status bt_value_map_insert_bool_entry(
151 bt_value *map_obj, const char *key, bt_bool val);
152
153 extern bt_value_map_insert_entry_status
154 bt_value_map_insert_unsigned_integer_entry(bt_value *map_obj, const char *key,
155 uint64_t val);
156
157 extern bt_value_map_insert_entry_status
158 bt_value_map_insert_signed_integer_entry(bt_value *map_obj, const char *key,
159 int64_t val);
160
161 extern bt_value_map_insert_entry_status bt_value_map_insert_real_entry(
162 bt_value *map_obj, const char *key, double val);
163
164 extern bt_value_map_insert_entry_status
165 bt_value_map_insert_string_entry(bt_value *map_obj, const char *key,
166 const char *val);
167
168 extern bt_value_map_insert_entry_status
169 bt_value_map_insert_empty_array_entry(bt_value *map_obj, const char *key,
170 bt_value **entry_obj);
171
172 extern bt_value_map_insert_entry_status
173 bt_value_map_insert_empty_map_entry(bt_value *map_obj, const char *key,
174 bt_value **entry_obj);
175
176 #ifdef __cplusplus
177 }
178 #endif
179
180 #endif /* BABELTRACE2_VALUE_H */
This page took 0.032615 seconds and 4 git commands to generate.